467 Commits

Author SHA1 Message Date
cijiugechu b90687377c Add constness & asyncness 2026-04-22 10:22:14 +08:00
Jana Dönszelmann 778d27441d also check let-else 2026-04-14 11:05:19 +02:00
Jana Dönszelmann 18d118a7b7 fixup rustdoc,clippy,rustfmt 2026-04-10 15:10:04 +02:00
Jana Dönszelmann d5d0153254 make all typing-mode conditional code an exhaustive match 2026-04-10 15:01:37 +02:00
Jana Dönszelmann 2facd34bc8 add #[rustc_must_match_exhaustively] 2026-04-10 11:43:27 +02:00
Jonathan Brouwer 65f1783a5f Rollup merge of #152669 - makai410:rpub-vtable, r=celinval
rustc_public: add `vtable_entries()` to `TraitRef`

Resolves: https://github.com/rust-lang/project-stable-mir/issues/103
2026-03-20 13:24:22 +01:00
Makai 042875bb84 rustc_public: add vtable_entries() to TraitRef 2026-03-16 23:25:36 +08:00
bjorn3 2199d07e2b Move env/file_depinfo from ParseSess to Session 2026-03-12 15:35:27 +00:00
Jonathan Brouwer 3679ba7fb0 Rollup merge of #153674 - estebank:issue-41906, r=petrochenkov
Detect inherent method behind deref being shadowed by trait method

```
error[E0277]: the trait bound `Rc<RefCell<S>>: Borrow<S>` is not satisfied
  --> $DIR/shadowed-intrinsic-method-deref.rs:16:22
   |
LL |     let sb : &S = &s.borrow();
   |                      ^^^^^^ the trait `Borrow<S>` is not implemented for `Rc<RefCell<S>>`
   |
help: the trait `Borrow<S>` is not implemented for `Rc<RefCell<S>>`
      but trait `Borrow<RefCell<S>>` is implemented for it
  --> $SRC_DIR/alloc/src/rc.rs:LL:COL
   = help: for that trait implementation, expected `RefCell<S>`, found `S`
   = note: there's an inherent method on `RefCell<S>` of the same name, which can be auto-dereferenced from `&RefCell<T>`
help: to access the inherent method on `RefCell<S>`, use the fully-qualified path
   |
LL -     let sb : &S = &s.borrow();
LL +     let sb : &S = &RefCell::borrow(&s);
   |
```

In the example above, method `borrow` is available both on `<RefCell<S> as Borrow<S>>` *and* on `RefCell<S>`. Adding the import `use std::borrow::Borrow;` causes `s.borrow()` to find the former instead of the latter. We now point out that the other exists, and provide a suggestion on how to call it.

Fix rust-lang/rust#41906. CC rust-lang/rust#153662.
2026-03-11 10:58:52 +01:00
Esteban Küber 73fe905f3c Detect inherent method behind deref being shadowed by trait method
```
error[E0277]: the trait bound `Rc<RefCell<S>>: Borrow<S>` is not satisfied
  --> $DIR/shadowed-intrinsic-method-deref.rs:16:22
   |
LL |     let sb : &S = &s.borrow();
   |                      ^^^^^^ the trait `Borrow<S>` is not implemented for `Rc<RefCell<S>>`
   |
help: the trait `Borrow<S>` is not implemented for `Rc<RefCell<S>>`
      but trait `Borrow<RefCell<S>>` is implemented for it
  --> $SRC_DIR/alloc/src/rc.rs:LL:COL
   = help: for that trait implementation, expected `RefCell<S>`, found `S`
   = note: there's an inherent method on `RefCell<S>` of the same name, which can be auto-dereferenced from `&RefCell<T>`
help: to access the inherent method on `RefCell<S>`, use the fully-qualified path
   |
LL -     let sb : &S = &s.borrow();
LL +     let sb : &S = &RefCell::borrow(&s);
   |
```

In the example above, method `borrow` is available both on `<RefCell<S> as Borrow<S>>` *and* on `RefCell<S>`. Adding the import `use std::borrow::Borrow;` causes `s.borrow()` to find the former instead of the latter. We now point out that the other exists, and provide a suggestion on how to call it.
2026-03-10 23:24:27 +00:00
Nicholas Nethercote c12ab08c14 Move Spanned.
It's defined in `rustc_span::source_map` which doesn't make any sense
because it has nothing to do with source maps. This commit moves it to
the crate root, a more sensible spot for something this basic.
2026-03-11 06:25:23 +11:00
Jonathan Brouwer 7baf2be12a Fix uitests 2026-03-07 01:23:58 +01:00
Jonathan Brouwer 1500680ba5 Rollup merge of #153401 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Migrationg of `LintDiagnostic` - part 7

Part of https://github.com/rust-lang/rust/issues/153099.

This PR removes the `LintDiagnostic` trait and proc-macro. \o/

r? @JonathanBrouwer
2026-03-04 19:30:40 +01:00
Jonathan Brouwer 1c44dbd580 Rollup merge of #152164 - mu001999-contrib:lint/unused_features, r=JonathanBrouwer
Lint unused features

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152164)*

Fixes rust-lang/rust#44232
Fixes rust-lang/rust#151752

---

This PR records used features through query side effect, then reports unsued features finally.
2026-03-04 19:30:36 +01:00
Guillaume Gomez 7ceb8ea1b0 Remove unused LintDiagnostic trait 2026-03-04 15:16:51 +01:00
mu001999 0436634084 Remove unused features in tests 2026-03-04 08:06:45 +08:00
bjorn3 5aa980e6dc Replace CodegenResults with CompiledModules
This is already CodegenResults without CrateInfo. The driver can
calculate the CrateInfo and pass it by-ref to the backend. Using
CompiledModules makes it a bit easier to move some other things out of
the backend as will be necessary for moving LTO to the link phase.
2026-03-02 16:39:41 +00:00
bjorn3 a192c617ec Use CompiledModules inside CodegenResults
In preparation for fully replacing CodegenResults with CompiledModules.
2026-03-02 16:39:13 +00:00
bors 38c0de8dcb Auto merge of #153050 - JayanAXHF:refactor/change-is-type-const, r=BoxyUwU
refactor(mgca): Change `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag



Addresses rust-lang/rust#152940 

- Changed `DefKind::Const` and `DefKind::AssocConst` to have a `is_type_const` flag.
- changed `is_type_const` query to check for this flag
- removed `is_rhs_type_const` query

r? @BoxyUwU
2026-02-28 18:27:06 +00:00
JayanAXHF efc150e5b3 refactor(mgca): Change DefKind::Const and DefKind::AssocConst to have a is_type_const flag
* refactor: add `is_type_const` flag to `DefKind::Const` and `AssocConst`
* refactor(cleanup) remove the `rhs_is_type_const` query
* style: fix formatting
* refactor: refactor stuff in librustdoc for new Const and AssocConst
* refactor: refactor clippy for the changes
* chore: formatting
* fix: fix test
* fix: fix suggestions
* Update context.rs

Co-authored-by: Boxy <rust@boxyuwu.dev>
* changed AssocKind::Const to store data about being a type const
2026-02-28 17:27:46 +00:00
Jacob Pratt f8f444757d Rollup merge of #153029 - nnethercote:disallowed-pass-by-ref, r=Urgau
Rename `rustc::pass_by_value` lint as `rustc::disallowed_pass_by_ref`.

The name `pass_by_value` is completely wrong. The lint actually checks for the use of pass by reference for types marked with `rustc_pass_by_value`.

The hardest part of this was choosing the new name. The `disallowed_` part of the name closely matches the following clippy lints:
- `disallowed_macros`
- `disallowed_methods`
- `disallowed_names`
- `disallowed_script_idents`
- `disallowed_types`

The `pass_by_value` part of the name aligns with the following clippy lints:
- `needless_pass_by_value`
- `needless_pass_by_ref_mut`
- `trivially_copy_pass_by_ref`
- `large_types_passed_by_value` (less so)

r? @Urgau
2026-02-25 21:42:57 -05:00
Nicholas Nethercote 8eed8bd7bb Rename pass_by_value lint as disallowed_pass_by_ref.
The name `pass_by_value` is completely wrong. The lint actually checks
for the use of pass by reference for types marked with
`rustc_pass_by_value`.

The hardest part of this was choosing the new name. The `disallowed_`
part of the name closely matches the following clippy lints:
- `disallowed_macros`
- `disallowed_methods`
- `disallowed_names`
- `disallowed_script_idents`
- `disallowed_types`

The `pass_by_value` part of the name aligns with the following clippy
lints:
- `needless_pass_by_value`
- `needless_pass_by_ref_mut`
- `trivially_copy_pass_by_ref`
- `large_types_passed_by_value` (less so)
2026-02-25 15:10:14 +11:00
Nicholas Nethercote 8971ad85af Fix attribute parser and kind names.
For the attribute `FooBar` the parser is generally called `FooBarParser`
and the kind is called `AttributeKind::FooBar`. This commit renames some
cases that don't match that pattern. The most common cases:
- Adding `Rustc` to the front of the parser name for a `rustc_*`
  attribute.
- Adding `Parser` to the end of a parser name.
- Slight word variations, e.g. `Deprecation` instead of `Deprecated`,
  `Pointer` instead of `Ptr`, `Stability` instead of `Stable`.
2026-02-25 08:46:47 +11:00
Jana Dönszelmann 8e7bc3c7d1 fix src/tools 2026-02-20 10:35:52 +01:00
Jana Dönszelmann be4f92fc45 emit unreachable pattern lint 2026-02-20 09:50:16 +01:00
Jana Dönszelmann 2bed584742 add lint for using AttributeKind in find_attr 2026-02-20 09:50:16 +01:00
Jonathan Brouwer 1489a8e3d7 Rollup merge of #152628 - Enselic:ptr-const-allocation, r=jieyouxu
tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)

In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there is a check for constant allocations of local variables of this function:

    fn other_consts() {{
        let _max_u128 = u128::MAX;
        let _min_i128 = i128::MIN;
        let _max_i8 = i8::MAX;
        let _char = 'x';
        let _false = false;
        let _true = true;
        let _ptr = &BAR;
        let _null_ptr: *const u8 = NULL;
        let _tuple = TUPLE;
        let _char_id = const {{ type_id::<char>() }};
        let _bool_id = const {{ type_id::<bool>() }};
    }}

The current test only finds 10 out of 11 allocations. The constant allocation for

    let _ptr = &BAR;

is not checked, because the `SingleUseConsts` MIR pass does not optimize away that assignment. Add code to also collect constant allocation from assignment rvalues to find the constant allocation for that last variable.

Not only does this change make sense on its own, it also makes the test pass both with and without the `SingleUseConsts` pass.

Discovered while investigating ways to avoid [this tests/ui-fulldeps/rustc_public/check_allocation.rs](https://github.com/Enselic/rust/commit/d7fffabc31904434cd41304c2f419f8b4abc6e70#diff-c4a926f9e8ba22bcfb1e6f2491b79b80608ab018641f85f66d6718d7f3716a5e) hack from https://github.com/rust-lang/rust/pull/151426 which wants to stop running `SingleUseConsts` for non-optimized builds.
2026-02-18 22:19:49 +01:00
Esteban Küber c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00
Nicholas Nethercote e9288e7e90 Remove last remnants of rustc_query_system.
At this point module `ich` is the only thing left.
2026-02-16 22:56:47 +11:00
Martin Nordholts 1e367f9663 tests: rustc_public: Check const allocation for all variables (1 of 11 was missing)
In the test `tests/ui-fulldeps/rustc_public/check_allocation.rs` there
is a check for constant allocations of local variables of this function:

    fn other_consts() {{
        let _max_u128 = u128::MAX;
        let _min_i128 = i128::MIN;
        let _max_i8 = i8::MAX;
        let _char = 'x';
        let _false = false;
        let _true = true;
        let _ptr = &BAR;
        let _null_ptr: *const u8 = NULL;
        let _tuple = TUPLE;
        let _char_id = const {{ type_id::<char>() }};
        let _bool_id = const {{ type_id::<bool>() }};
    }}

The current test only finds 10 out of 11 allocations. The constant
allocation for

    let _ptr = &BAR;

is not checked, because the `SingleUseConsts` MIR pass does not optimize
away that assignment. Add code to also collect constant allocation from
assignment rvalues. Not only does this change make sense on its own, it
also makes the test pass both with and without the `SingleUseConsts`
pass.
2026-02-14 19:51:56 +01:00
Lukas Bergdoll 2f3b952349 Stabilize assert_matches 2026-02-11 14:13:44 +01:00
Jonathan Brouwer ea361287be Remove SubdiagMessage in favour of the identical DiagMessage 2026-02-10 09:13:45 +00:00
Jonathan Brouwer 0db0acd699 Remove the fallback bundle 2026-02-08 11:06:42 +01:00
Jonathan Brouwer 2289e6cfb7 Adjust expected uitests results for the updated derive(Diagnostic) macro 2026-02-08 11:06:42 +01:00
Jonathan Brouwer 580c8d3c20 Update remaining session-diagnostics tests 2026-02-07 19:34:21 +01:00
Jonathan Brouwer 3837431516 Remove ui-fulldeps tests for slugs 2026-02-07 19:34:21 +01:00
Jonathan Brouwer 9a114c686f Convert to inline diagnostics in rustc_parse 2026-02-07 10:30:40 +01:00
Jonathan Brouwer d96d73fd86 Rollup merge of #152140 - bjorn3:driver_fixed_error_codes, r=jdonszelmann
Hard code the error code registry for custom drivers

And do some cleanups enabled by this.
2026-02-06 10:06:45 +01:00
Jonathan Brouwer c0b4db118b Rollup merge of #150379 - ChrisDenton:exitcode, r=jieyouxu
Return `ExitCode` from `rustc_driver::main` instead of calling `process::exit`

This makes rustc simply return an exit code from main rather than calling `std::process::exit` with an exit code. This means that drops run normally and the process exits cleanly. This is similar to what happens when an ICE occurs (due to being a panic that's caught by std's `lang_start`).

Also instead of hard coding success and failure codes this uses `ExitCode::SUCCESS` and `ExitCode::FAILURE`, which in turn effectively uses `libc::EXIT_SUCCESS` and `libc::EXIT_FAILURE` (via std). These are `0` and `1` respectively for all currently supported host platforms so it doesn't actually change the exit code.
2026-02-05 08:32:43 +01:00
bjorn3 1851937577 Hard code the error code registry for custom drivers 2026-02-04 21:21:15 +00:00
Jonathan Brouwer cf0e19b0b4 Rollup merge of #152102 - bjorn3:inline_fluent_codegen_backends, r=JonathanBrouwer,GuillaumeGomez
Convert to inline diagnostics in all codegen backends

Part of https://github.com/rust-lang/rust/issues/151366

r? @JonathanBrouwer
2026-02-04 14:39:29 +01:00
bjorn3 d2a0557afb Convert to inline diagnostics in all codegen backends 2026-02-04 13:12:49 +00:00
John Kåre Alsaker 247a022957 Fix references and remove inner queries module 2026-02-03 21:32:52 +01:00
Jonathan Brouwer ca2be71a18 Add verification for inline fluent messages 2026-02-01 11:12:10 +01:00
Jonathan Brouwer 523d9d9200 Uitests for subdiagnostics 2026-02-01 11:12:04 +01:00
Jonathan Brouwer 378c6fc6fe Uitests for #[diagnostic] 2026-02-01 11:12:03 +01:00
Jonathan Brouwer 0bf3f5d51c Remove unused no_span option 2026-01-28 22:23:23 +01:00
Jonathan Brouwer 5d21a21695 Convert parse_nested_meta to parse_args_with for #[subdiagnostic] 2026-01-28 22:18:44 +01:00
Jonathan Brouwer 9e61014a8a Convert parse_nested_meta to parse_args_with for #[diagnostic] 2026-01-28 22:18:37 +01:00
Jonathan Brouwer 4a0c044c63 Update stderrs 2026-01-27 17:11:47 +01:00