Commit Graph

237958 Commits

Author SHA1 Message Date
David Tolnay
8b8906b264
Add method for checking if deprecation is a rustc version 2023-10-30 17:13:38 -07:00
David Tolnay
dccf10e989
Descriptive variant name deprecation versions outside the standard library 2023-10-30 17:13:26 -07:00
Michael Goulet
add09e66f2 Some more coroutine renamings 2023-10-30 23:46:27 +00:00
David Tolnay
e8868af75b
Represent absence of 'since' attribute as a variant of DeprecatedSince 2023-10-30 16:46:02 -07:00
David Tolnay
c52367276d
Preserve deprecation attribute even if 'since' version is missing 2023-10-30 15:48:46 -07:00
bors
a395214a3a Auto merge of #116405 - estebank:issue-103155, r=davidtwco
Detect object safety errors when assoc type is missing

When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with.

Fix #103155.
2023-10-30 22:47:48 +00:00
David Tolnay
b106167673
Add a DeprecatedSince::Err variant for versions that fail to parse 2023-10-30 15:41:18 -07:00
Esteban Küber
b8a8ba9c91 Sort errors 2023-10-30 22:19:17 +00:00
Esteban Küber
8c5577283c Add test 2023-10-30 22:12:07 +00:00
Esteban Küber
17a6ae2df3 Detect object safety errors when assoc type is missing
When an associated type with GATs isn't specified in a `dyn Trait`, emit
an object safety error instead of only complaining about the missing
associated type, as it will lead the user down a path of three different
errors before letting them know that what they were trying to do is
impossible to begin with.

Fix #103155.
2023-10-30 22:12:07 +00:00
Nicholas Nethercote
5b391b01ce Test the multispan case in tests.ui/bounds-lifetime.rs. 2023-10-31 08:01:02 +11:00
Nicholas Nethercote
499b3098f8 Fix a FIXME, by adding a gate_multi macro.
Note that this adds the `span.allows_unstable` checking that this case
previously lacked.
2023-10-31 08:01:01 +11:00
Nicholas Nethercote
de17ec9dae Rearrange the gate_feature_* macros. 2023-10-31 08:01:01 +11:00
Nicholas Nethercote
c88954e9c1 Use if let to reduce some excessive indentation. 2023-10-31 08:01:01 +11:00
Nicholas Nethercote
dcb72e705f Use a slice pattern to neaten a condition. 2023-10-31 08:01:01 +11:00
Nicholas Nethercote
531b38ac23 Cover two more cases in the gate_doc macro. 2023-10-31 08:01:01 +11:00
Nicholas Nethercote
bb3e09f144 Streamline gate_feature_* macros.
The debug probably isn't useful, and assigning all the `$foo`
metavariables to `foo` variables is verbose and weird. Also, `$x:expr`
usually doesn't have a space after the `:`.
2023-10-31 08:00:53 +11:00
bors
31bc7e2c47 Auto merge of #117415 - matthiaskrgr:rollup-jr2p1t2, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #116862 (Detect when trait is implemented for type and suggest importing it)
 - #117389 (Some diagnostics improvements of `gen` blocks)
 - #117396 (Don't treat closures/coroutine types as part of the public API)
 - #117398 (Correctly handle nested or-patterns in exhaustiveness)
 - #117403 (Poison check_well_formed if method receivers are invalid to prevent typeck from running on it)
 - #117411 (Improve some diagnostics around `?Trait` bounds)
 - #117414 (Don't normalize to an un-revealed opaque when we hit the recursion limit)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-30 20:50:14 +00:00
Michael Goulet
48491c182b Also consider TAIT to be uncomputable if the MIR body is tainted 2023-10-30 20:16:22 +00:00
Celina G. Val
af7472ecbc Add a stable MIR visitor
Add a few utility functions as well and extend most `mir` and `ty`
ADTs to implement `PartialEq` and `Eq`.
2023-10-30 13:11:14 -07:00
Matthias Krüger
c5aec96440
Rollup merge of #117414 - compiler-errors:tait-forevert, r=oli-obk
Don't normalize to an un-revealed opaque when we hit the recursion limit

Currently, we will normalize `Opaque := Option<&Opaque>` to something like `Option<&Option<&Option<&...Opaque>>>`, hitting a limit and bottoming out in an unnormalized opaque after the recursion limit gets hit.

Unfortunately, during `layout_of`, we'll simply recurse and try again if the type normalizes to something different than the type:
e6e931dda5/compiler/rustc_ty_utils/src/layout.rs (L58-L60)

That means then we'll try to normalize `Option<&Option<&Option<&...Opaque>>>` again, substituting `Opaque` into itself even deeper. Eventually this will get to the point that we're just stack-overflowing on a really deep type before even hitting an opaque again.

To fix this, we just bottom out into `ty::Error` instead of the unrevealed opaque type.

Fixes #117412

r? `@oli-obk`
2023-10-30 21:03:40 +01:00
Matthias Krüger
3e95c6ab03
Rollup merge of #117411 - oli-obk:query_merge_immobile_game, r=compiler-errors,Nilstrieb
Improve some diagnostics around `?Trait` bounds

* uses better spans
* clarifies a message that was only talking about generic params, but applies to `dyn ?Trait` and `impl ?Trait` as well
2023-10-30 21:03:39 +01:00
Matthias Krüger
24c6b6c803
Rollup merge of #117403 - oli-obk:the_gift_that_keeps_on_giving_116849, r=compiler-errors
Poison check_well_formed if method receivers are invalid to prevent typeck from running on it

fixes #117379

Though if some code invokes typeck without having first invoked `check_well_formed` then we'll encounter this ICE again. This can happen in const and const fn bodies if they are evaluated due to other `check_well_formed` checks or similar
2023-10-30 21:03:39 +01:00
Matthias Krüger
342483ccc6
Rollup merge of #117398 - Nadrieril:fix-117378, r=compiler-errors
Correctly handle nested or-patterns in exhaustiveness

I had assumed nested or-patterns were flattened, and they mostly are but not always.

Fixes https://github.com/rust-lang/rust/issues/117378
2023-10-30 21:03:38 +01:00
Matthias Krüger
e648f479d8
Rollup merge of #117396 - oli-obk:privacy_visitor_types, r=compiler-errors
Don't treat closures/coroutine types as part of the public API

Fixes a regression from https://github.com/rust-lang/rust/pull/117076

r? `@compiler-errors`
2023-10-30 21:03:38 +01:00
Matthias Krüger
86259e79e4
Rollup merge of #117389 - oli-obk:gen_fn, r=compiler-errors
Some diagnostics improvements of `gen` blocks

These are leftovers from https://github.com/rust-lang/rust/pull/116447
2023-10-30 21:03:37 +01:00
Matthias Krüger
c299595379
Rollup merge of #116862 - estebank:issue-57457, r=oli-obk
Detect when trait is implemented for type and suggest importing it

Fix #57457.
2023-10-30 21:03:37 +01:00
y21
69c3b9c252 new lint: unnecessary_fallible_conversions 2023-10-30 20:54:24 +01:00
Michael Goulet
c91f60e22f Don't super-fold types when we hit the recursion limit 2023-10-30 19:24:15 +00:00
bors
236ac911de Auto merge of #117405 - GuillaumeGomez:rollup-i3jxtwh, r=GuillaumeGomez
Rollup of 11 pull requests

Successful merges:

 - #112463 (rustdoc: elide cross-crate default generic arguments)
 - #117068 (Clean up `compiler/rustc*/Cargo.toml`)
 - #117132 (On object safety error, mention new enum as alternative)
 - #117317 (share some track_caller logic between interpret and codegen)
 - #117356 (Add support for mipsel-unknown-netbsd, 32-bit LE mips.)
 - #117357 (Rename a few remaining references to abort terminator)
 - #117370 (C-variadic error improvements)
 - #117376 (More `rustc_interface` cleanups)
 - #117383 (improve and fix `x install`)
 - #117390 (Fix unused variables lint issue for args in macro)
 - #117395 (Fix missing leading space in suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-10-30 18:47:55 +00:00
Oli Scherer
455cf5a4f6 Improve some diagnostics around ?Trait bounds 2023-10-30 17:47:07 +00:00
bors
cdc4d56ae7 Auto merge of #11701 - Alexendoo:vec-init-then-push-docs, r=Jarcho
Use multiple pushes in `vec_init_then_push` example

Makes the perf argument clearer, since a single push doesn't have unnecessary allocations compared to `vec![x]`

changelog: none
2023-10-30 17:25:55 +00:00
bors
325e9fd339 Auto merge of #11723 - Alexendoo:clippy-utils-internal, r=Jarcho
Remove internal feature from clippy_utils

It's only used to gate a few `const`s, removing the feature gate means it doesn't have to be recompiled when moving between a normal and `-F internal` build/test/etc

changelog: none
2023-10-30 17:11:53 +00:00
Esteban Küber
162443b32e Detect when trait is implemented for type and suggest importing it
Fix #57457.
2023-10-30 17:00:44 +00:00
Guillaume Gomez
9e4ab9f111
Rollup merge of #117395 - gurry:117380-wrong-parent-sugg, r=Nilstrieb
Fix missing leading space in suggestion

For a local pattern with no space between `let` and `(` e.g.:
```rust
  let(_a) = 3;
```
we were previously suggesting this illegal code:
```rust
  let_a = 3;
```
After this change the suggestion will instead be:
```rust
  let _a = 3;
```
Fixes #117380
2023-10-30 17:33:19 +01:00
Guillaume Gomez
02d32d2bc2
Rollup merge of #117390 - chenyukang:yukang-fix-117284-unused-macro, r=estebank
Fix unused variables lint issue for args in macro

Fixes #117284
r? ````@estebank````
2023-10-30 17:33:18 +01:00
Guillaume Gomez
c994bdb8d7
Rollup merge of #117383 - onur-ozkan:fix-x-install, r=albertlarsan68
improve and fix `x install`

Fix: Write access check of `prefix` and `sysconfdir` when DESTDIR is present.

Improvement: Instead of repeatedly reading `DESTDIR` within each `fn prepare_dir` usage, read it once and pass it to the `fn prepare_dir`.

Fixes #117203
2023-10-30 17:33:18 +01:00
Guillaume Gomez
d96bdbe218
Rollup merge of #117376 - nnethercote:rustc_interface-more, r=oli-obk
More `rustc_interface` cleanups

In particular, following up #117268 with more improvement to `--cfg`/`--check-cfg` handling.

r? ``@oli-obk``
2023-10-30 17:33:18 +01:00
Guillaume Gomez
784f04b367
Rollup merge of #117370 - nicholasbishop:bishop-better-c-variadic-errors, r=oli-obk
C-variadic error improvements

A couple improvements for c-variadic errors:

1. Fix the bad-c-variadic error being emitted multiple times. If a function incorrectly contains multiple `...` args, and is also not foreign or `unsafe extern "C"`, only emit the latter error once rather than once per `...`.

2. Explicitly reject `const` C-variadic functions. Trying to use C-variadics in a const function would previously fail with an error like "destructor of `VaListImpl<'_>` cannot be evaluated at compile-time". Add an explicit check for const C-variadics to provide a clearer error: "functions cannot be both `const` and C-variadic". This also addresses one of the concerns in https://github.com/rust-lang/rust/issues/44930: "Ensure that even when this gets stabilized for regular functions, it is still rejected on const fn."
2023-10-30 17:33:17 +01:00
Guillaume Gomez
5ac999f133
Rollup merge of #117357 - tmiasko:terminate, r=wesleywiser
Rename a few remaining references to abort terminator

Follow up to e3f2edc75b
2023-10-30 17:33:17 +01:00
Guillaume Gomez
99b032f9ff
Rollup merge of #117356 - he32:netbsd-mipsel, r=oli-obk
Add support for mipsel-unknown-netbsd, 32-bit LE mips.
2023-10-30 17:33:16 +01:00
Guillaume Gomez
73100d8e93
Rollup merge of #117317 - RalfJung:track-caller, r=oli-obk
share some track_caller logic between interpret and codegen

Also move the code that implements the track_caller intrinsics out of the core interpreter engine -- it's just a helper creating a const-allocation, doesn't need to be part of the interpreter core.
2023-10-30 17:33:16 +01:00
Guillaume Gomez
95de91b5ce
Rollup merge of #117132 - estebank:issue-80194, r=petrochenkov
On object safety error, mention new enum as alternative

When we encounter a `dyn Trait` that isn't object safe, look for its implementors. If there's one, mention using it directly If there are less than 9, mention the possibility of creating a new enum and using that instead.

Fix #80194.
2023-10-30 17:33:15 +01:00
Guillaume Gomez
824e3677c2
Rollup merge of #117068 - nnethercote:clean-up-Cargo-toml, r=wesleywiser
Clean up `compiler/rustc*/Cargo.toml`

Mostly by sorting dependencies, plus some other minor things.

r? ``@wesleywiser``
2023-10-30 17:33:15 +01:00
Guillaume Gomez
b9dce53d4a
Rollup merge of #112463 - fmease:rustdoc-elide-x-crate-def-gen-args, r=GuillaumeGomez
rustdoc: elide cross-crate default generic arguments

Elide cross-crate generic arguments if they coincide with their default.
TL;DR: Most notably, no more `Box<…, Global>` in `std`'s docs, just `Box<…>` from now on.
Fixes #80379.

Also helps with #44306. Follow-up to #103885, #107637.

r? ``@ghost``
2023-10-30 17:33:14 +01:00
Oli Scherer
224ddf8fd9 Only run panic tests on targets that can unwind 2023-10-30 16:32:53 +00:00
Oli Scherer
ff3a818554 Poison check_well_formed if method receivers are invalid to prevent typeck from running on it 2023-10-30 16:11:52 +00:00
David Tolnay
1e10fe9eb6
Move deprecation_in_effect to inherent method on Deprecation 2023-10-30 09:02:32 -07:00
León Orell Valerian Liehr
58a80c85b9
rustdoc: elide cross-crate default generic arguments 2023-10-30 16:44:52 +01:00
bors
e6e931dda5 Auto merge of #117267 - RalfJung:miri-tests, r=Mark-Simulacrum
update which targets we test Miri on

I hope this doesn't cost too much time; running only the "pass" tests should be reasonably fast (1-2 minutes on my system).

Fixes https://github.com/rust-lang/rust/issues/117167
2023-10-30 15:38:24 +00:00