Commit Graph

207293 Commits

Author SHA1 Message Date
Dylan DPC
e461e94165
Rollup merge of #102475 - RalfJung:unsafe, r=dtolnay
unsafe keyword: trait examples and unsafe_op_in_unsafe_fn update

Having a safe `fn` in an `unsafe trait` vs an `unsafe fn` in a safe `trait` are pretty different situations, but the distinction is subtle and can confuse even seasoned Rust developers. So let's have explicit examples of both. I also removed the existing `unsafe trait` example since it was rather strange.

Also the `unsafe_op_in_unsafe_fn` lint can help disentangle the two sides of `unsafe`, so update the docs to account for that.
2022-10-07 22:05:30 +05:30
Dylan DPC
2592609574
Rollup merge of #102300 - scottmcm:simpler-fold-closures, r=Mark-Simulacrum
Use a macro to not have to copy-paste `ConstFnMutClosure::new(&mut fold, NeverShortCircuit::wrap_mut_2_imp)).0` everywhere

Also use that macro to replace a bunch of places that had custom closure-wrappers.

+35 -114 sounds good to me.
2022-10-07 22:05:29 +05:30
Oli Scherer
d90d055691 Allow transmutes between the same types after erasing lifetimes 2022-10-07 16:33:32 +00:00
Michael Goulet
8b9a1f1f4e Remove tuple candidate, nothing special about it 2022-10-07 16:19:21 +00:00
Ralf Jung
fd59d44f58 make const_err a hard error 2022-10-07 18:08:49 +02:00
Deadbeef
e8a2aee50d Remove DefId from some SelectionCandidate variants 2022-10-07 15:14:22 +00:00
Hosshii
462730fdae Add regression test for #102124 2022-10-07 23:36:59 +09:00
Cameron Steffen
ff940db666 Rewrite representability 2022-10-07 09:33:46 -05:00
bors
43c22af267 Auto merge of #101632 - camsteffen:refactor-infer-err, r=lcnr
Remove `TypeckResults` from `InferCtxt`

`InferCtxt` currently has `in_progress_typeck_results` which is only used for some diagnostics during typeck. It adds a lifetime which propagates through a lot of code. This PR moves that field into a new helper struct `TypeErrCtxt`.
2022-10-07 13:54:55 +00:00
Ralf Jung
c30dcff97a review feedback 2022-10-07 15:21:47 +02:00
Ralf Jung
d71a85135b fix Miri 2022-10-07 14:57:41 +02:00
Ralf Jung
3d93c3848a run Miri CI when std::sys changes 2022-10-07 14:39:07 +02:00
Ralf Jung
6f6433428f add a few more assert_unsafe_precondition 2022-10-07 14:35:12 +02:00
Cameron Steffen
283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Takayuki Maeda
fa767868df fix a ICE #102768 2022-10-07 21:10:08 +09:00
Cameron Steffen
91269fa5b8 Remove a reference from Inherited 2022-10-07 07:06:19 -05:00
Cameron Steffen
349415d1c6 Remove TypeckResults from InferCtxt 2022-10-07 07:06:19 -05:00
Cameron Steffen
4a68373217 Introduce TypeErrCtxt
TypeErrCtxt optionally has a TypeckResults so that InferCtxt doesn't
need to.
2022-10-07 07:06:16 -05:00
Gary Guo
242348343b Fix MIR inlining of asm_unwind 2022-10-07 12:59:38 +01:00
bors
e42c4d7218 Auto merge of #102025 - chenyukang:fix-102002, r=jyn514
Delete the stage1 and stage0-sysroot directories when using download-rustc

Fixes #102002
2022-10-07 10:46:04 +00:00
joboet
5d0211dc03
std: use futex in Once 2022-10-07 12:12:36 +02:00
bors
5854680388 Auto merge of #102767 - matthiaskrgr:rollup-vcbt81v, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #102577 (Warn about Visual Studio Code branding confusion)
 - #102720 (do not reverse the expected type and found type for ObligationCauseCo…)
 - #102744 (rustdoc: remove unused CSS `.content .item-list`)
 - #102747 (rustdoc: remove unused CSS `.docblock a:not(.srclink)`)
 - #102748 (Disable compressed debug sections on i586-gnu)
 - #102761 (let-else: test else block with non-never uninhabited type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-07 07:31:53 +00:00
Matthias Krüger
a09e2f6753
Rollup merge of #102761 - est31:let_else_uninhabited_test, r=compiler-errors
let-else: test else block with non-never uninhabited type

let else currently does not allow uninhabited types for the `else` block that aren't `!`. One can maybe think about relaxing this in the future, but if it is done, it should be an explicit choice and not an unexpected side effect of e.g. a refactor. Thus, I'm extending a test that will fail if the behaviour changes.
2022-10-07 07:28:12 +02:00
Matthias Krüger
04459f7a6a
Rollup merge of #102748 - cuviper:i586-gnu-uncompress, r=pietroalbini
Disable compressed debug sections on i586-gnu

Compressed debug is enabled by default for gas (assembly) on Linux/x86
targets, and we started building our own in #102530, but that made our
`compiler_builtins` incompatible with binutils < 2.32. Add an explicit
option to disable that in our crosstool-ng config. Fixes #102703.
2022-10-07 07:28:11 +02:00
Matthias Krüger
d6c05fb9f1
Rollup merge of #102747 - notriddle:notriddle/docblock-a-not-srclink, r=GuillaumeGomez
rustdoc: remove unused CSS `.docblock a:not(.srclink)`

This selector was added in c7312fbae4, because the list of impl items could be nested below `docblock`.

c7312fbae4/src/librustdoc/html/render.rs (L3841-L3845)

Now that rustdoc toggles have been switched to `<details>`, there shouldn't be any need to put things inside docblock containers just to give them disclosure toggles.
2022-10-07 07:28:11 +02:00
Matthias Krüger
a636398897
Rollup merge of #102744 - notriddle:notriddle/content-item-list, r=GuillaumeGomez
rustdoc: remove unused CSS `.content .item-list`

When these rules were added in 4fd061c426 (yeah, that's the very first commit of rustdoc_ng), `.item-list` was a `<ul>`, and this would override the default style for that tag.

In c1b1d6804b, it was changed to use a `<div>` tag, so these rules are both no-ops.
2022-10-07 07:28:10 +02:00
Matthias Krüger
047ff20875
Rollup merge of #102720 - lyming2007:issue-102397-fix, r=compiler-errors
do not reverse the expected type and found type for ObligationCauseCo…

…de of IfExpressionWithNoElse

this will fix #102397
2022-10-07 07:28:10 +02:00
Matthias Krüger
1a2a3249bc
Rollup merge of #102577 - kornelski:non-code-visual-studio, r=wesleywiser
Warn about Visual Studio Code branding confusion

VS Code is a popular companion for Rust, but Microsoft's branding is confusing, and users [may not understand](https://users.rust-lang.org/t/complie-error-when-i-run-rustc/82127) they also need the *other* VS.
2022-10-07 07:28:09 +02:00
bors
cf0fa76f27 Auto merge of #101988 - petrochenkov:flavor2, r=lqd
rustc_target: Refactor internal linker flavors

In accordance with the design from https://github.com/rust-lang/rust/pull/96827#issuecomment-1208441595

`lld_flavor` and `linker_is_gnu` fields are removed from internal target specs, but still parsed from JSON specs using compatibility layer introduced in https://github.com/rust-lang/rust/pull/100552.
r? `@lqd`
2022-10-07 03:35:02 +00:00
Ben Kimock
95ae993bd8 Avoid defensive re-initialization of the BufReader buffer 2022-10-06 23:31:57 -04:00
Michael Goulet
414319468b Check WhereClauseReferencesSelf after all other object safety checks 2022-10-07 02:29:19 +00:00
est31
58fb351cad let-else: test else block with non-never uninhabited type 2022-10-07 03:05:27 +02:00
bors
233384f395 Auto merge of #102729 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2022-10-06 23:11:18 +00:00
Kornel
9b3db34072 Warn about Visual Studio Code branding confusion 2022-10-06 20:56:44 +01:00
bors
0ca356586f Auto merge of #102741 - matthiaskrgr:rollup-63no5tz, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #98496 (make `compare_const_impl` a query and use it in `instance.rs`)
 - #102680 (Fix overconstrained Send impls in btree internals)
 - #102718 (Fix `opaque_hidden_inferred_bound` lint ICE)
 - #102725 (Remove `-Ztime`)
 - #102736 (Migrate search input color to CSS variable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-06 19:55:48 +00:00
Josh Stone
1158398688 Disable compressed debug sections on i586-gnu
Compressed debug is enabled by default for gas (assembly) on Linux/x86
targets, and we started building our own in #102530, but that made our
`compiler_builtins` incompatible with binutils < 2.32. Add an explicit
option to disable that in our crosstool-ng config. Fixes #102703.
2022-10-06 12:13:23 -07:00
Michael Howell
28b26b7aa6 rustdoc: remove unused CSS .docblock a:not(.srclink)
This selector was added in c7312fbae4,
because the list of impl items could be nested below `docblock`.

c7312fbae4/src/librustdoc/html/render.rs (L3841-L3845)

Now that rustdoc toggles have been switched to `<details>`, there shouldn't
be any need to put things inside docblock containers just to give them
disclosure toggles.
2022-10-06 11:21:42 -07:00
Michael Howell
0997b28a89 rustdoc: remove unused HTML class="item-list"
Since 50f662e99e, there is no CSS or JS
targeting this class.
2022-10-06 10:55:33 -07:00
Michael Howell
50f662e99e rustdoc: remove unused CSS .content .item-list
When these rules were added in 4fd061c426
(yeah, that's the very first commit of rustdoc_ng), `.item-list` was a
`<ul>`, and this would override the default style for that tag.

In c1b1d6804b, it was changed to use a
`<div>` tag, so these rules are both no-ops.
2022-10-06 10:18:43 -07:00
Philipp Krones
2b30ce04ac
Merge commit '8f1ebdd18bdecc621f16baaf779898cc08cc2766' into clippyup 2022-10-06 17:41:53 +02:00
bors
8f1ebdd18b Auto merge of #9593 - Andy-Python-Programmer:master, r=llogiq
lint::unsafe_removed_from_name: fix false positive result when allowed

changelog: [`unsafe_removed_from_name`] Fix allowing on imports produces a false positive on `useless_attribute`.

Fixes: #9197

Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
2022-10-06 14:39:26 +00:00
Matthias Krüger
48964bdb87
Rollup merge of #102736 - GuillaumeGomez:search-input-color, r=notriddle
Migrate search input color to CSS variable

Part of https://github.com/rust-lang/rust/pull/98460.

No UI changes.

r? `@notriddle`
2022-10-06 16:29:45 +02:00
Matthias Krüger
42df0a580f
Rollup merge of #102725 - nnethercote:rm-Z-time, r=davidtwco
Remove `-Ztime`

Because it has a lot of overlap with `-Ztime-passes` but is generally less useful. Plus some related cleanups.

Best reviewed one commit at a time.

r? `@davidtwco`
2022-10-06 16:29:45 +02:00
Matthias Krüger
045fc18cde
Rollup merge of #102718 - compiler-errors:opaque-bound-lint-ice, r=fee1-dead
Fix `opaque_hidden_inferred_bound` lint ICE

Fixes #102705
2022-10-06 16:29:44 +02:00
Matthias Krüger
e77e0200ae
Rollup merge of #102680 - dtolnay:btreesend, r=thomcc
Fix overconstrained Send impls in btree internals

Fixes https://github.com/dtolnay/async-trait/issues/215.

Minimal repro:

```rust
use std::collections::btree_map::Iter;

fn require_send<T: Send>(_: T) {}

fn main() {
    require_send(async {
        let _iter = None::<Iter<(), &()>>;
        async {}.await;
    });
}
```

```console
error: higher-ranked lifetime error
 --> src/main.rs:6:5
  |
6 | /     require_send(async {
7 | |         let _iter = None::<Iter<(), &()>>;
8 | |         async {}.await;
9 | |     });
  | |______^
  |
  = note: could not prove `impl Future<Output = ()>: Send`
```

Not-quite-so-minimal repro:

```rust
use std::collections::BTreeMap;
use std::future::Future;

fn spawn<T: Future + Send>(_: T) {}

async fn f() {
    let map = BTreeMap::<u32, Box<dyn Send + Sync>>::new();
    for _ in &map {
        async {}.await;
    }
}

fn main() {
    spawn(f());
}
```

```console
error: higher-ranked lifetime error
  --> src/main.rs:14:5
   |
14 |     spawn(f());
   |     ^^^^^^^^^^
   |
   = note: could not prove `impl Future<Output = ()>: Send`
```

I am not familiar with the btree internals, but it seems clear to me that the `async fn f` above should return a Send future. Using HashMap instead of BTreeMap in that code makes it already return a Send future.

The _"higher-ranked lifetime error"_ message may be a regression in Rust 1.63. Using older compilers the error message was more detailed:

```console
error: implementation of `Send` is not general enough
  --> src/main.rs:14:5
   |
14 |     spawn(f());
   |     ^^^^^ implementation of `Send` is not general enough
   |
   = note: `Send` would have to be implemented for the type `alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Immut<'0>, u32, Box<(dyn Send + Sync + '1)>, alloc::collections::btree::node::marker::LeafOrInternal>`, for any two lifetimes `'0` and `'1`...
   = note: ...but `Send` is actually implemented for the type `alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Immut<'2>, u32, Box<dyn Send + Sync>, alloc::collections::btree::node::marker::LeafOrInternal>`, for some specific lifetime `'2`

error: implementation of `Send` is not general enough
  --> src/main.rs:14:5
   |
14 |     spawn(f());
   |     ^^^^^ implementation of `Send` is not general enough
   |
   = note: `Send` would have to be implemented for the type `alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Immut<'0>, u32, Box<(dyn Send + Sync + '1)>, alloc::collections::btree::node::marker::Leaf>`, for any two lifetimes `'0` and `'1`...
   = note: ...but `Send` is actually implemented for the type `alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Immut<'2>, u32, Box<dyn Send + Sync>, alloc::collections::btree::node::marker::Leaf>`, for some specific lifetime `'2`
```
2022-10-06 16:29:44 +02:00
Matthias Krüger
dd0fa6f871
Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnr
make `compare_const_impl` a query and use it in `instance.rs`

Fixes #88365

the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons:
- the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable)
- it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71))

r? `@lcnr`
2022-10-06 16:29:43 +02:00
bors
6dd0c3a9e8 Auto merge of #9599 - nyurik:inline-crash, r=flip1995
Add a temporary workaround for  multiline formart arg inlining

per suggestion in
https://github.com/rust-lang/rust/pull/102729#discussion_r988990080

workaround for an internal crash when handling multi-line format argument inlining.

changelog: none

(no point for changelog because it is still a new lint being introduced)
2022-10-06 14:12:29 +00:00
Yuri Astrakhan
cfd6c8d19d Add a temporary workaround for multiline formart arg inlining
per suggestion in
https://github.com/rust-lang/rust/pull/102729#discussion_r988990080

workaround for an internal crash when handling multi-line format
argument inlining.
2022-10-06 09:24:57 -04:00
bors
45343e2bb8 Auto merge of #9598 - nyurik:fix-comment, r=Alexendoo
lint: fix a few comments

minor cleanup per `@Alexendoo` [comment](https://github.com/rust-lang/rust-clippy/pull/9586#discussion_r988991976)

changelog: none
2022-10-06 12:56:27 +00:00
Yuri Astrakhan
c251f8d8dd lint: fix a few comments 2022-10-06 08:54:07 -04:00