From 223cbad696316d6def8b124b9a8701899d00ade2 Mon Sep 17 00:00:00 2001 From: cijiugechu Date: Fri, 24 Apr 2026 18:33:14 +0800 Subject: [PATCH 01/28] update compare modes --- src/doc/rustc-dev-guide/src/tests/compiletest.md | 7 ++++--- src/doc/rustc-dev-guide/src/tests/directives.md | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/compiletest.md b/src/doc/rustc-dev-guide/src/tests/compiletest.md index 4c534e9ae0eda..36dc71a3ac0cc 100644 --- a/src/doc/rustc-dev-guide/src/tests/compiletest.md +++ b/src/doc/rustc-dev-guide/src/tests/compiletest.md @@ -821,13 +821,14 @@ check for any problems that might arise. To run the tests in a different mode, you need to pass the `--compare-mode` CLI flag: ```bash -./x test tests/ui --compare-mode=chalk +./x test tests/ui --compare-mode=next-solver ``` The possible compare modes are: -- `polonius` — Runs with Polonius with `-Zpolonius`. -- `chalk` — Runs with Chalk with `-Zchalk`. +- `polonius` — Runs with Polonius with `-Zpolonius=next`. +- `next-solver` — Runs with the next trait solver with `-Znext-solver`. +- `next-solver-coherence` — Runs coherence with the next trait solver with `-Znext-solver=coherence`. - `split-dwarf` — Runs with unpacked split-DWARF with `-Csplit-debuginfo=unpacked`. - `split-dwarf-single` — Runs with packed split-DWARF with `-Csplit-debuginfo=packed`. diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md index d536d324cb2bf..8bb9685d8d465 100644 --- a/src/doc/rustc-dev-guide/src/tests/directives.md +++ b/src/doc/rustc-dev-guide/src/tests/directives.md @@ -148,7 +148,8 @@ Some examples of `X` in `ignore-X` or `only-X`: - When particular debuggers are being tested: `cdb`, `gdb`, `lldb` - When particular debugger versions are matched: `ignore-gdb-version` - When the [parallel frontend] is enabled: `ignore-parallel-frontend` -- Specific [compare modes]: `compare-mode-polonius`, `compare-mode-chalk`, +- Specific [compare modes]: `compare-mode-polonius`, + `compare-mode-next-solver`, `compare-mode-next-solver-coherence`, `compare-mode-split-dwarf`, `compare-mode-split-dwarf-single` - The two different test modes used by coverage tests: `ignore-coverage-map`, `ignore-coverage-run` From ab450e970e1a051a70985abc857cc06a0d6e4e60 Mon Sep 17 00:00:00 2001 From: "Kevin K." Date: Thu, 30 Apr 2026 14:56:26 +0200 Subject: [PATCH 02/28] Add CI testing instructions for offload --- src/doc/rustc-dev-guide/src/offload/installation.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/offload/installation.md b/src/doc/rustc-dev-guide/src/offload/installation.md index 00233d9b02f8f..4b67f31cd3c28 100644 --- a/src/doc/rustc-dev-guide/src/offload/installation.md +++ b/src/doc/rustc-dev-guide/src/offload/installation.md @@ -39,7 +39,15 @@ This gives you a working LLVM build. ## Testing -run +Run this test script for offload-specific tests: ```console ./x test --stage 1 tests/codegen-llvm/gpu_offload ``` + +For testing the CI locally, you may use the commands outlined in [Testing with Docker](https://rustc-dev-guide.rust-lang.org/tests/docker.html): +```console +cargo run --manifest-path src/ci/citool/Cargo.toml run-local dist-x86_64-linux +``` +This stores all compiler artifacts in the `obj` directory, however should you modify rustc-specific code, you may need to delete this directory as the Docker image will cache its state otherwise. + +Submodules should also be checked out at this point. From 5f46b81bf89e2e1dd9c5f520ac90744ee2ab5db6 Mon Sep 17 00:00:00 2001 From: Alyssa Haroldsen Date: Fri, 1 May 2026 18:00:46 -0700 Subject: [PATCH 03/28] Fix tip on unstable syntax gating rust-lang/rust@80d2bdb6 changed `sess` to `psess` in 2024. `gated_spans` appears to have always been plural. --- src/doc/rustc-dev-guide/src/implementing-new-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/src/implementing-new-features.md b/src/doc/rustc-dev-guide/src/implementing-new-features.md index b288cb4d9ff91..e5a6d03f43fdd 100644 --- a/src/doc/rustc-dev-guide/src/implementing-new-features.md +++ b/src/doc/rustc-dev-guide/src/implementing-new-features.md @@ -197,7 +197,7 @@ The below steps needs to be followed in order to implement a new unstable featur For features introducing new syntax, pre-expansion gating should be used instead. During parsing, when the new syntax is parsed, the symbol must be inserted to the current crate's [`GatedSpans`] - via `self.sess.gated_span.gate(sym::my_feature, span)`. + via `self.psess.gated_spans.gate(sym::my_feature, span)`. After being inserted to the gated spans, the span must be checked in the [`rustc_ast_passes::feature_gate::check_crate`] function, From 6158d6e43745ced36dcf16f2c37082a028de3e56 Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 4 May 2026 05:17:27 +0000 Subject: [PATCH 04/28] Prepare for merging from rust-lang/rust This updates the rust-version file to 045b17737dab5fcc28e4cbee0cfe2ce4ed363b32. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index ea416dc27b52d..59e9e5a0e6ee9 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -f53b654a8882fd5fc036c4ca7a4ff41ce32497a6 +045b17737dab5fcc28e4cbee0cfe2ce4ed363b32 From a2c0e02be822b593506d19b0ae265fbb083e5d95 Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Wed, 6 May 2026 21:49:37 +0800 Subject: [PATCH 05/28] skip incorrect suggestion in nested imports --- compiler/rustc_resolve/src/diagnostics.rs | 5 +++++ ...private-import-nested-suggestion-156060.rs | 17 ++++++++++++++++ ...ate-import-nested-suggestion-156060.stderr | 20 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tests/ui/imports/private-import-nested-suggestion-156060.rs create mode 100644 tests/ui/imports/private-import-nested-suggestion-156060.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index c082455380ce7..5664933673a3a 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2483,6 +2483,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // `tests/ui/imports/issue-55884-2.rs` continue; } + // In nested imports `dedup_span` is just the inner ident, so a full path + // substitution would produce invalid code. See #156060. + if single_nested { + break; + } let path = join_path_idents(sugg); let sugg = if reexport { errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path } diff --git a/tests/ui/imports/private-import-nested-suggestion-156060.rs b/tests/ui/imports/private-import-nested-suggestion-156060.rs new file mode 100644 index 0000000000000..90a7b94aad555 --- /dev/null +++ b/tests/ui/imports/private-import-nested-suggestion-156060.rs @@ -0,0 +1,17 @@ +// Regression test for #156060. + +mod one { + pub struct One(); +} + +mod two { + use crate::one::One; + pub struct Two(); +} + +mod test { + use crate::two::{One, Two}; + //~^ ERROR struct import `One` is private [E0603] +} + +fn main() {} diff --git a/tests/ui/imports/private-import-nested-suggestion-156060.stderr b/tests/ui/imports/private-import-nested-suggestion-156060.stderr new file mode 100644 index 0000000000000..09d5391bd58df --- /dev/null +++ b/tests/ui/imports/private-import-nested-suggestion-156060.stderr @@ -0,0 +1,20 @@ +error[E0603]: struct import `One` is private + --> $DIR/private-import-nested-suggestion-156060.rs:13:22 + | +LL | use crate::two::{One, Two}; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-nested-suggestion-156060.rs:8:9 + | +LL | use crate::one::One; + | ^^^^^^^^^^^^^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-nested-suggestion-156060.rs:4:5 + | +LL | pub struct One(); + | ^^^^^^^^^^^^^^^^^ you could import this directly + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0603`. From 05b97f76a48d2550038144347decb0151d7c4709 Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Thu, 7 May 2026 23:41:19 +0800 Subject: [PATCH 06/28] address review comment --- compiler/rustc_resolve/src/diagnostics.rs | 11 +++----- ...ous-import-visibility-globglob-priv.stderr | 4 +-- ...port-suggestion-path-156244-edition2015.rs | 16 ++++++++++++ ...-suggestion-path-156244-edition2015.stderr | 25 +++++++++++++++++++ .../private-import-suggestion-path-156244.rs | 16 ++++++++++++ ...ivate-import-suggestion-path-156244.stderr | 25 +++++++++++++++++++ tests/ui/privacy/privacy2.stderr | 5 ++++ 7 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs create mode 100644 tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr create mode 100644 tests/ui/imports/private-import-suggestion-path-156244.rs create mode 100644 tests/ui/imports/private-import-suggestion-path-156244.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 5664933673a3a..acad0c6726d96 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2429,7 +2429,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { match binding.kind { DeclKind::Import { import, .. } => { - for segment in import.module_path.iter().skip(1) { + for segment in &import.module_path { // Don't include `{{root}}` in suggestions - it's an internal symbol // that should never be shown to users. if segment.ident.name != kw::PathRoot { @@ -2474,8 +2474,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } // We prioritize shorter paths, non-core imports and direct imports over the alternatives. sugg_paths.sort_by_key(|(p, reexport)| (p.len(), p[0].name == sym::core, *reexport)); + // In nested imports `dedup_span` is just the inner ident, so a full path + // substitution would produce invalid code. See #156060. for (sugg, reexport) in sugg_paths { - if not_publicly_reexported { + if not_publicly_reexported || single_nested { break; } if sugg.len() <= 1 { @@ -2483,11 +2485,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // `tests/ui/imports/issue-55884-2.rs` continue; } - // In nested imports `dedup_span` is just the inner ident, so a full path - // substitution would produce invalid code. See #156060. - if single_nested { - break; - } let path = join_path_idents(sugg); let sugg = if reexport { errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path } diff --git a/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr b/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr index 4485f5ac96481..07c0be3726ee8 100644 --- a/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr +++ b/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr @@ -17,7 +17,7 @@ LL | pub struct S {} help: import `S` through the re-export | LL - use crate::both::private::S; -LL + use m::S; +LL + use crate::m::S; | error[E0603]: struct import `S` is private @@ -39,7 +39,7 @@ LL | pub struct S {} help: import `S` through the re-export | LL - use crate::both::private::S; -LL + use m::S; +LL + use crate::m::S; | error: aborting due to 2 previous errors diff --git a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs new file mode 100644 index 0000000000000..b92a136745649 --- /dev/null +++ b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs @@ -0,0 +1,16 @@ +//@ edition: 2015 + +mod one { + pub struct One(); +} + +mod two { + use one::One; +} + +mod test { + use two::One; + //~^ ERROR struct import `One` is private [E0603] +} + +fn main() {} diff --git a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr new file mode 100644 index 0000000000000..4723ac835e303 --- /dev/null +++ b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr @@ -0,0 +1,25 @@ +error[E0603]: struct import `One` is private + --> $DIR/private-import-suggestion-path-156244-edition2015.rs:16:14 + | +LL | use two::One; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-suggestion-path-156244-edition2015.rs:12:9 + | +LL | use one::One; + | ^^^^^^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-suggestion-path-156244-edition2015.rs:8:5 + | +LL | pub struct One(); + | ^^^^^^^^^^^^^^^^^ you could import this directly +help: import `One` through the re-export + | +LL - use two::One; +LL + use one::One; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/imports/private-import-suggestion-path-156244.rs b/tests/ui/imports/private-import-suggestion-path-156244.rs new file mode 100644 index 0000000000000..266a3cb53bdd7 --- /dev/null +++ b/tests/ui/imports/private-import-suggestion-path-156244.rs @@ -0,0 +1,16 @@ +// PR #156244 comment + +mod one { + pub struct One(); +} + +mod two { + use crate::one::One; +} + +mod test { + use crate::two::One; + //~^ ERROR struct import `One` is private [E0603] +} + +fn main() {} diff --git a/tests/ui/imports/private-import-suggestion-path-156244.stderr b/tests/ui/imports/private-import-suggestion-path-156244.stderr new file mode 100644 index 0000000000000..f31d18460b666 --- /dev/null +++ b/tests/ui/imports/private-import-suggestion-path-156244.stderr @@ -0,0 +1,25 @@ +error[E0603]: struct import `One` is private + --> $DIR/private-import-suggestion-path-156244.rs:15:21 + | +LL | use crate::two::One; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-suggestion-path-156244.rs:11:9 + | +LL | use crate::one::One; + | ^^^^^^^^^^^^^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-suggestion-path-156244.rs:7:5 + | +LL | pub struct One(); + | ^^^^^^^^^^^^^^^^^ you could import this directly +help: import `One` through the re-export + | +LL - use crate::two::One; +LL + use crate::one::One; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index 3d36f26f784ab..5c720540db8e3 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -20,6 +20,11 @@ note: ...and refers to the function `foo` which is defined here | LL | pub fn foo() {} | ^^^^^^^^^^^^ you could import this directly +help: import `foo` through the re-export + | +LL - use bar::glob::foo; +LL + use crate::foo; + | error: requires `sized` lang_item --> $DIR/privacy2.rs:17:14 From dcaef5f6880b307597b33016dda5423691cbcdb3 Mon Sep 17 00:00:00 2001 From: danieljofficial Date: Thu, 7 May 2026 17:42:25 +0100 Subject: [PATCH 07/28] move consts ui tests into its folder --- .../issue-4387.rs => consts/arithmetic-expr-in-array-len.rs} | 0 .../assoc-const-with-self-in-trait-object.rs} | 0 .../bool-comparison-in-const-array-len.rs} | 0 .../issue-33287.rs => consts/const-array-oob-in-range-expr.rs} | 0 .../issue-53275.rs => consts/empty-array-index-in-struct-init.rs} | 0 .../local-var-in-associated-const.fixed} | 0 .../issue-44239.rs => consts/local-var-in-associated-const.rs} | 0 .../local-var-in-associated-const.stderr} | 0 .../issue-25757.rs => consts/method-reference-in-const-dyn-fn.rs} | 0 .../non-constant-value-in-nested-const.fixed} | 0 .../non-constant-value-in-nested-const.rs} | 0 .../non-constant-value-in-nested-const.stderr} | 0 .../issue-17252.rs => consts/recursive-const-stack-overflow.rs} | 0 .../recursive-const-stack-overflow.stderr} | 0 .../issue-30891.rs => consts/short-circuit-or-with-const-bool.rs} | 0 .../static-lifetime-inference-from-const-array.rs} | 0 .../static-ref-to-const-array-element.rs} | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-4387.rs => consts/arithmetic-expr-in-array-len.rs} (100%) rename tests/ui/{issues/issue-50518.rs => consts/assoc-const-with-self-in-trait-object.rs} (100%) rename tests/ui/{issues/issue-39548.rs => consts/bool-comparison-in-const-array-len.rs} (100%) rename tests/ui/{issues/issue-33287.rs => consts/const-array-oob-in-range-expr.rs} (100%) rename tests/ui/{issues/issue-53275.rs => consts/empty-array-index-in-struct-init.rs} (100%) rename tests/ui/{issues/issue-44239.fixed => consts/local-var-in-associated-const.fixed} (100%) rename tests/ui/{issues/issue-44239.rs => consts/local-var-in-associated-const.rs} (100%) rename tests/ui/{issues/issue-44239.stderr => consts/local-var-in-associated-const.stderr} (100%) rename tests/ui/{issues/issue-25757.rs => consts/method-reference-in-const-dyn-fn.rs} (100%) rename tests/ui/{issues/issue-27433.fixed => consts/non-constant-value-in-nested-const.fixed} (100%) rename tests/ui/{issues/issue-27433.rs => consts/non-constant-value-in-nested-const.rs} (100%) rename tests/ui/{issues/issue-27433.stderr => consts/non-constant-value-in-nested-const.stderr} (100%) rename tests/ui/{issues/issue-17252.rs => consts/recursive-const-stack-overflow.rs} (100%) rename tests/ui/{issues/issue-17252.stderr => consts/recursive-const-stack-overflow.stderr} (100%) rename tests/ui/{issues/issue-30891.rs => consts/short-circuit-or-with-const-bool.rs} (100%) rename tests/ui/{issues/issue-40951.rs => consts/static-lifetime-inference-from-const-array.rs} (100%) rename tests/ui/{issues/issue-49955.rs => consts/static-ref-to-const-array-element.rs} (100%) diff --git a/tests/ui/issues/issue-4387.rs b/tests/ui/consts/arithmetic-expr-in-array-len.rs similarity index 100% rename from tests/ui/issues/issue-4387.rs rename to tests/ui/consts/arithmetic-expr-in-array-len.rs diff --git a/tests/ui/issues/issue-50518.rs b/tests/ui/consts/assoc-const-with-self-in-trait-object.rs similarity index 100% rename from tests/ui/issues/issue-50518.rs rename to tests/ui/consts/assoc-const-with-self-in-trait-object.rs diff --git a/tests/ui/issues/issue-39548.rs b/tests/ui/consts/bool-comparison-in-const-array-len.rs similarity index 100% rename from tests/ui/issues/issue-39548.rs rename to tests/ui/consts/bool-comparison-in-const-array-len.rs diff --git a/tests/ui/issues/issue-33287.rs b/tests/ui/consts/const-array-oob-in-range-expr.rs similarity index 100% rename from tests/ui/issues/issue-33287.rs rename to tests/ui/consts/const-array-oob-in-range-expr.rs diff --git a/tests/ui/issues/issue-53275.rs b/tests/ui/consts/empty-array-index-in-struct-init.rs similarity index 100% rename from tests/ui/issues/issue-53275.rs rename to tests/ui/consts/empty-array-index-in-struct-init.rs diff --git a/tests/ui/issues/issue-44239.fixed b/tests/ui/consts/local-var-in-associated-const.fixed similarity index 100% rename from tests/ui/issues/issue-44239.fixed rename to tests/ui/consts/local-var-in-associated-const.fixed diff --git a/tests/ui/issues/issue-44239.rs b/tests/ui/consts/local-var-in-associated-const.rs similarity index 100% rename from tests/ui/issues/issue-44239.rs rename to tests/ui/consts/local-var-in-associated-const.rs diff --git a/tests/ui/issues/issue-44239.stderr b/tests/ui/consts/local-var-in-associated-const.stderr similarity index 100% rename from tests/ui/issues/issue-44239.stderr rename to tests/ui/consts/local-var-in-associated-const.stderr diff --git a/tests/ui/issues/issue-25757.rs b/tests/ui/consts/method-reference-in-const-dyn-fn.rs similarity index 100% rename from tests/ui/issues/issue-25757.rs rename to tests/ui/consts/method-reference-in-const-dyn-fn.rs diff --git a/tests/ui/issues/issue-27433.fixed b/tests/ui/consts/non-constant-value-in-nested-const.fixed similarity index 100% rename from tests/ui/issues/issue-27433.fixed rename to tests/ui/consts/non-constant-value-in-nested-const.fixed diff --git a/tests/ui/issues/issue-27433.rs b/tests/ui/consts/non-constant-value-in-nested-const.rs similarity index 100% rename from tests/ui/issues/issue-27433.rs rename to tests/ui/consts/non-constant-value-in-nested-const.rs diff --git a/tests/ui/issues/issue-27433.stderr b/tests/ui/consts/non-constant-value-in-nested-const.stderr similarity index 100% rename from tests/ui/issues/issue-27433.stderr rename to tests/ui/consts/non-constant-value-in-nested-const.stderr diff --git a/tests/ui/issues/issue-17252.rs b/tests/ui/consts/recursive-const-stack-overflow.rs similarity index 100% rename from tests/ui/issues/issue-17252.rs rename to tests/ui/consts/recursive-const-stack-overflow.rs diff --git a/tests/ui/issues/issue-17252.stderr b/tests/ui/consts/recursive-const-stack-overflow.stderr similarity index 100% rename from tests/ui/issues/issue-17252.stderr rename to tests/ui/consts/recursive-const-stack-overflow.stderr diff --git a/tests/ui/issues/issue-30891.rs b/tests/ui/consts/short-circuit-or-with-const-bool.rs similarity index 100% rename from tests/ui/issues/issue-30891.rs rename to tests/ui/consts/short-circuit-or-with-const-bool.rs diff --git a/tests/ui/issues/issue-40951.rs b/tests/ui/consts/static-lifetime-inference-from-const-array.rs similarity index 100% rename from tests/ui/issues/issue-40951.rs rename to tests/ui/consts/static-lifetime-inference-from-const-array.rs diff --git a/tests/ui/issues/issue-49955.rs b/tests/ui/consts/static-ref-to-const-array-element.rs similarity index 100% rename from tests/ui/issues/issue-49955.rs rename to tests/ui/consts/static-ref-to-const-array-element.rs From 1ad59ef18292fdb8eb96d12ff5b807652fa2e795 Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Thu, 7 May 2026 23:51:35 +0800 Subject: [PATCH 08/28] mark the suggestion as directly when it is --- compiler/rustc_resolve/src/diagnostics.rs | 52 +++++++++++-------- ...ous-import-visibility-globglob-priv.stderr | 4 +- ...-suggestion-path-156244-edition2015.stderr | 8 +-- ...ivate-import-suggestion-path-156244.stderr | 8 +-- ...private-std-reexport-suggest-public.stderr | 2 +- tests/ui/privacy/privacy2.stderr | 2 +- 6 files changed, 41 insertions(+), 35 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index acad0c6726d96..47b4e9ca2c694 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2307,7 +2307,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.mention_default_field_values(source, ident, &mut err); - let mut not_publicly_reexported = false; if let Some((this_res, outer_ident)) = outermost_res { let mut import_suggestions = self.lookup_import_candidates( outer_ident, @@ -2332,7 +2331,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ); // If we suggest importing a public re-export, don't point at the definition. if point_to_def && ident.span != outer_ident.span { - not_publicly_reexported = true; let label = errors::OuterIdentIsNotPubliclyReexported { span: outer_ident.span, outer_ident_descr: this_res.descr(), @@ -2428,7 +2426,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; match binding.kind { - DeclKind::Import { import, .. } => { + DeclKind::Import { source_decl, import, .. } => { for segment in &import.module_path { // Don't include `{{root}}` in suggestions - it's an internal symbol // that should never be shown to users. @@ -2436,9 +2434,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { path.push(segment.ident); } } + let through_reexport = !matches!(source_decl.kind, DeclKind::Def(_)); sugg_paths.push(( path.iter().cloned().chain(std::iter::once(ident)).collect::>(), - true, // re-export + through_reexport, )); } DeclKind::Def(_) => {} @@ -2472,27 +2471,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; err.subdiagnostic(note); } - // We prioritize shorter paths, non-core imports and direct imports over the alternatives. - sugg_paths.sort_by_key(|(p, reexport)| (p.len(), p[0].name == sym::core, *reexport)); - // In nested imports `dedup_span` is just the inner ident, so a full path - // substitution would produce invalid code. See #156060. - for (sugg, reexport) in sugg_paths { - if not_publicly_reexported || single_nested { + // The suggestion replaces `dedup_span` with a path reaching the failing ident. + // That's valid only when + // 1) the failing ident is the imported leaf, otherwise `as` renames and trailing segments + // get dropped, and + // 2) the use isn't nested, otherwise `dedup_span` is one ident in `{...}`. + // + // See issue #156060. + let can_replace_use = + !single_nested && !outermost_res.is_some_and(|(_, outer)| outer.span != ident.span); + if can_replace_use { + // We prioritize shorter paths, non-core imports and direct imports over the + // alternatives. + sugg_paths.sort_by_key(|(p, reexport)| (p.len(), p[0].name == sym::core, *reexport)); + for (sugg, reexport) in sugg_paths { + if sugg.len() <= 1 { + // A single path segment suggestion is wrong. This happens on circular + // imports. `tests/ui/imports/issue-55884-2.rs` + continue; + } + let path = join_path_idents(sugg); + let sugg = if reexport { + errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path } + } else { + errors::ImportIdent::Directly { span: dedup_span, ident, path } + }; + err.subdiagnostic(sugg); break; } - if sugg.len() <= 1 { - // A single path segment suggestion is wrong. This happens on circular imports. - // `tests/ui/imports/issue-55884-2.rs` - continue; - } - let path = join_path_idents(sugg); - let sugg = if reexport { - errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path } - } else { - errors::ImportIdent::Directly { span: dedup_span, ident, path } - }; - err.subdiagnostic(sugg); - break; } err.emit(); diff --git a/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr b/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr index 07c0be3726ee8..a6119dba34d70 100644 --- a/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr +++ b/tests/ui/imports/ambiguous-import-visibility-globglob-priv.stderr @@ -14,7 +14,7 @@ note: ...and refers to the struct `S` which is defined here | LL | pub struct S {} | ^^^^^^^^^^^^ you could import this directly -help: import `S` through the re-export +help: import `S` directly | LL - use crate::both::private::S; LL + use crate::m::S; @@ -36,7 +36,7 @@ note: ...and refers to the struct `S` which is defined here | LL | pub struct S {} | ^^^^^^^^^^^^ you could import this directly -help: import `S` through the re-export +help: import `S` directly | LL - use crate::both::private::S; LL + use crate::m::S; diff --git a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr index 4723ac835e303..777e060430692 100644 --- a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr +++ b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr @@ -1,20 +1,20 @@ error[E0603]: struct import `One` is private - --> $DIR/private-import-suggestion-path-156244-edition2015.rs:16:14 + --> $DIR/private-import-suggestion-path-156244-edition2015.rs:12:14 | LL | use two::One; | ^^^ private struct import | note: the struct import `One` is defined here... - --> $DIR/private-import-suggestion-path-156244-edition2015.rs:12:9 + --> $DIR/private-import-suggestion-path-156244-edition2015.rs:8:9 | LL | use one::One; | ^^^^^^^^ note: ...and refers to the struct `One` which is defined here - --> $DIR/private-import-suggestion-path-156244-edition2015.rs:8:5 + --> $DIR/private-import-suggestion-path-156244-edition2015.rs:4:5 | LL | pub struct One(); | ^^^^^^^^^^^^^^^^^ you could import this directly -help: import `One` through the re-export +help: import `One` directly | LL - use two::One; LL + use one::One; diff --git a/tests/ui/imports/private-import-suggestion-path-156244.stderr b/tests/ui/imports/private-import-suggestion-path-156244.stderr index f31d18460b666..c4f8aff049906 100644 --- a/tests/ui/imports/private-import-suggestion-path-156244.stderr +++ b/tests/ui/imports/private-import-suggestion-path-156244.stderr @@ -1,20 +1,20 @@ error[E0603]: struct import `One` is private - --> $DIR/private-import-suggestion-path-156244.rs:15:21 + --> $DIR/private-import-suggestion-path-156244.rs:12:21 | LL | use crate::two::One; | ^^^ private struct import | note: the struct import `One` is defined here... - --> $DIR/private-import-suggestion-path-156244.rs:11:9 + --> $DIR/private-import-suggestion-path-156244.rs:8:9 | LL | use crate::one::One; | ^^^^^^^^^^^^^^^ note: ...and refers to the struct `One` which is defined here - --> $DIR/private-import-suggestion-path-156244.rs:7:5 + --> $DIR/private-import-suggestion-path-156244.rs:4:5 | LL | pub struct One(); | ^^^^^^^^^^^^^^^^^ you could import this directly -help: import `One` through the re-export +help: import `One` directly | LL - use crate::two::One; LL + use crate::one::One; diff --git a/tests/ui/imports/private-std-reexport-suggest-public.stderr b/tests/ui/imports/private-std-reexport-suggest-public.stderr index 49718da7fc939..cc4365d73ad9a 100644 --- a/tests/ui/imports/private-std-reexport-suggest-public.stderr +++ b/tests/ui/imports/private-std-reexport-suggest-public.stderr @@ -13,7 +13,7 @@ note: ...and refers to the module `mem` which is defined here --> $SRC_DIR/std/src/lib.rs:LL:COL | = note: you could import this directly -help: import `mem` through the re-export +help: import `mem` directly | LL - use foo::mem; LL + use std::mem; diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index 5c720540db8e3..cef8fdb6c5154 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -20,7 +20,7 @@ note: ...and refers to the function `foo` which is defined here | LL | pub fn foo() {} | ^^^^^^^^^^^^ you could import this directly -help: import `foo` through the re-export +help: import `foo` directly | LL - use bar::glob::foo; LL + use crate::foo; From b7d22fd68bd2047ad67b3d5b53186157b591111b Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Fri, 8 May 2026 16:21:06 +0800 Subject: [PATCH 09/28] refactor path construction Co-Authored-By: mu001999 --- compiler/rustc_resolve/src/diagnostics.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 47b4e9ca2c694..874b4ca988305 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -2406,7 +2406,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let first_binding = decl; let mut next_binding = Some(decl); let mut next_ident = ident; - let mut path = vec![]; while let Some(binding) = next_binding { let name = next_ident; next_binding = match binding.kind { @@ -2427,18 +2426,17 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { match binding.kind { DeclKind::Import { source_decl, import, .. } => { - for segment in &import.module_path { - // Don't include `{{root}}` in suggestions - it's an internal symbol - // that should never be shown to users. - if segment.ident.name != kw::PathRoot { - path.push(segment.ident); - } - } + // Don't include `{{root}}` in suggestions - it's an internal symbol + // that should never be shown to users. + let path = import + .module_path + .iter() + .filter(|seg| seg.ident.name != kw::PathRoot) + .map(|seg| seg.ident.clone()) + .chain(std::iter::once(ident)) + .collect::>(); let through_reexport = !matches!(source_decl.kind, DeclKind::Def(_)); - sugg_paths.push(( - path.iter().cloned().chain(std::iter::once(ident)).collect::>(), - through_reexport, - )); + sugg_paths.push((path, through_reexport)); } DeclKind::Def(_) => {} } From 2a119e8c4f5cc5fe2733a997fbfa96c4e67e857d Mon Sep 17 00:00:00 2001 From: danieljofficial Date: Fri, 8 May 2026 10:36:04 +0100 Subject: [PATCH 10/28] add issue links and bless --- tests/ui/consts/arithmetic-expr-in-array-len.rs | 2 ++ .../consts/assoc-const-with-self-in-trait-object.rs | 2 ++ .../ui/consts/bool-comparison-in-const-array-len.rs | 2 ++ tests/ui/consts/const-array-oob-in-range-expr.rs | 2 ++ tests/ui/consts/empty-array-index-in-struct-init.rs | 2 ++ tests/ui/consts/local-var-in-associated-const.fixed | 2 ++ tests/ui/consts/local-var-in-associated-const.rs | 2 ++ tests/ui/consts/local-var-in-associated-const.stderr | 2 +- tests/ui/consts/method-reference-in-const-dyn-fn.rs | 2 ++ .../consts/non-constant-value-in-nested-const.fixed | 2 ++ .../ui/consts/non-constant-value-in-nested-const.rs | 2 ++ .../consts/non-constant-value-in-nested-const.stderr | 2 +- tests/ui/consts/recursive-const-stack-overflow.rs | 2 ++ .../ui/consts/recursive-const-stack-overflow.stderr | 12 ++++++------ tests/ui/consts/short-circuit-or-with-const-bool.rs | 2 ++ .../static-lifetime-inference-from-const-array.rs | 2 +- tests/ui/consts/static-ref-to-const-array-element.rs | 2 ++ 17 files changed, 35 insertions(+), 9 deletions(-) diff --git a/tests/ui/consts/arithmetic-expr-in-array-len.rs b/tests/ui/consts/arithmetic-expr-in-array-len.rs index 10f607aacbd2d..758833b485bd3 100644 --- a/tests/ui/consts/arithmetic-expr-in-array-len.rs +++ b/tests/ui/consts/arithmetic-expr-in-array-len.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/4387 + //@ run-pass pub fn main() { diff --git a/tests/ui/consts/assoc-const-with-self-in-trait-object.rs b/tests/ui/consts/assoc-const-with-self-in-trait-object.rs index 9ac0a297fef3d..653dc05ae0303 100644 --- a/tests/ui/consts/assoc-const-with-self-in-trait-object.rs +++ b/tests/ui/consts/assoc-const-with-self-in-trait-object.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/50518 + //@ check-pass use std::marker::PhantomData; diff --git a/tests/ui/consts/bool-comparison-in-const-array-len.rs b/tests/ui/consts/bool-comparison-in-const-array-len.rs index e46114154f9d5..028ec16a21c66 100644 --- a/tests/ui/consts/bool-comparison-in-const-array-len.rs +++ b/tests/ui/consts/bool-comparison-in-const-array-len.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/39548 + //@ run-pass type Array = [(); ((1 < 2) == false) as usize]; diff --git a/tests/ui/consts/const-array-oob-in-range-expr.rs b/tests/ui/consts/const-array-oob-in-range-expr.rs index 4d0f757b7a59f..da95bf5fcc57e 100644 --- a/tests/ui/consts/const-array-oob-in-range-expr.rs +++ b/tests/ui/consts/const-array-oob-in-range-expr.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/33287 + //@ build-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/consts/empty-array-index-in-struct-init.rs b/tests/ui/consts/empty-array-index-in-struct-init.rs index 13c35c8fdaad5..c0b77abf03517 100644 --- a/tests/ui/consts/empty-array-index-in-struct-init.rs +++ b/tests/ui/consts/empty-array-index-in-struct-init.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/53275 + //@ build-pass #![crate_type = "lib"] diff --git a/tests/ui/consts/local-var-in-associated-const.fixed b/tests/ui/consts/local-var-in-associated-const.fixed index 5466726fc9d4b..94d8b6ed44877 100644 --- a/tests/ui/consts/local-var-in-associated-const.fixed +++ b/tests/ui/consts/local-var-in-associated-const.fixed @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/44239 + //@ run-rustfix #![allow(dead_code, non_upper_case_globals)] fn main() { diff --git a/tests/ui/consts/local-var-in-associated-const.rs b/tests/ui/consts/local-var-in-associated-const.rs index b07c3f6dbeffc..18a06911b3252 100644 --- a/tests/ui/consts/local-var-in-associated-const.rs +++ b/tests/ui/consts/local-var-in-associated-const.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/44239 + //@ run-rustfix #![allow(dead_code, non_upper_case_globals)] fn main() { diff --git a/tests/ui/consts/local-var-in-associated-const.stderr b/tests/ui/consts/local-var-in-associated-const.stderr index 8048e32f149a9..c85cc6b93ff57 100644 --- a/tests/ui/consts/local-var-in-associated-const.stderr +++ b/tests/ui/consts/local-var-in-associated-const.stderr @@ -1,5 +1,5 @@ error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/issue-44239.rs:8:26 + --> $DIR/local-var-in-associated-const.rs:10:26 | LL | const N: usize = n; | ^ non-constant value diff --git a/tests/ui/consts/method-reference-in-const-dyn-fn.rs b/tests/ui/consts/method-reference-in-const-dyn-fn.rs index dc9c2ffaa6fad..edb6efc770096 100644 --- a/tests/ui/consts/method-reference-in-const-dyn-fn.rs +++ b/tests/ui/consts/method-reference-in-const-dyn-fn.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/25757 + //@ run-pass struct Foo { a: u32 diff --git a/tests/ui/consts/non-constant-value-in-nested-const.fixed b/tests/ui/consts/non-constant-value-in-nested-const.fixed index f847b698976a0..9942537b48934 100644 --- a/tests/ui/consts/non-constant-value-in-nested-const.fixed +++ b/tests/ui/consts/non-constant-value-in-nested-const.fixed @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/27433 + //@ run-rustfix fn main() { let foo = 42u32; diff --git a/tests/ui/consts/non-constant-value-in-nested-const.rs b/tests/ui/consts/non-constant-value-in-nested-const.rs index 9bbc5bcbb459d..fbaba2de615d6 100644 --- a/tests/ui/consts/non-constant-value-in-nested-const.rs +++ b/tests/ui/consts/non-constant-value-in-nested-const.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/27433 + //@ run-rustfix fn main() { let foo = 42u32; diff --git a/tests/ui/consts/non-constant-value-in-nested-const.stderr b/tests/ui/consts/non-constant-value-in-nested-const.stderr index d8fd3d84ecbbc..c50bb8651716a 100644 --- a/tests/ui/consts/non-constant-value-in-nested-const.stderr +++ b/tests/ui/consts/non-constant-value-in-nested-const.stderr @@ -1,5 +1,5 @@ error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/issue-27433.rs:5:23 + --> $DIR/non-constant-value-in-nested-const.rs:7:23 | LL | const FOO : u32 = foo; | ^^^ non-constant value diff --git a/tests/ui/consts/recursive-const-stack-overflow.rs b/tests/ui/consts/recursive-const-stack-overflow.rs index dd002bfd187a0..aee95a685b20a 100644 --- a/tests/ui/consts/recursive-const-stack-overflow.rs +++ b/tests/ui/consts/recursive-const-stack-overflow.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/17252 + const FOO: usize = FOO; //~ ERROR E0391 //@ ignore-parallel-frontend query cycle fn main() { diff --git a/tests/ui/consts/recursive-const-stack-overflow.stderr b/tests/ui/consts/recursive-const-stack-overflow.stderr index b0d9d94e07ddf..054102f0978ab 100644 --- a/tests/ui/consts/recursive-const-stack-overflow.stderr +++ b/tests/ui/consts/recursive-const-stack-overflow.stderr @@ -1,36 +1,36 @@ error[E0391]: cycle detected when checking if `FOO` is a trivial const - --> $DIR/issue-17252.rs:1:1 + --> $DIR/recursive-const-stack-overflow.rs:3:1 | LL | const FOO: usize = FOO; | ^^^^^^^^^^^^^^^^ | note: ...which requires building MIR for `FOO`... - --> $DIR/issue-17252.rs:1:1 + --> $DIR/recursive-const-stack-overflow.rs:3:1 | LL | const FOO: usize = FOO; | ^^^^^^^^^^^^^^^^ = note: ...which again requires checking if `FOO` is a trivial const, completing the cycle note: cycle used when simplifying constant for the type system `FOO` - --> $DIR/issue-17252.rs:1:1 + --> $DIR/recursive-const-stack-overflow.rs:3:1 | LL | const FOO: usize = FOO; | ^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when checking if `main::BAR` is a trivial const - --> $DIR/issue-17252.rs:6:9 + --> $DIR/recursive-const-stack-overflow.rs:8:9 | LL | const BAR: usize = BAR; | ^^^^^^^^^^^^^^^^ | note: ...which requires building MIR for `main::BAR`... - --> $DIR/issue-17252.rs:6:9 + --> $DIR/recursive-const-stack-overflow.rs:8:9 | LL | const BAR: usize = BAR; | ^^^^^^^^^^^^^^^^ = note: ...which again requires checking if `main::BAR` is a trivial const, completing the cycle note: cycle used when simplifying constant for the type system `main::BAR` - --> $DIR/issue-17252.rs:6:9 + --> $DIR/recursive-const-stack-overflow.rs:8:9 | LL | const BAR: usize = BAR; | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/short-circuit-or-with-const-bool.rs b/tests/ui/consts/short-circuit-or-with-const-bool.rs index 25b7165d01167..aafe9cefa2220 100644 --- a/tests/ui/consts/short-circuit-or-with-const-bool.rs +++ b/tests/ui/consts/short-circuit-or-with-const-bool.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/30891 + //@ run-pass const ERROR_CONST: bool = true; diff --git a/tests/ui/consts/static-lifetime-inference-from-const-array.rs b/tests/ui/consts/static-lifetime-inference-from-const-array.rs index e99fe76c08527..05edbd66052af 100644 --- a/tests/ui/consts/static-lifetime-inference-from-const-array.rs +++ b/tests/ui/consts/static-lifetime-inference-from-const-array.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(unused_variables)] -// Regression test for #40951. +// Regression test for https://github.com/rust-lang/rust/issues/40951. const FOO: [&'static str; 1] = ["foo"]; diff --git a/tests/ui/consts/static-ref-to-const-array-element.rs b/tests/ui/consts/static-ref-to-const-array-element.rs index c2f160bd6d4cc..b53ffc2685619 100644 --- a/tests/ui/consts/static-ref-to-const-array-element.rs +++ b/tests/ui/consts/static-ref-to-const-array-element.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/49955 + //@ run-pass const ALL_THE_NUMS: [u32; 1] = [ From a28de9fb1cc5e392d7ca077a37bd67fbe5aac9a4 Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Fri, 8 May 2026 17:43:42 +0800 Subject: [PATCH 11/28] update tests --- tests/ui/imports/issue-55884-2.stderr | 5 ++ .../private-import-no-suggestion-156244.rs | 31 ++++++++++ ...private-import-no-suggestion-156244.stderr | 59 +++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/ui/imports/private-import-no-suggestion-156244.rs create mode 100644 tests/ui/imports/private-import-no-suggestion-156244.stderr diff --git a/tests/ui/imports/issue-55884-2.stderr b/tests/ui/imports/issue-55884-2.stderr index 7425b92a11e0f..55b5158ffca89 100644 --- a/tests/ui/imports/issue-55884-2.stderr +++ b/tests/ui/imports/issue-55884-2.stderr @@ -24,6 +24,11 @@ note: ...and refers to the struct `ParseOptions` which is defined here | LL | pub struct ParseOptions {} | ^^^^^^^^^^^^^^^^^^^^^^^ you could import this directly +help: import `ParseOptions` directly + | +LL - pub use parser::ParseOptions; +LL + pub use options::ParseOptions; + | error: aborting due to 1 previous error diff --git a/tests/ui/imports/private-import-no-suggestion-156244.rs b/tests/ui/imports/private-import-no-suggestion-156244.rs new file mode 100644 index 0000000000000..b82340daa4afb --- /dev/null +++ b/tests/ui/imports/private-import-no-suggestion-156244.rs @@ -0,0 +1,31 @@ +//@ edition: 2018 + +mod a { + pub struct One; + pub struct Two; +} + +mod b { + use crate::a::One; + use crate::a::Two; +} + +mod outer { + pub mod actual { + pub struct Item; + } +} + +mod rename { + use crate::outer::actual as inner; +} + +mod bad { + use crate::b::{One, Two}; + //~^ ERROR struct import `One` is private [E0603] + //~| ERROR struct import `Two` is private [E0603] + use crate::rename::inner::Item as Item1; + //~^ ERROR module import `inner` is private [E0603] +} + +fn main() {} diff --git a/tests/ui/imports/private-import-no-suggestion-156244.stderr b/tests/ui/imports/private-import-no-suggestion-156244.stderr new file mode 100644 index 0000000000000..c3bc8ae4373a7 --- /dev/null +++ b/tests/ui/imports/private-import-no-suggestion-156244.stderr @@ -0,0 +1,59 @@ +error[E0603]: struct import `One` is private + --> $DIR/private-import-no-suggestion-156244.rs:24:20 + | +LL | use crate::b::{One, Two}; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-no-suggestion-156244.rs:9:9 + | +LL | use crate::a::One; + | ^^^^^^^^^^^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-no-suggestion-156244.rs:4:5 + | +LL | pub struct One; + | ^^^^^^^^^^^^^^^ you could import this directly + +error[E0603]: struct import `Two` is private + --> $DIR/private-import-no-suggestion-156244.rs:24:25 + | +LL | use crate::b::{One, Two}; + | ^^^ private struct import + | +note: the struct import `Two` is defined here... + --> $DIR/private-import-no-suggestion-156244.rs:10:9 + | +LL | use crate::a::Two; + | ^^^^^^^^^^^^^ +note: ...and refers to the struct `Two` which is defined here + --> $DIR/private-import-no-suggestion-156244.rs:5:5 + | +LL | pub struct Two; + | ^^^^^^^^^^^^^^^ you could import this directly + +error[E0603]: module import `inner` is private + --> $DIR/private-import-no-suggestion-156244.rs:27:24 + | +LL | use crate::rename::inner::Item as Item1; + | ^^^^^ private module import + | +note: the module import `inner` is defined here... + --> $DIR/private-import-no-suggestion-156244.rs:20:9 + | +LL | use crate::outer::actual as inner; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...and refers to the module `actual` which is defined here + --> $DIR/private-import-no-suggestion-156244.rs:14:5 + | +LL | pub mod actual { + | ^^^^^^^^^^^^^^ you could import this directly +help: consider importing this struct instead + | +LL - use crate::rename::inner::Item as Item1; +LL + use crate::outer::actual::Item as Item1; + | + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0603`. From 22d28263cf9536f724953893daaca12362fa3faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Fri, 1 May 2026 14:30:52 +0200 Subject: [PATCH 12/28] remove param_env from HasTypingEnv --- compiler/rustc_middle/src/ty/layout.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index e38e5393d967d..73392d9e6eeaf 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -528,12 +528,6 @@ pub trait HasTyCtxt<'tcx>: HasDataLayout { pub trait HasTypingEnv<'tcx> { fn typing_env(&self) -> ty::TypingEnv<'tcx>; - - /// FIXME(#132279): This method should not be used as in the future - /// everything should take a `TypingEnv` instead. Remove it as that point. - fn param_env(&self) -> ty::ParamEnv<'tcx> { - self.typing_env().param_env - } } impl<'tcx> HasDataLayout for TyCtxt<'tcx> { From 68f9143013502454fd50131160eb970c921d4b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Fri, 1 May 2026 14:30:52 +0200 Subject: [PATCH 13/28] use the right typing mode for each mir phase --- .../src/check_consts/qualifs.rs | 17 +++++---- compiler/rustc_middle/src/mir/mod.rs | 37 +++++++++++++++---- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index e1cab9af046be..0410521034b6b 100644 --- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs @@ -9,7 +9,7 @@ use rustc_errors::ErrorGuaranteed; use rustc_hir::LangItem; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::*; -use rustc_middle::ty::{self, AdtDef, Ty}; +use rustc_middle::ty::{self, AdtDef, Ty, TypingMode}; use rustc_middle::{bug, mir}; use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt}; use tracing::instrument; @@ -100,13 +100,14 @@ impl Qualif for HasMutInterior { // Instead we invoke an obligation context manually, and provide the opaque type inference settings // that allow the trait solver to just error out instead of cycling. let freeze_def_id = cx.tcx.require_lang_item(LangItem::Freeze, cx.body.span); - // FIXME(#132279): Once we've got a typing mode which reveals opaque types using the HIR - // typeck results without causing query cycles, we should use this here instead of defining - // opaque types. - let typing_env = ty::TypingEnv::new( - cx.typing_env.param_env, - ty::TypingMode::analysis_in_body(cx.tcx, cx.body.source.def_id().expect_local()), - ); + let did = cx.body.source.def_id().expect_local(); + + let typing_env = if cx.tcx.use_typing_mode_borrowck() { + cx.typing_env + } else { + ty::TypingEnv::new(cx.typing_env.param_env, TypingMode::analysis_in_body(cx.tcx, did)) + }; + let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(typing_env); let ocx = ObligationCtxt::new(&infcx); let obligation = Obligation::new( diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 6124b92da5c10..49077c3007f4a 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -413,13 +413,36 @@ impl<'tcx> Body<'tcx> { } pub fn typing_env(&self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> { - match self.phase { - // FIXME(#132279): we should reveal the opaques defined in the body during analysis. - MirPhase::Built | MirPhase::Analysis(_) => TypingEnv::new( - tcx.param_env(self.source.def_id()), - ty::TypingMode::non_body_analysis(), - ), - MirPhase::Runtime(_) => TypingEnv::post_analysis(tcx, self.source.def_id()), + if tcx.use_typing_mode_borrowck() { + match self.phase { + MirPhase::Built if let Some(def_id) = self.source.def_id().as_local() => { + TypingEnv::new( + tcx.param_env(self.source.def_id()), + ty::TypingMode::borrowck(tcx, def_id), + ) + } + MirPhase::Analysis(_) if let Some(def_id) = self.source.def_id().as_local() => { + TypingEnv::new( + tcx.param_env(self.source.def_id()), + ty::TypingMode::post_borrowck_analysis(tcx, def_id), + ) + } + MirPhase::Built | MirPhase::Analysis(_) => { + // This branch happens for drop glue and fn ptr shims. + // FIXME: why do we do any of this analysis on drop glue etc? + // This should ideally all be skipped. + TypingEnv::post_analysis(tcx, self.source.def_id()) + } + MirPhase::Runtime(_) => TypingEnv::post_analysis(tcx, self.source.def_id()), + } + } else { + match self.phase { + MirPhase::Built | MirPhase::Analysis(_) => TypingEnv::new( + tcx.param_env(self.source.def_id()), + ty::TypingMode::non_body_analysis(), + ), + MirPhase::Runtime(_) => TypingEnv::post_analysis(tcx, self.source.def_id()), + } } } From 0aefbd13c342417a688fec320b94ac243b7ee592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Mon, 4 May 2026 15:14:14 +0200 Subject: [PATCH 14/28] use the right typing mode in lints --- compiler/rustc_infer/src/infer/mod.rs | 21 +++++++++++++++++++ compiler/rustc_lint/src/context.rs | 11 +++++++--- .../src/opaque_hidden_inferred_bound.rs | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index b802c3b2e8d40..a23dc5bda9dd0 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -320,6 +320,27 @@ pub struct InferCtxt<'tcx> { pub obligation_inspector: Cell>>, } +impl<'tcx> Drop for InferCtxt<'tcx> { + fn drop(&mut self) { + // Defuse the drop bomb in the OpaqueTypeStorage when we're in TypingMode::Borrowck, + // and the InferCtxt doesn't consider regions. This is okay since in `Borrowck`, + // the only reason we care about opaques is in relation to regions. + // In some places *after* typeck, like in lints we use `TypingMode::Borrowck` + // to prevent defining opaque types and we simply don't care about regions. + match self.typing_mode() { + TypingMode::Coherence + | TypingMode::Analysis { .. } + | TypingMode::PostBorrowckAnalysis { .. } + | TypingMode::PostAnalysis => {} + TypingMode::Borrowck { .. } => { + if !self.considering_regions { + let _ = self.inner.borrow_mut().opaque_type_storage.take_opaque_types(); + } + } + } + } +} + /// See the `error_reporting` module for more details. #[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable)] pub enum ValuePairs<'tcx> { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 352652413751e..6b0205f9a78a3 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -633,9 +633,14 @@ impl<'tcx> LateContext<'tcx> { /// The typing mode of the currently visited node. Use this when /// building a new `InferCtxt`. pub fn typing_mode(&self) -> TypingMode<'tcx> { - // FIXME(#132279): In case we're in a body, we should use a typing - // mode which reveals the opaque types defined by that body. - TypingMode::non_body_analysis() + if let Some(body_id) = self.enclosing_body + && self.tcx.use_typing_mode_borrowck() + { + let def_id = self.tcx.hir_enclosing_body_owner(body_id.hir_id); + TypingMode::borrowck(self.tcx, def_id) + } else { + TypingMode::non_body_analysis() + } } pub fn typing_env(&self) -> TypingEnv<'tcx> { diff --git a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs index 97df4ebc8ae13..6b19aa17c6d6c 100644 --- a/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs +++ b/compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs @@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound { } let def_id = opaque.def_id.to_def_id(); - let infcx = &cx.tcx.infer_ctxt().build(cx.typing_mode()); + let infcx = &cx.tcx.infer_ctxt().ignoring_regions().build(cx.typing_mode()); // For every projection predicate in the opaque type's explicit bounds, // check that the type that we're assigning actually satisfies the bounds // of the associated type. From 0d65aa285fd7377e7402c2827ce335bf4a123eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Tue, 5 May 2026 13:44:45 +0200 Subject: [PATCH 15/28] move drop bomb from OpaqueTypeStorage into InferCtxt's Drop --- compiler/rustc_infer/src/infer/mod.rs | 18 +++++++++++++----- .../src/infer/opaque_types/table.rs | 10 +--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index a23dc5bda9dd0..3c70d03aed0d6 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -322,22 +322,30 @@ pub struct InferCtxt<'tcx> { impl<'tcx> Drop for InferCtxt<'tcx> { fn drop(&mut self) { - // Defuse the drop bomb in the OpaqueTypeStorage when we're in TypingMode::Borrowck, - // and the InferCtxt doesn't consider regions. This is okay since in `Borrowck`, - // the only reason we care about opaques is in relation to regions. + let mut inner = self.inner.borrow_mut(); + let opaque_type_storage = &mut inner.opaque_type_storage; + + // No need for the drop bomb when we're in TypingMode::Borrowck, and the InferCtxt doesn't consider regions. + // This is okay since in `Borrowck`, the only reason we care about opaques is in relation to regions. // In some places *after* typeck, like in lints we use `TypingMode::Borrowck` // to prevent defining opaque types and we simply don't care about regions. - match self.typing_mode() { + match self.typing_mode_raw() { TypingMode::Coherence | TypingMode::Analysis { .. } | TypingMode::PostBorrowckAnalysis { .. } | TypingMode::PostAnalysis => {} + // In erased mode, the opaque type storage is always empty + TypingMode::ErasedNotCoherence(..) => {} TypingMode::Borrowck { .. } => { if !self.considering_regions { - let _ = self.inner.borrow_mut().opaque_type_storage.take_opaque_types(); + return; } } } + + if !opaque_type_storage.is_empty() { + ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{opaque_type_storage:?}"))); + } } } diff --git a/compiler/rustc_infer/src/infer/opaque_types/table.rs b/compiler/rustc_infer/src/infer/opaque_types/table.rs index 55c00a8695fa5..066d12be320a2 100644 --- a/compiler/rustc_infer/src/infer/opaque_types/table.rs +++ b/compiler/rustc_infer/src/infer/opaque_types/table.rs @@ -3,7 +3,7 @@ use std::ops::Deref; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::undo_log::UndoLogs; use rustc_middle::bug; -use rustc_middle::ty::{self, OpaqueTypeKey, ProvisionalHiddenType, Ty}; +use rustc_middle::ty::{OpaqueTypeKey, ProvisionalHiddenType, Ty}; use tracing::instrument; use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog}; @@ -121,14 +121,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> { } } -impl<'tcx> Drop for OpaqueTypeStorage<'tcx> { - fn drop(&mut self) { - if !self.is_empty() { - ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{:?}", self.opaque_types))); - } - } -} - pub struct OpaqueTypeTable<'a, 'tcx> { storage: &'a mut OpaqueTypeStorage<'tcx>, From 6d5fc3275f99116946190ef1d913312f3f24af9d Mon Sep 17 00:00:00 2001 From: Iris Shi <0.0@owo.li> Date: Fri, 8 May 2026 20:42:22 +0800 Subject: [PATCH 16/28] combine tests into one file --- .../private-import-no-suggestion-156244.rs | 31 ------- ...port-suggestion-path-156244-edition2015.rs | 16 ---- ...-suggestion-path-156244-edition2015.stderr | 25 ------ ...suggestion-path-156244.edition_2015.stderr | 81 +++++++++++++++++++ ...uggestion-path-156244.edition_2018.stderr} | 50 ++++++++---- .../private-import-suggestion-path-156244.rs | 36 +++++++-- ...ivate-import-suggestion-path-156244.stderr | 25 ------ 7 files changed, 148 insertions(+), 116 deletions(-) delete mode 100644 tests/ui/imports/private-import-no-suggestion-156244.rs delete mode 100644 tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs delete mode 100644 tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr create mode 100644 tests/ui/imports/private-import-suggestion-path-156244.edition_2015.stderr rename tests/ui/imports/{private-import-no-suggestion-156244.stderr => private-import-suggestion-path-156244.edition_2018.stderr} (50%) delete mode 100644 tests/ui/imports/private-import-suggestion-path-156244.stderr diff --git a/tests/ui/imports/private-import-no-suggestion-156244.rs b/tests/ui/imports/private-import-no-suggestion-156244.rs deleted file mode 100644 index b82340daa4afb..0000000000000 --- a/tests/ui/imports/private-import-no-suggestion-156244.rs +++ /dev/null @@ -1,31 +0,0 @@ -//@ edition: 2018 - -mod a { - pub struct One; - pub struct Two; -} - -mod b { - use crate::a::One; - use crate::a::Two; -} - -mod outer { - pub mod actual { - pub struct Item; - } -} - -mod rename { - use crate::outer::actual as inner; -} - -mod bad { - use crate::b::{One, Two}; - //~^ ERROR struct import `One` is private [E0603] - //~| ERROR struct import `Two` is private [E0603] - use crate::rename::inner::Item as Item1; - //~^ ERROR module import `inner` is private [E0603] -} - -fn main() {} diff --git a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs deleted file mode 100644 index b92a136745649..0000000000000 --- a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ edition: 2015 - -mod one { - pub struct One(); -} - -mod two { - use one::One; -} - -mod test { - use two::One; - //~^ ERROR struct import `One` is private [E0603] -} - -fn main() {} diff --git a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr b/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr deleted file mode 100644 index 777e060430692..0000000000000 --- a/tests/ui/imports/private-import-suggestion-path-156244-edition2015.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0603]: struct import `One` is private - --> $DIR/private-import-suggestion-path-156244-edition2015.rs:12:14 - | -LL | use two::One; - | ^^^ private struct import - | -note: the struct import `One` is defined here... - --> $DIR/private-import-suggestion-path-156244-edition2015.rs:8:9 - | -LL | use one::One; - | ^^^^^^^^ -note: ...and refers to the struct `One` which is defined here - --> $DIR/private-import-suggestion-path-156244-edition2015.rs:4:5 - | -LL | pub struct One(); - | ^^^^^^^^^^^^^^^^^ you could import this directly -help: import `One` directly - | -LL - use two::One; -LL + use one::One; - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/imports/private-import-suggestion-path-156244.edition_2015.stderr b/tests/ui/imports/private-import-suggestion-path-156244.edition_2015.stderr new file mode 100644 index 0000000000000..95b1760e6a239 --- /dev/null +++ b/tests/ui/imports/private-import-suggestion-path-156244.edition_2015.stderr @@ -0,0 +1,81 @@ +error[E0603]: struct import `One` is private + --> $DIR/private-import-suggestion-path-156244.rs:17:12 + | +LL | use b::One; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-suggestion-path-156244.rs:12:20 + | +LL | use crate::a::{One, Two}; + | ^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-suggestion-path-156244.rs:7:5 + | +LL | pub struct One; + | ^^^^^^^^^^^^^^^ you could import this directly +help: import `One` directly + | +LL - use b::One; +LL + use crate::a::One; + | + +error[E0603]: struct import `One` is private + --> $DIR/private-import-suggestion-path-156244.rs:35:20 + | +LL | use crate::b::{One, Two}; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-suggestion-path-156244.rs:12:20 + | +LL | use crate::a::{One, Two}; + | ^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-suggestion-path-156244.rs:7:5 + | +LL | pub struct One; + | ^^^^^^^^^^^^^^^ you could import this directly + +error[E0603]: struct import `Two` is private + --> $DIR/private-import-suggestion-path-156244.rs:35:25 + | +LL | use crate::b::{One, Two}; + | ^^^ private struct import + | +note: the struct import `Two` is defined here... + --> $DIR/private-import-suggestion-path-156244.rs:12:25 + | +LL | use crate::a::{One, Two}; + | ^^^ +note: ...and refers to the struct `Two` which is defined here + --> $DIR/private-import-suggestion-path-156244.rs:8:5 + | +LL | pub struct Two; + | ^^^^^^^^^^^^^^^ you could import this directly + +error[E0603]: module import `inner` is private + --> $DIR/private-import-suggestion-path-156244.rs:38:24 + | +LL | use crate::rename::inner::Item as Item1; + | ^^^^^ private module import + | +note: the module import `inner` is defined here... + --> $DIR/private-import-suggestion-path-156244.rs:31:9 + | +LL | use crate::outer::actual as inner; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...and refers to the module `actual` which is defined here + --> $DIR/private-import-suggestion-path-156244.rs:25:5 + | +LL | pub mod actual { + | ^^^^^^^^^^^^^^ you could import this directly +help: consider importing this struct instead + | +LL - use crate::rename::inner::Item as Item1; +LL + use outer::actual::Item as Item1; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/imports/private-import-no-suggestion-156244.stderr b/tests/ui/imports/private-import-suggestion-path-156244.edition_2018.stderr similarity index 50% rename from tests/ui/imports/private-import-no-suggestion-156244.stderr rename to tests/ui/imports/private-import-suggestion-path-156244.edition_2018.stderr index c3bc8ae4373a7..e153b0cdc95aa 100644 --- a/tests/ui/imports/private-import-no-suggestion-156244.stderr +++ b/tests/ui/imports/private-import-suggestion-path-156244.edition_2018.stderr @@ -1,50 +1,72 @@ error[E0603]: struct import `One` is private - --> $DIR/private-import-no-suggestion-156244.rs:24:20 + --> $DIR/private-import-suggestion-path-156244.rs:20:19 + | +LL | use crate::b::One; + | ^^^ private struct import + | +note: the struct import `One` is defined here... + --> $DIR/private-import-suggestion-path-156244.rs:12:20 + | +LL | use crate::a::{One, Two}; + | ^^^ +note: ...and refers to the struct `One` which is defined here + --> $DIR/private-import-suggestion-path-156244.rs:7:5 + | +LL | pub struct One; + | ^^^^^^^^^^^^^^^ you could import this directly +help: import `One` directly + | +LL - use crate::b::One; +LL + use crate::a::One; + | + +error[E0603]: struct import `One` is private + --> $DIR/private-import-suggestion-path-156244.rs:35:20 | LL | use crate::b::{One, Two}; | ^^^ private struct import | note: the struct import `One` is defined here... - --> $DIR/private-import-no-suggestion-156244.rs:9:9 + --> $DIR/private-import-suggestion-path-156244.rs:12:20 | -LL | use crate::a::One; - | ^^^^^^^^^^^^^ +LL | use crate::a::{One, Two}; + | ^^^ note: ...and refers to the struct `One` which is defined here - --> $DIR/private-import-no-suggestion-156244.rs:4:5 + --> $DIR/private-import-suggestion-path-156244.rs:7:5 | LL | pub struct One; | ^^^^^^^^^^^^^^^ you could import this directly error[E0603]: struct import `Two` is private - --> $DIR/private-import-no-suggestion-156244.rs:24:25 + --> $DIR/private-import-suggestion-path-156244.rs:35:25 | LL | use crate::b::{One, Two}; | ^^^ private struct import | note: the struct import `Two` is defined here... - --> $DIR/private-import-no-suggestion-156244.rs:10:9 + --> $DIR/private-import-suggestion-path-156244.rs:12:25 | -LL | use crate::a::Two; - | ^^^^^^^^^^^^^ +LL | use crate::a::{One, Two}; + | ^^^ note: ...and refers to the struct `Two` which is defined here - --> $DIR/private-import-no-suggestion-156244.rs:5:5 + --> $DIR/private-import-suggestion-path-156244.rs:8:5 | LL | pub struct Two; | ^^^^^^^^^^^^^^^ you could import this directly error[E0603]: module import `inner` is private - --> $DIR/private-import-no-suggestion-156244.rs:27:24 + --> $DIR/private-import-suggestion-path-156244.rs:38:24 | LL | use crate::rename::inner::Item as Item1; | ^^^^^ private module import | note: the module import `inner` is defined here... - --> $DIR/private-import-no-suggestion-156244.rs:20:9 + --> $DIR/private-import-suggestion-path-156244.rs:31:9 | LL | use crate::outer::actual as inner; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...and refers to the module `actual` which is defined here - --> $DIR/private-import-no-suggestion-156244.rs:14:5 + --> $DIR/private-import-suggestion-path-156244.rs:25:5 | LL | pub mod actual { | ^^^^^^^^^^^^^^ you could import this directly @@ -54,6 +76,6 @@ LL - use crate::rename::inner::Item as Item1; LL + use crate::outer::actual::Item as Item1; | -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0603`. diff --git a/tests/ui/imports/private-import-suggestion-path-156244.rs b/tests/ui/imports/private-import-suggestion-path-156244.rs index 266a3cb53bdd7..3f9d247097f7d 100644 --- a/tests/ui/imports/private-import-suggestion-path-156244.rs +++ b/tests/ui/imports/private-import-suggestion-path-156244.rs @@ -1,16 +1,42 @@ // PR #156244 comment +//@ revisions: edition_2015 edition_2018 +//@[edition_2015] edition: 2015 +//@[edition_2018] edition: 2018 -mod one { - pub struct One(); +mod a { + pub struct One; + pub struct Two; } -mod two { - use crate::one::One; +mod b { + use crate::a::{One, Two}; } mod test { - use crate::two::One; + #[cfg(edition_2015)] + use b::One; + //[edition_2015]~^ ERROR struct import `One` is private [E0603] + #[cfg(edition_2018)] + use crate::b::One; + //[edition_2018]~^ ERROR struct import `One` is private [E0603] +} + +mod outer { + pub mod actual { + pub struct Item; + } +} + +mod rename { + use crate::outer::actual as inner; +} + +mod bad { + use crate::b::{One, Two}; //~^ ERROR struct import `One` is private [E0603] + //~| ERROR struct import `Two` is private [E0603] + use crate::rename::inner::Item as Item1; + //~^ ERROR module import `inner` is private [E0603] } fn main() {} diff --git a/tests/ui/imports/private-import-suggestion-path-156244.stderr b/tests/ui/imports/private-import-suggestion-path-156244.stderr deleted file mode 100644 index c4f8aff049906..0000000000000 --- a/tests/ui/imports/private-import-suggestion-path-156244.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0603]: struct import `One` is private - --> $DIR/private-import-suggestion-path-156244.rs:12:21 - | -LL | use crate::two::One; - | ^^^ private struct import - | -note: the struct import `One` is defined here... - --> $DIR/private-import-suggestion-path-156244.rs:8:9 - | -LL | use crate::one::One; - | ^^^^^^^^^^^^^^^ -note: ...and refers to the struct `One` which is defined here - --> $DIR/private-import-suggestion-path-156244.rs:4:5 - | -LL | pub struct One(); - | ^^^^^^^^^^^^^^^^^ you could import this directly -help: import `One` directly - | -LL - use crate::two::One; -LL + use crate::one::One; - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0603`. From aa43cd21492e8dd87172e06c480c931507879177 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Fri, 8 May 2026 09:48:32 -0400 Subject: [PATCH 17/28] Remove outdated apple download instructions --- src/doc/rustc-dev-guide/src/autodiff/installation.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/autodiff/installation.md b/src/doc/rustc-dev-guide/src/autodiff/installation.md index 648e6c0ccef6f..c8d5faeb390b4 100644 --- a/src/doc/rustc-dev-guide/src/autodiff/installation.md +++ b/src/doc/rustc-dev-guide/src/autodiff/installation.md @@ -6,7 +6,7 @@ For the meantime, you can download up-to-date builds to enable `std::autodiff` o **Linux**, with `x86_64-unknown-linux-gnu` or `aarch64-unknown-linux-gnu` **Windows**, with `x86_64-llvm-mingw` or `aarch64-llvm-mingw` -You can also download slightly outdated builds for **Apple** (aarch64-apple), which should generally work for now. +In the past you could also download builds for **Apple** (aarch64-apple), however they are not usable at the moment. If you need any other platform, you can build rustc including autodiff from source. Please open an issue if you want to help enabling automatic builds for your prefered target. @@ -23,8 +23,7 @@ For now, you'll have to manually download and copy it. 4) Under the `CI artifacts` section, find the `enzyme-nightly` artifact, download, and unpack it. 5) Copy the artifact (libEnzyme-22.so for linux, libEnzyme-22.dylib for apple, etc.), which should be in a folder named `enzyme-preview`, to your rust toolchain directory. E.g. for linux: `cp ~/Downloads/enzyme-nightly-x86_64-unknown-linux-gnu/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib` -Apple support was temporarily reverted, due to downstream breakages. -If you want to download autodiff for apple, please look at the artifacts from this [`run`]. +Apple support was temporarily reverted, due to downstream breakages. Please (currently) build it from source. ## Installation guide for Nix user. @@ -144,5 +143,4 @@ This will build Enzyme, and you can find it in `Enzyme/enzyme/build/lib/ Date: Fri, 8 May 2026 15:59:17 +0000 Subject: [PATCH 18/28] Prepare for merging from rust-lang/rust This updates the rust-version file to f2b291d902bfde7d7f209fc3a64908134bcef201. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 59e9e5a0e6ee9..d33dd7b83a6a7 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -045b17737dab5fcc28e4cbee0cfe2ce4ed363b32 +f2b291d902bfde7d7f209fc3a64908134bcef201 From 497a0eb906a4c44ddcb56c415db814d08b7c9f08 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 18:05:16 +0200 Subject: [PATCH 19/28] sembr src/autodiff/installation.md --- src/doc/rustc-dev-guide/src/autodiff/installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/autodiff/installation.md b/src/doc/rustc-dev-guide/src/autodiff/installation.md index c8d5faeb390b4..a1e802ffaea5e 100644 --- a/src/doc/rustc-dev-guide/src/autodiff/installation.md +++ b/src/doc/rustc-dev-guide/src/autodiff/installation.md @@ -23,7 +23,8 @@ For now, you'll have to manually download and copy it. 4) Under the `CI artifacts` section, find the `enzyme-nightly` artifact, download, and unpack it. 5) Copy the artifact (libEnzyme-22.so for linux, libEnzyme-22.dylib for apple, etc.), which should be in a folder named `enzyme-preview`, to your rust toolchain directory. E.g. for linux: `cp ~/Downloads/enzyme-nightly-x86_64-unknown-linux-gnu/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib` -Apple support was temporarily reverted, due to downstream breakages. Please (currently) build it from source. +Apple support was temporarily reverted, due to downstream breakages. +Please (currently) build it from source. ## Installation guide for Nix user. @@ -110,8 +111,7 @@ docker cp :/rust/build/dist/rust-nightly-x86_64-unknown-linux-gnu.tar. Afterwards we can create a new (pre-release) tag on the EnzymeAD/rust repository and make a PR against the EnzymeAD/enzyme-explorer repository to update the tag. Remember to ping `tgymnich` on the PR to run his update script. Note: We should archive EnzymeAD/rust and update the instructions here. -The explorer should soon -be able to get the rustc toolchain from the official rust servers. +The explorer should soon be able to get the rustc toolchain from the official rust servers. ## Build instruction for Enzyme itself From a6c134c361acaad27950cc035be186193332cd4d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 18:08:12 +0200 Subject: [PATCH 20/28] sembr src/unsafety-checking.md --- .../rustc-dev-guide/src/unsafety-checking.md | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/unsafety-checking.md b/src/doc/rustc-dev-guide/src/unsafety-checking.md index e4547634280e6..2a0811951b275 100644 --- a/src/doc/rustc-dev-guide/src/unsafety-checking.md +++ b/src/doc/rustc-dev-guide/src/unsafety-checking.md @@ -1,47 +1,49 @@ # Unsafety checking Certain expressions in Rust can violate memory safety and as such need to be -inside an `unsafe` block or function. The compiler will also warn if an unsafe -block is used without any corresponding unsafe operations. +inside an `unsafe` block or function. +The compiler will also warn if an unsafe block is used without any corresponding unsafe operations. ## Overview -The unsafety check is located in the [`check_unsafety`] module. It performs a -walk over the [THIR] of a function and all of its closures and inline constants. +The unsafety check is located in the [`check_unsafety`] module. +It performs a walk over the [THIR] of a function and all of its closures and inline constants. It keeps track of the unsafe context: whether it has entered an `unsafe` block. -If an unsafe operation is used outside of an `unsafe` block, then an error is -reported. If an unsafe operation is used in an unsafe block then that block is +If an unsafe operation is used outside of an `unsafe` block, then an error is reported. +If an unsafe operation is used in an unsafe block then that block is marked as used for [the unused_unsafe lint](#the-unused_unsafe-lint). The unsafety check needs type information so could potentially be done on the -HIR, making use of typeck results, THIR or MIR. THIR is chosen because there are +HIR, making use of typeck results, THIR or MIR. +THIR is chosen because there are fewer cases to consider than in HIR, for example unsafe function calls and -unsafe method calls have the same representation in THIR. The check is not done -on MIR because safety checks do not depend on control flow so MIR is not +unsafe method calls have the same representation in THIR. +The check is not done on MIR because safety checks do not depend on control flow so MIR is not necessary to use and MIR doesn't have as precise spans for some expressions. Most unsafe operations can be identified by checking the `ExprKind` in THIR and -checking the type of the argument. For example, dereferences of a raw pointer +checking the type of the argument. +For example, dereferences of a raw pointer correspond to `ExprKind::Deref`s with an argument that has a raw pointer type. Looking for unsafe Union field accesses is a bit more complex because writing to -a field of a union is safe. The checker tracks when it's visiting the left-hand +a field of a union is safe. +The checker tracks when it's visiting the left-hand side of an assignment expression and allows union fields to directly appear -there, while erroring in all other cases. Union field accesses can also occur -in patterns, so those have to be walked as well. +there, while erroring in all other cases. +Union field accesses can also occur in patterns, so those have to be walked as well. [THIR]: ./thir.md [`check_unsafety`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_mir_build/check_unsafety/index.html ## The unused_unsafe lint -The unused_unsafe lint reports `unsafe` blocks that can be removed. The unsafety -checker records whenever it finds an operation that requires unsafe. The lint is -then reported if either: +The unused_unsafe lint reports `unsafe` blocks that can be removed. +The unsafety checker records whenever it finds an operation that requires unsafe. +The lint is then reported if either: - An `unsafe` block contains no unsafe operations -- An `unsafe` block is within another unsafe block, and the outer block - isn't considered unused +- An `unsafe` block is within another unsafe block, and the outer block isn't considered unused ```rust #![deny(unused_unsafe)] @@ -64,7 +66,8 @@ unsafe { ## Other checks involving `unsafe` [Unsafe traits] require an `unsafe impl` to be implemented, the check for this -is done as part of [coherence]. The `unsafe_code` lint is run as a lint pass on +is done as part of [coherence]. +The `unsafe_code` lint is run as a lint pass on the ast that searches for unsafe blocks, functions and implementations, as well as certain unsafe attributes. From 66882cfd049420490cf13828e895fd727e1a5184 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 18:11:12 +0200 Subject: [PATCH 21/28] add a pause (and remove redundant word) --- src/doc/rustc-dev-guide/src/unsafety-checking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/unsafety-checking.md b/src/doc/rustc-dev-guide/src/unsafety-checking.md index 2a0811951b275..5f80c30a431e2 100644 --- a/src/doc/rustc-dev-guide/src/unsafety-checking.md +++ b/src/doc/rustc-dev-guide/src/unsafety-checking.md @@ -10,8 +10,8 @@ The unsafety check is located in the [`check_unsafety`] module. It performs a walk over the [THIR] of a function and all of its closures and inline constants. It keeps track of the unsafe context: whether it has entered an `unsafe` block. If an unsafe operation is used outside of an `unsafe` block, then an error is reported. -If an unsafe operation is used in an unsafe block then that block is -marked as used for [the unused_unsafe lint](#the-unused_unsafe-lint). +If an unsafe operation is used in an unsafe block, +that block is marked as used for [the unused_unsafe lint](#the-unused_unsafe-lint). The unsafety check needs type information so could potentially be done on the HIR, making use of typeck results, THIR or MIR. From 22066538aa9f3c124dffcadbf88dabfe4165bc60 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 18:14:30 +0200 Subject: [PATCH 22/28] add some pauses --- src/doc/rustc-dev-guide/src/unsafety-checking.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/unsafety-checking.md b/src/doc/rustc-dev-guide/src/unsafety-checking.md index 5f80c30a431e2..d1a3ddb138505 100644 --- a/src/doc/rustc-dev-guide/src/unsafety-checking.md +++ b/src/doc/rustc-dev-guide/src/unsafety-checking.md @@ -13,13 +13,14 @@ If an unsafe operation is used outside of an `unsafe` block, then an error is re If an unsafe operation is used in an unsafe block, that block is marked as used for [the unused_unsafe lint](#the-unused_unsafe-lint). -The unsafety check needs type information so could potentially be done on the +The unsafety check needs type information, so could potentially be done on the HIR, making use of typeck results, THIR or MIR. THIR is chosen because there are fewer cases to consider than in HIR, for example unsafe function calls and unsafe method calls have the same representation in THIR. -The check is not done on MIR because safety checks do not depend on control flow so MIR is not -necessary to use and MIR doesn't have as precise spans for some expressions. +The check is not done on MIR because safety checks do not depend on control flow, +so MIR is not necessary to use, +and MIR doesn't have as precise spans for some expressions. Most unsafe operations can be identified by checking the `ExprKind` in THIR and checking the type of the argument. From 1eb7b460da28b54009e15697dd82a7feafdca19e Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 18:16:31 +0200 Subject: [PATCH 23/28] replace awkward wording --- src/doc/rustc-dev-guide/src/unsafety-checking.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/unsafety-checking.md b/src/doc/rustc-dev-guide/src/unsafety-checking.md index d1a3ddb138505..fcdd4a8236b5d 100644 --- a/src/doc/rustc-dev-guide/src/unsafety-checking.md +++ b/src/doc/rustc-dev-guide/src/unsafety-checking.md @@ -19,8 +19,8 @@ THIR is chosen because there are fewer cases to consider than in HIR, for example unsafe function calls and unsafe method calls have the same representation in THIR. The check is not done on MIR because safety checks do not depend on control flow, -so MIR is not necessary to use, -and MIR doesn't have as precise spans for some expressions. +so there is no need to use MIR. +Also, MIR doesn't have precise enough spans for some expressions. Most unsafe operations can be identified by checking the `ExprKind` in THIR and checking the type of the argument. From e2b66ef351fb230fd7cbd6d6ce83966e2d8da6f7 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sat, 9 May 2026 01:27:23 +0900 Subject: [PATCH 24/28] add regression test for unicode dotdotdot rest pattern --- .../dotdotdot-rest-pattern-suggestion-span.rs | 20 ++++ ...dotdot-rest-pattern-suggestion-span.stderr | 110 ++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.rs create mode 100644 tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.stderr diff --git a/tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.rs b/tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.rs new file mode 100644 index 0000000000000..0db10726c5dc4 --- /dev/null +++ b/tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.rs @@ -0,0 +1,20 @@ +// Suggestions for `...` in patterns should not perform span manipulations that +// assume the token is ASCII, because it could have been recovered from +// similar-looking Unicode characters. +// +// Regression test for https://github.com/rust-lang/rust/issues/156316. + +// These dots are U+00B7 MIDDLE DOT, not ASCII periods. +impl S { fn f(···>) } +//~^ ERROR unknown start of token +//~| ERROR unknown start of token +//~| ERROR unknown start of token +//~| ERROR unexpected `...` +//~| ERROR expected `:`, found `>` +//~| ERROR expected one of +//~| ERROR associated function in `impl` without body +//~| ERROR cannot find type `S` in this scope +//~| ERROR missing pattern for `...` argument +//~| WARN this was previously accepted by the compiler + +fn main() {} diff --git a/tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.stderr b/tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.stderr new file mode 100644 index 0000000000000..d483c40ca5e0b --- /dev/null +++ b/tests/ui/parser/dotdotdot-rest-pattern-suggestion-span.stderr @@ -0,0 +1,110 @@ +error: unknown start of token: \u{b7} + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:15 + | +LL | impl S { fn f(···>) } + | ^^^ + | + = note: character appears 2 more times +help: Unicode character '·' (Middle Dot) looks like '.' (Period), but it is not + | +LL - impl S { fn f(···>) } +LL + impl S { fn f(...>) } + | + +error: unknown start of token: \u{b7} + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:16 + | +LL | impl S { fn f(···>) } + | ^^ + | + = note: character appears once more +help: Unicode character '·' (Middle Dot) looks like '.' (Period), but it is not + | +LL - impl S { fn f(···>) } +LL + impl S { fn f(·..>) } + | + +error: unknown start of token: \u{b7} + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:17 + | +LL | impl S { fn f(···>) } + | ^ + | +help: Unicode character '·' (Middle Dot) looks like '.' (Period), but it is not + | +LL - impl S { fn f(···>) } +LL + impl S { fn f(··.>) } + | + +error: unexpected `...` + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:15 + | +LL | impl S { fn f(···>) } + | ^^^ not a valid pattern + | +help: for a rest pattern, use `..` instead of `...` + | +LL - impl S { fn f(···>) } +LL + impl S { fn f(..>) } + | + +error: expected `:`, found `>` + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:18 + | +LL | impl S { fn f(···>) } + | ^ expected `:` + +error: expected one of `->`, `where`, or `{`, found `}` + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:21 + | +LL | impl S { fn f(···>) } + | - ^ expected one of `->`, `where`, or `{` + | | + | while parsing this `fn` + +error: associated function in `impl` without body + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:10 + | +LL | impl S { fn f(···>) } + | ^^^^^^^^^^- help: provide a definition for the function: `{ }` + +error[E0425]: cannot find type `S` in this scope + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:6 + | +LL | impl S { fn f(···>) } + | ^ not found in this scope + +error: missing pattern for `...` argument + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:15 + | +LL | impl S { fn f(···>) } + | ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #145544 + = note: `#[deny(varargs_without_pattern)]` (part of `#[deny(future_incompatible)]`) on by default +help: name the argument, or use `_` to continue ignoring it + | +LL - impl S { fn f(···>) } +LL + impl S { fn f(_: ...>) } + | + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0425`. +Future incompatibility report: Future breakage diagnostic: +error: missing pattern for `...` argument + --> $DIR/dotdotdot-rest-pattern-suggestion-span.rs:8:15 + | +LL | impl S { fn f(···>) } + | ^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #145544 + = note: `#[deny(varargs_without_pattern)]` (part of `#[deny(future_incompatible)]`) on by default +help: name the argument, or use `_` to continue ignoring it + | +LL - impl S { fn f(···>) } +LL + impl S { fn f(_: ...>) } + | + From 431017bb5589263e34447091329242e225038cbc Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sat, 9 May 2026 01:27:40 +0900 Subject: [PATCH 25/28] avoid byte slicing in dotdotdot rest pattern suggestion --- compiler/rustc_parse/src/errors.rs | 2 +- compiler/rustc_parse/src/parser/pat.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 4043b9bca61c5..12dc35d29ad9f 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -3238,7 +3238,7 @@ pub(crate) struct DotDotDotRestPattern { #[suggestion( "for a rest pattern, use `..` instead of `...`", style = "verbose", - code = "", + code = "..", applicability = "machine-applicable" )] pub suggestion: Option, diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 4e6d76fefd9c2..b8718b503df26 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -920,7 +920,7 @@ impl<'a> Parser<'a> { // The user probably mistook `...` for a rest pattern `..`. self.dcx().emit_err(DotDotDotRestPattern { span: lo, - suggestion: Some(lo.with_lo(lo.hi() - BytePos(1))), + suggestion: Some(lo), var_args: None, }); PatKind::Rest From f3fb5712038252e9dcc850c020870c88a8ab13c4 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 20:01:25 +0200 Subject: [PATCH 26/28] line reflow is not part of sembr compliance --- src/doc/rustc-dev-guide/ci/sembr/src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs index 4038f112d59fd..b9d659d40d365 100644 --- a/src/doc/rustc-dev-guide/ci/sembr/src/main.rs +++ b/src/doc/rustc-dev-guide/ci/sembr/src/main.rs @@ -45,14 +45,16 @@ fn main() -> Result<()> { continue; } let old = fs::read_to_string(&path)?; - let new = lengthen_lines(&comply(&old), cli.line_length_limit); + let new = comply(&old); if new == old { compliant.push(path.clone()); - } else if cli.overwrite { - fs::write(&path, new)?; - made_compliant.push(path.clone()); } else { - not_compliant.push(path.clone()); + if cli.overwrite { + fs::write(&path, lengthen_lines(&new, cli.line_length_limit))?; + made_compliant.push(path.clone()); + } else { + not_compliant.push(path.clone()); + } } } } From a99347980b5eadb10edc710669029f6b74d0f94d Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 20:02:28 +0200 Subject: [PATCH 27/28] sembr src/building/build-install-distribution-artifacts.md --- .../src/building/build-install-distribution-artifacts.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md b/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md index 9e7acda8fa5c4..b51f248300057 100644 --- a/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md +++ b/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md @@ -10,7 +10,8 @@ You’ll want to run this command to do it: # Install from source You might want to prefer installing Rust (and tools configured in your configuration) -by building from source. If so, you want to run this command: +by building from source. +If so, you want to run this command: ```bash ./x install @@ -24,8 +25,9 @@ by building from source. If so, you want to run this command: invoke it with `rustc +foo ...` (where ... represents the rest of the arguments). Instead of installing Rust (and tools in your config file) globally, you can set `DESTDIR` -environment variable to change the installation path. If you want to set installation paths +environment variable to change the installation path. +If you want to set installation paths more dynamically, you should prefer [install options] in your config file to achieve that. [create-rustup-toolchain]: ./how-to-build-and-run.md#creating-a-rustup-toolchain -[install options]: https://github.com/rust-lang/rust/blob/f7c8928f035370be33463bb7f1cd1aeca2c5f898/config.example.toml#L422-L442 \ No newline at end of file +[install options]: https://github.com/rust-lang/rust/blob/f7c8928f035370be33463bb7f1cd1aeca2c5f898/config.example.toml#L422-L442 From fb8270db7daab7a79a82ff7295604a88d58c421f Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 8 May 2026 20:04:02 +0200 Subject: [PATCH 28/28] use a more correct code marker --- .../src/building/build-install-distribution-artifacts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md b/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md index b51f248300057..5a4823127dc8c 100644 --- a/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md +++ b/src/doc/rustc-dev-guide/src/building/build-install-distribution-artifacts.md @@ -3,7 +3,7 @@ You might want to build and package up the compiler for distribution. You’ll want to run this command to do it: -```bash +```console ./x dist ``` @@ -13,7 +13,7 @@ You might want to prefer installing Rust (and tools configured in your configura by building from source. If so, you want to run this command: -```bash +```console ./x install ```