Commit Graph

248905 Commits

Author SHA1 Message Date
Guillaume Gomez
b0d7f2bb0e
Rollup merge of #119888 - weiznich:stablize_diagnostic_namespace, r=compiler-errors
Stabilize the `#[diagnostic]` namespace and `#[diagnostic::on_unimplemented]` attribute

This PR stabilizes the `#[diagnostic]` attribute namespace and a minimal option of the `#[diagnostic::on_unimplemented]` attribute.

The `#[diagnostic]` attribute namespace is meant to provide a home for attributes that allow users to influence error messages emitted by the compiler. The compiler is not guaranteed to use any of this hints, however it should accept any (non-)existing attribute in this namespace and potentially emit lint-warnings for unused attributes and options. This is meant to allow discarding certain attributes/options in the future to allow fundamental changes to the compiler without the need to keep then non-meaningful options working.

The `#[diagnostic::on_unimplemented]` attribute is allowed to appear on a trait definition. This allows crate authors to hint the compiler to emit a specific error message if a certain trait is not implemented. For the `#[diagnostic::on_unimplemented]` attribute the following options are implemented:

* `message` which provides the text for the top level error message
* `label` which provides the text for the label shown inline in the broken code in the error message
* `note` which provides additional notes.

The `note` option can appear several times, which results in several note messages being emitted. If any of the other options appears several times the first occurrence of the relevant option specifies the actually used value. Any other occurrence generates an lint warning. For any other non-existing option a lint-warning is generated.

All three options accept a text as argument. This text is allowed to contain format parameters referring to generic argument or `Self` by name via the `{Self}` or `{NameOfGenericArgument}` syntax. For any non-existing argument a lint warning is generated.

This allows to have a trait definition like:

```rust
#[diagnostic::on_unimplemented(
    message = "My Message for `ImportantTrait<{A}>` is not implemented for `{Self}`",
    label = "My Label",
    note = "Note 1",
    note = "Note 2"
)]
trait ImportantTrait<A> {}

```

which then generates for the following code

```rust
fn use_my_trait(_: impl ImportantTrait<i32>) {}

fn main() {
    use_my_trait(String::new());
}
```

this error message:

```
error[E0277]: My Message for `ImportantTrait<i32>` is not implemented for `String`
  --> src/main.rs:14:18
   |
14 |     use_my_trait(String::new());
   |     ------------ ^^^^^^^^^^^^^ My Label
   |     |
   |     required by a bound introduced by this call
   |
   = help: the trait `ImportantTrait<i32>` is not implemented for `String`
   = note: Note 1
   = note: Note 2
```

[Playground with the unstable feature](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=05133acce8e1d163d481e97631f17536)

Fixes #111996
2024-03-07 18:32:46 +01:00
bors
735f7589e3 Auto merge of #122149 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2024-03-07 17:31:44 +00:00
Philipp Krones
73f7e79a3b
Merge commit '93f0a9a91f58c9b2153868f458402155fb6265bb' into clippy-subtree-update 2024-03-07 17:19:29 +01:00
bors
93f0a9a91f Auto merge of #12431 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2024-03-07 16:16:36 +00:00
Philipp Krones
1d65642a1f
Bump nightly version -> 2024-03-07 2024-03-07 17:14:39 +01:00
Philipp Krones
a6df0277ea
Merge remote-tracking branch 'upstream/master' into rustup 2024-03-07 17:14:36 +01:00
Augie Fackler
ef626d772f PassWrapper: update for llvm/llvm-project@a331937197
@rustbot label: +llvm-main
2024-03-07 10:24:48 -05:00
Kalle Wachsmuth
5ce3db2248
make std::os::unix::ucred module private 2024-03-07 16:23:35 +01:00
bors
1c580bcb70 Auto merge of #122139 - GuillaumeGomez:rollup-37vtwsc, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #121863 (silence mismatched types errors for implied projections)
 - #122043 (Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`)
 - #122066 (Add proper cfgs for struct HirIdValidator used only with debug-assert)
 - #122104 (Rust is a proper name: rust → Rust)
 - #122110 (Make `x t miri` respect `MIRI_TEMP`)
 - #122114 (Make not finding core a fatal error)
 - #122115 (Cancel parsing ever made during recovery)
 - #122123 (Don't require specifying unrelated assoc types when trait alias is in `dyn` type)
 - #122126 (Fix `tidy --bless` on  ̶X̶e̶n̶i̶x̶ Windows)
 - #122129 (Set `RustcDocs` to only run on host)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-07 15:02:36 +00:00
DianQK
3d7f8b4e5b
Get all variants to eliminate the default branching if we cannot get the layout of type 2024-03-07 22:58:51 +08:00
DianQK
08ae8380ce
Replace the default branch with an unreachable branch If it is the last variant 2024-03-07 22:58:51 +08:00
DianQK
d8b7b5be7d
Regenerate uninhabited_enum_branching.rs 2024-03-07 22:58:51 +08:00
lcnr
f9405ed4d8 cleanup imports 2024-03-07 15:41:24 +01:00
lcnr
2339317cfb move snapshot handling into mod 2024-03-07 15:39:30 +01:00
klensy
cd549aeffd sync (try_)instantiate_mir_and_normalize_erasing_regions implementation
try_instantiate_mir_and_normalize_erasing_regions was changed in dbc2cc8717, but not instantiate_mir_and_normalize_erasing_regions
2024-03-07 17:33:08 +03:00
Oli Scherer
ae50e36dfa Merge collect_mod_item_types query into check_well_formed 2024-03-07 14:26:31 +00:00
lcnr
de3c965b76 move mod into folder 2024-03-07 15:23:36 +01:00
lcnr
6ebeb1c36b remove empty folder 2024-03-07 15:18:25 +01:00
Guillaume Gomez
ce9a6adba9
Rollup merge of #122129 - tgross35:rustcdocs-host-only, r=onur-ozkan
Set `RustcDocs` to only run on host

`./x dist` currently crashes when cross compiling. Add the fix described by `@catamorphism` in https://github.com/rust-lang/rust/issues/110071.

Fixes #110071
2024-03-07 15:07:10 +01:00
Guillaume Gomez
d03d9a4e9b
Rollup merge of #122126 - workingjubilee:every-os-in-the-world-belongs-to-unix, r=ChrisDenton
Fix `tidy --bless` on  ̶X̶e̶n̶i̶x̶ Windows

As reported in https://github.com/rust-lang/rust/pull/120628#issuecomment-1973655740 the requested `tidy --bless` implementation didn't take into account the fact that earlier the linting code canonicalized things to use the OS path separator. This makes it so that the path separator is always rewritten back as '/', which should fix the variance there.

r? ``@ChrisDenton``
2024-03-07 15:07:09 +01:00
Guillaume Gomez
bb582c6d0f
Rollup merge of #122123 - compiler-errors:object-trait-alias-bounds, r=oli-obk
Don't require specifying unrelated assoc types when trait alias is in `dyn` type

Object types must specify the associated types for all of the principal trait ref's supertraits. However, we weren't doing elaboration properly, so we incorrectly errored with erroneous suggestions to specify associated types that were unrelated to that principal trait ref. To fix this, use proper supertrait elaboration when expanding trait aliases in `conv_object_ty_poly_trait_ref`.

**NOTE**: Please use the ignore-whitespace option when reviewing. This only touches a handful of lines.

r? oli-obk or please feel free to reassign.

Fixes #122118
2024-03-07 15:07:09 +01:00
Guillaume Gomez
9bda4e47c7
Rollup merge of #122115 - clubby789:cancel-recoverr, r=compiler-errors
Cancel parsing ever made during recovery

Fixes #122112

It would be nice if diagnostics from recovery were automatically cancelled... 🤔
2024-03-07 15:07:08 +01:00
Guillaume Gomez
66a062af86
Rollup merge of #122114 - saethlin:cant-find-crate-spam, r=WaffleLapkin
Make not finding core a fatal error

Similar to https://github.com/rust-lang/rust/pull/120472, this prevents terminal spam. In particular, it makes the good diagnostic visible when you try to use a target that's not installed.
2024-03-07 15:07:08 +01:00
Guillaume Gomez
d7106d27ab
Rollup merge of #122110 - WaffleLapkin:miri-temp, r=RalfJung
Make `x t miri` respect `MIRI_TEMP`

(I don't want to override `TMPDIR`, as that might affect other things)

r? ``@RalfJung``
2024-03-07 15:07:07 +01:00
Guillaume Gomez
6b045184a8
Rollup merge of #122104 - RalfJung:rust, r=ChrisDenton
Rust is a proper name: rust → Rust

I only went over the library where it might be user-visible -- I noticed this in the `time` docs.
2024-03-07 15:07:07 +01:00
Guillaume Gomez
f1fb720734
Rollup merge of #122066 - mu001999:clean, r=oli-obk
Add proper cfgs for struct HirIdValidator used only with debug-assert

See https://github.com/rust-lang/rust/pull/122065#issuecomment-1980118572.
I think it's due to #121752.
2024-03-07 15:07:06 +01:00
Guillaume Gomez
e52c5411bb
Rollup merge of #122043 - Y-Nak:move-early-binder, r=lcnr
Apply `EarlyBinder` only to `TraitRef` in `ImplTraitHeader`

Resolves #121852

This PR
1. Moves `EarlyBinder` to `TraitRef` inside `ImplTraitHeader`,
2. Changes visibility of `coherence::builtin::check_trait` to `pub(super)` from `pub` as it seems not being re-exported from the `coherence` module.
2024-03-07 15:07:06 +01:00
Guillaume Gomez
0e3764889d
Rollup merge of #121863 - lukas-code:silence-mismatched-super-projections, r=lcnr
silence mismatched types errors for implied projections

Currently, if a trait bound is not satisfied, then we suppress any errors for the trait's supertraits not being satisfied, but still report errors for super projections not being satisfied.

For example:
```rust
trait Super {
    type Assoc;
}
trait Sub: Super<Assoc = ()> {}
```
Before this PR, if `T: Sub` is not satisfied, then errors for `T: Super` are suppressed, but errors for `<T as Super>::Assoc == ()` are still shown. This PR makes it so that errors about super projections not being satisfied are also suppressed.

The errors are only suppressed if the span of the trait obligation matches the span of the super predicate obligation to avoid silencing error that are not related. This PR removes some differences between the spans of supertraits and super projections to make the suppression work correctly.

This PR fixes the majority of the diagnostics fallout when making `Thin` a supertrait of `Sized` (in a future PR).
cc https://github.com/rust-lang/rust/pull/120354#issuecomment-1930585382
cc `@lcnr`
2024-03-07 15:07:05 +01:00
bors
ba80e06537 Auto merge of #12429 - Alexendoo:redundant-field-names-macro-ctxt, r=Manishearth
Don't lint `redundant_field_names` across macro boundaries

Fixes #12426

The `field.span.eq_ctxt(field.ident.span)` addition is the relevant line for the bugfix

The current implementation checks that the field's name and the path are in the same context by comparing the idents, but not that the two are in the same context as the entire field itself, so in local macros `SomeStruct { $ident: $ident }` would get linted

changelog: none
2024-03-07 13:56:36 +00:00
Oli Scherer
42ab88d747 Remove redundant query invocations in rustdoc 2024-03-07 13:37:06 +00:00
Oli Scherer
ebf1b92417 Use the same collection order as check_mod_type_wf 2024-03-07 13:37:06 +00:00
Yoshitomo Nakanishi
9669934798 Apply EarlyBinder only to TraitRef in ImplTraitHeader 2024-03-07 13:56:29 +01:00
Rémy Rakic
1c3fe15f6c record mtime in llvm linker script
This will avoid rebuilds due to the script being more recent than the
rest of the original files.
2024-03-07 12:56:17 +00:00
Rémy Rakic
b91ceb88de use file to write llvm linker script 2024-03-07 12:56:13 +00:00
Oli Scherer
de3fb8d429 Collect mod item types in parallel, just like wfcheck 2024-03-07 12:42:49 +00:00
bors
52f8aec14c Auto merge of #121985 - RalfJung:interpret-return-place, r=oli-obk
interpret: avoid a long-lived PlaceTy in stack frames

`PlaceTy` uses a representation that's not very stable under changes to the stack. I'd feel better if we didn't have one in the long-term machine state.

r? `@oli-obk`
2024-03-07 12:33:19 +00:00
Alex Macleod
ac643a278b Don't lint redundant_field_names across macro boundaries 2024-03-07 12:21:16 +00:00
Lukas Markeffsky
db48b93454 improve debug logging 2024-03-07 13:20:56 +01:00
Zalathar
570376c496 Don't pass a break scope to Builder::break_for_else
This method would previously take a target scope, and then verify that it
was equal to the scope on top of the if-then scope stack.

In practice, this means that callers have to go out of their way to pass around
redundant scope information that's already on the if-then stack.

So it's easier to just retrieve the correct scope directly from the if-then
stack, and simplify the other code that was passing it around.
2024-03-07 23:11:18 +11:00
Gary Guo
0ee0f290a6 Bless aarch64 asm test 2024-03-07 11:57:26 +00:00
Jakub Beránek
4a1f4ff474 Include all library files in artifact summary on CI 2024-03-07 12:19:13 +01:00
bors
8c9a75b323 Auto merge of #121154 - oli-obk:track_errors11, r=estebank
Merge `check_mod_impl_wf` and `check_mod_type_wf`

This still causes some funny diagnostics, but I'm not sure they can be fixed without a larger change, which I'd like to avoid here.

Reducing the number of times we iterate over the same items at this high level helps avoid parallel-compiler bottlenecks.
2024-03-07 10:18:00 +00:00
r0cky
71d35d8d0c remove the --generate-link-to-definition flags from bootstrap 2024-03-07 17:38:13 +08:00
Trevor Gross
9d9e78e942 Set RustcDocs to only run on host
`./x dist` currently crashes when cross compiling. Add the fix described
by @catamorphism in https://github.com/rust-lang/rust/issues/110071.

Fixes #110071
2024-03-07 02:50:06 -05:00
bors
51f483944d Auto merge of #121866 - Kobzol:opt-dist-find-llvm, r=Mark-Simulacrum
Modify opt-dist logic for finding LLVM artifacts

This is the `rustc` side of fixing https://github.com/rust-lang/rust/pull/121395#issuecomment-1973572885.
2024-03-07 07:31:34 +00:00
Urgau
98dbe9abac Use was_invoked_from_cargo method instead of hand-written one 2024-03-07 07:54:15 +01:00
Urgau
6c4eadd747 Add early-return when checking if a path is local 2024-03-07 07:54:15 +01:00
Urgau
20200f65ca Remove useless smallvec dependency in rustc_lint::non_local_def 2024-03-07 07:54:15 +01:00
Urgau
5c87ca2d1f Add some weird test cases to the non_local_definitions lint tests 2024-03-07 07:54:14 +01:00
Ralf Jung
1a2bc1102d Rust is a proper name: rust → Rust 2024-03-07 07:49:22 +01:00