From 54875f68359ca79638b84420d9d9ca4af0e47909 Mon Sep 17 00:00:00 2001 From: Alex Macleod Date: Sat, 14 Feb 2026 17:14:51 +0000 Subject: [PATCH 1/8] Provide all lint group names to Clippy Unblocks https://github.com/rust-lang/rust-clippy/pull/14689 --- compiler/rustc_lint/src/context.rs | 5 +++++ .../clippy/clippy_lints/src/cargo/lint_groups_priority.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 19f3a9b4c062e..561bdd1a2db67 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -154,6 +154,11 @@ impl LintStore { }) } + /// Returns all lint group names, including deprecated/aliased groups + pub fn get_all_group_names(&self) -> impl Iterator { + self.lint_groups.keys().copied() + } + pub fn register_early_pass( &mut self, pass: impl Fn() -> EarlyLintPassObject + 'static + sync::DynSend + sync::DynSync, diff --git a/src/tools/clippy/clippy_lints/src/cargo/lint_groups_priority.rs b/src/tools/clippy/clippy_lints/src/cargo/lint_groups_priority.rs index f937f065d6e0d..fbf5f72c53615 100644 --- a/src/tools/clippy/clippy_lints/src/cargo/lint_groups_priority.rs +++ b/src/tools/clippy/clippy_lints/src/cargo/lint_groups_priority.rs @@ -135,7 +135,7 @@ pub fn check(cx: &LateContext<'_>) { { let mut rustc_groups = FxHashSet::default(); let mut clippy_groups = FxHashSet::default(); - for (group, ..) in unerased_lint_store(cx.tcx.sess).get_lint_groups() { + for group in unerased_lint_store(cx.tcx.sess).get_all_group_names() { match group.split_once("::") { None => { rustc_groups.insert(group); From abca0d5f74217d9f8917cf366463ff83562cbe17 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 8 Feb 2026 12:28:18 +0000 Subject: [PATCH 2/8] Move dynamically-sized-types tests into dst dir --- tests/ui/README.md | 4 ---- .../{dynamically-sized-types => dst}/dst-coerce-custom.rs | 0 .../ui/{dynamically-sized-types => dst}/dst-coerce-rc.rs | 0 .../ui/{dynamically-sized-types => dst}/dst-coercions.rs | 0 .../{dynamically-sized-types => dst}/dst-coercions.stderr | 0 .../ui/{dynamically-sized-types => dst}/dst-deref-mut.rs | 0 tests/ui/{dynamically-sized-types => dst}/dst-deref.rs | 0 .../{dynamically-sized-types => dst}/dst-field-align.rs | 0 tests/ui/dst/{dst-index.rs => dst-index-fail.rs} | 0 tests/ui/dst/{dst-index.stderr => dst-index-fail.stderr} | 8 ++++---- .../dst-index.rs => dst/dst-index-success.rs} | 0 .../dst-irrefutable-bind.rs | 0 tests/ui/{dynamically-sized-types => dst}/dst-raw.rs | 0 .../{dynamically-sized-types => dst}/dst-struct-sole.rs | 0 tests/ui/{dynamically-sized-types => dst}/dst-struct.rs | 0 tests/ui/{dynamically-sized-types => dst}/dst-trait.rs | 0 16 files changed, 4 insertions(+), 8 deletions(-) rename tests/ui/{dynamically-sized-types => dst}/dst-coerce-custom.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-coerce-rc.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-coercions.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-coercions.stderr (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-deref-mut.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-deref.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-field-align.rs (100%) rename tests/ui/dst/{dst-index.rs => dst-index-fail.rs} (100%) rename tests/ui/dst/{dst-index.stderr => dst-index-fail.stderr} (85%) rename tests/ui/{dynamically-sized-types/dst-index.rs => dst/dst-index-success.rs} (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-irrefutable-bind.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-raw.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-struct-sole.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-struct.rs (100%) rename tests/ui/{dynamically-sized-types => dst}/dst-trait.rs (100%) diff --git a/tests/ui/README.md b/tests/ui/README.md index 237cfb9c4f071..612661dae907a 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -518,10 +518,6 @@ The `dyn` keyword is used to highlight that calls to methods on the associated T See [`dyn` keyword](https://doc.rust-lang.org/std/keyword.dyn.html). -## `tests/ui/dynamically-sized-types`: Dynamically Sized Types - -**FIXME**: should be coalesced with `tests/ui/dst`. - ## `tests/ui/editions/`: Rust edition-specific peculiarities These tests run in specific Rust editions, such as Rust 2015 or Rust 2018, and check errors and functionality related to specific now-deprecated idioms and features. diff --git a/tests/ui/dynamically-sized-types/dst-coerce-custom.rs b/tests/ui/dst/dst-coerce-custom.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-coerce-custom.rs rename to tests/ui/dst/dst-coerce-custom.rs diff --git a/tests/ui/dynamically-sized-types/dst-coerce-rc.rs b/tests/ui/dst/dst-coerce-rc.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-coerce-rc.rs rename to tests/ui/dst/dst-coerce-rc.rs diff --git a/tests/ui/dynamically-sized-types/dst-coercions.rs b/tests/ui/dst/dst-coercions.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-coercions.rs rename to tests/ui/dst/dst-coercions.rs diff --git a/tests/ui/dynamically-sized-types/dst-coercions.stderr b/tests/ui/dst/dst-coercions.stderr similarity index 100% rename from tests/ui/dynamically-sized-types/dst-coercions.stderr rename to tests/ui/dst/dst-coercions.stderr diff --git a/tests/ui/dynamically-sized-types/dst-deref-mut.rs b/tests/ui/dst/dst-deref-mut.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-deref-mut.rs rename to tests/ui/dst/dst-deref-mut.rs diff --git a/tests/ui/dynamically-sized-types/dst-deref.rs b/tests/ui/dst/dst-deref.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-deref.rs rename to tests/ui/dst/dst-deref.rs diff --git a/tests/ui/dynamically-sized-types/dst-field-align.rs b/tests/ui/dst/dst-field-align.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-field-align.rs rename to tests/ui/dst/dst-field-align.rs diff --git a/tests/ui/dst/dst-index.rs b/tests/ui/dst/dst-index-fail.rs similarity index 100% rename from tests/ui/dst/dst-index.rs rename to tests/ui/dst/dst-index-fail.rs diff --git a/tests/ui/dst/dst-index.stderr b/tests/ui/dst/dst-index-fail.stderr similarity index 85% rename from tests/ui/dst/dst-index.stderr rename to tests/ui/dst/dst-index-fail.stderr index d38af3f89c21b..a5481e9ad6735 100644 --- a/tests/ui/dst/dst-index.stderr +++ b/tests/ui/dst/dst-index-fail.stderr @@ -1,23 +1,23 @@ error[E0161]: cannot move a value of type `str` - --> $DIR/dst-index.rs:31:5 + --> $DIR/dst-index-fail.rs:31:5 | LL | S[0]; | ^^^^ the size of `str` cannot be statically determined error[E0161]: cannot move a value of type `dyn Debug` - --> $DIR/dst-index.rs:34:5 + --> $DIR/dst-index-fail.rs:34:5 | LL | T[0]; | ^^^^ the size of `dyn Debug` cannot be statically determined error[E0507]: cannot move out of index of `S` - --> $DIR/dst-index.rs:31:5 + --> $DIR/dst-index-fail.rs:31:5 | LL | S[0]; | ^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait error[E0507]: cannot move out of index of `T` - --> $DIR/dst-index.rs:34:5 + --> $DIR/dst-index-fail.rs:34:5 | LL | T[0]; | ^^^^ move occurs because value has type `dyn Debug`, which does not implement the `Copy` trait diff --git a/tests/ui/dynamically-sized-types/dst-index.rs b/tests/ui/dst/dst-index-success.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-index.rs rename to tests/ui/dst/dst-index-success.rs diff --git a/tests/ui/dynamically-sized-types/dst-irrefutable-bind.rs b/tests/ui/dst/dst-irrefutable-bind.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-irrefutable-bind.rs rename to tests/ui/dst/dst-irrefutable-bind.rs diff --git a/tests/ui/dynamically-sized-types/dst-raw.rs b/tests/ui/dst/dst-raw.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-raw.rs rename to tests/ui/dst/dst-raw.rs diff --git a/tests/ui/dynamically-sized-types/dst-struct-sole.rs b/tests/ui/dst/dst-struct-sole.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-struct-sole.rs rename to tests/ui/dst/dst-struct-sole.rs diff --git a/tests/ui/dynamically-sized-types/dst-struct.rs b/tests/ui/dst/dst-struct.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-struct.rs rename to tests/ui/dst/dst-struct.rs diff --git a/tests/ui/dynamically-sized-types/dst-trait.rs b/tests/ui/dst/dst-trait.rs similarity index 100% rename from tests/ui/dynamically-sized-types/dst-trait.rs rename to tests/ui/dst/dst-trait.rs From 161298831023272ae38bf62b0bb9f433b68abf8d Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 8 Feb 2026 12:38:25 +0000 Subject: [PATCH 3/8] Move underscore-imports tests into imports subdir --- src/tools/tidy/src/issues.txt | 1 - tests/ui/README.md | 6 ------ .../underscore-imports/auxiliary/duplicate.rs | 0 .../auxiliary/underscore-imports.rs | 0 tests/ui/{ => imports}/underscore-imports/basic.rs | 0 .../ui/{ => imports}/underscore-imports/basic.stderr | 0 tests/ui/{ => imports}/underscore-imports/cycle.rs | 0 .../ui/{ => imports}/underscore-imports/duplicate.rs | 0 .../ui/{ => imports}/underscore-imports/hygiene-2.rs | 0 tests/ui/{ => imports}/underscore-imports/hygiene.rs | 0 .../{ => imports}/underscore-imports/intercrate.rs | 0 .../invalid-path-110164.ed2015.stderr} | 12 ++++++------ .../invalid-path-110164.ed2021.stderr} | 12 ++++++------ .../underscore-imports/invalid-path-110164.rs} | 0 .../underscore-imports/macro-expanded.rs | 0 ...iple-extern-by-macro-for-underscore.ed2015.stderr | 0 ...iple-extern-by-macro-for-underscore.ed2021.stderr | 0 .../multiple-extern-by-macro-for-underscore.rs | 0 .../underscore-imports/multiple-uses.ed2015.stderr | 0 .../underscore-imports/multiple-uses.ed2021.stderr | 0 .../underscore-imports/multiple-uses.rs | 0 tests/ui/{ => imports}/underscore-imports/shadow.rs | 0 .../{ => imports}/underscore-imports/shadow.stderr | 0 .../{ => imports}/underscore-imports/unused-2018.rs | 0 .../underscore-imports/unused-2018.stderr | 0 25 files changed, 12 insertions(+), 19 deletions(-) rename tests/ui/{ => imports}/underscore-imports/auxiliary/duplicate.rs (100%) rename tests/ui/{ => imports}/underscore-imports/auxiliary/underscore-imports.rs (100%) rename tests/ui/{ => imports}/underscore-imports/basic.rs (100%) rename tests/ui/{ => imports}/underscore-imports/basic.stderr (100%) rename tests/ui/{ => imports}/underscore-imports/cycle.rs (100%) rename tests/ui/{ => imports}/underscore-imports/duplicate.rs (100%) rename tests/ui/{ => imports}/underscore-imports/hygiene-2.rs (100%) rename tests/ui/{ => imports}/underscore-imports/hygiene.rs (100%) rename tests/ui/{ => imports}/underscore-imports/intercrate.rs (100%) rename tests/ui/{underscore-imports/issue-110164.ed2015.stderr => imports/underscore-imports/invalid-path-110164.ed2015.stderr} (79%) rename tests/ui/{underscore-imports/issue-110164.ed2021.stderr => imports/underscore-imports/invalid-path-110164.ed2021.stderr} (79%) rename tests/ui/{underscore-imports/issue-110164.rs => imports/underscore-imports/invalid-path-110164.rs} (100%) rename tests/ui/{ => imports}/underscore-imports/macro-expanded.rs (100%) rename tests/ui/imports/{ => underscore-imports}/multiple-extern-by-macro-for-underscore.ed2015.stderr (100%) rename tests/ui/imports/{ => underscore-imports}/multiple-extern-by-macro-for-underscore.ed2021.stderr (100%) rename tests/ui/imports/{ => underscore-imports}/multiple-extern-by-macro-for-underscore.rs (100%) rename tests/ui/{ => imports}/underscore-imports/multiple-uses.ed2015.stderr (100%) rename tests/ui/{ => imports}/underscore-imports/multiple-uses.ed2021.stderr (100%) rename tests/ui/{ => imports}/underscore-imports/multiple-uses.rs (100%) rename tests/ui/{ => imports}/underscore-imports/shadow.rs (100%) rename tests/ui/{ => imports}/underscore-imports/shadow.stderr (100%) rename tests/ui/{ => imports}/underscore-imports/unused-2018.rs (100%) rename tests/ui/{ => imports}/underscore-imports/unused-2018.stderr (100%) diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index c747636691f60..295cf228815e6 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -2978,7 +2978,6 @@ ui/unboxed-closures/issue-18652.rs ui/unboxed-closures/issue-18661.rs ui/unboxed-closures/issue-30906.rs ui/unboxed-closures/issue-53448.rs -ui/underscore-imports/issue-110164.rs ui/uniform-paths/auxiliary/issue-53691.rs ui/uniform-paths/issue-53691.rs ui/uninhabited/issue-107505.rs diff --git a/tests/ui/README.md b/tests/ui/README.md index 612661dae907a..faf1721e0b033 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -1526,12 +1526,6 @@ See [RFC 0132 Unified Function Call Syntax](https://github.com/rust-lang/rfcs/bl See [Tracking issue for Fn traits (`unboxed_closures` & `fn_traits` feature)](https://github.com/rust-lang/rust/issues/29625). -## `tests/ui/underscore-imports/` - -See [Underscore imports | Reference](https://doc.rust-lang.org/reference/items/use-declarations.html#underscore-imports). - -**FIXME**: should become a subdirectory of `tests/ui/imports/`. - ## `tests/ui/underscore-lifetime/`: `'_` elided lifetime Exercises [anonymous elided lifetimes](https://doc.rust-lang.org/reference/lifetime-elision.html). diff --git a/tests/ui/underscore-imports/auxiliary/duplicate.rs b/tests/ui/imports/underscore-imports/auxiliary/duplicate.rs similarity index 100% rename from tests/ui/underscore-imports/auxiliary/duplicate.rs rename to tests/ui/imports/underscore-imports/auxiliary/duplicate.rs diff --git a/tests/ui/underscore-imports/auxiliary/underscore-imports.rs b/tests/ui/imports/underscore-imports/auxiliary/underscore-imports.rs similarity index 100% rename from tests/ui/underscore-imports/auxiliary/underscore-imports.rs rename to tests/ui/imports/underscore-imports/auxiliary/underscore-imports.rs diff --git a/tests/ui/underscore-imports/basic.rs b/tests/ui/imports/underscore-imports/basic.rs similarity index 100% rename from tests/ui/underscore-imports/basic.rs rename to tests/ui/imports/underscore-imports/basic.rs diff --git a/tests/ui/underscore-imports/basic.stderr b/tests/ui/imports/underscore-imports/basic.stderr similarity index 100% rename from tests/ui/underscore-imports/basic.stderr rename to tests/ui/imports/underscore-imports/basic.stderr diff --git a/tests/ui/underscore-imports/cycle.rs b/tests/ui/imports/underscore-imports/cycle.rs similarity index 100% rename from tests/ui/underscore-imports/cycle.rs rename to tests/ui/imports/underscore-imports/cycle.rs diff --git a/tests/ui/underscore-imports/duplicate.rs b/tests/ui/imports/underscore-imports/duplicate.rs similarity index 100% rename from tests/ui/underscore-imports/duplicate.rs rename to tests/ui/imports/underscore-imports/duplicate.rs diff --git a/tests/ui/underscore-imports/hygiene-2.rs b/tests/ui/imports/underscore-imports/hygiene-2.rs similarity index 100% rename from tests/ui/underscore-imports/hygiene-2.rs rename to tests/ui/imports/underscore-imports/hygiene-2.rs diff --git a/tests/ui/underscore-imports/hygiene.rs b/tests/ui/imports/underscore-imports/hygiene.rs similarity index 100% rename from tests/ui/underscore-imports/hygiene.rs rename to tests/ui/imports/underscore-imports/hygiene.rs diff --git a/tests/ui/underscore-imports/intercrate.rs b/tests/ui/imports/underscore-imports/intercrate.rs similarity index 100% rename from tests/ui/underscore-imports/intercrate.rs rename to tests/ui/imports/underscore-imports/intercrate.rs diff --git a/tests/ui/underscore-imports/issue-110164.ed2015.stderr b/tests/ui/imports/underscore-imports/invalid-path-110164.ed2015.stderr similarity index 79% rename from tests/ui/underscore-imports/issue-110164.ed2015.stderr rename to tests/ui/imports/underscore-imports/invalid-path-110164.ed2015.stderr index f34b5ab5dde74..e023ec58d1adf 100644 --- a/tests/ui/underscore-imports/issue-110164.ed2015.stderr +++ b/tests/ui/imports/underscore-imports/invalid-path-110164.ed2015.stderr @@ -1,35 +1,35 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:8:5 + --> $DIR/invalid-path-110164.rs:8:5 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:10:5 + --> $DIR/invalid-path-110164.rs:10:5 | LL | use _::*; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:14:9 + --> $DIR/invalid-path-110164.rs:14:9 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:16:9 + --> $DIR/invalid-path-110164.rs:16:9 | LL | use _::*; | ^ expected identifier, found reserved identifier error[E0432]: unresolved import `self::*` - --> $DIR/issue-110164.rs:4:5 + --> $DIR/invalid-path-110164.rs:4:5 | LL | use self::*; | ^^^^^^^ cannot glob-import a module into itself error[E0432]: unresolved import `crate::*` - --> $DIR/issue-110164.rs:6:5 + --> $DIR/invalid-path-110164.rs:6:5 | LL | use crate::*; | ^^^^^^^^ cannot glob-import a module into itself diff --git a/tests/ui/underscore-imports/issue-110164.ed2021.stderr b/tests/ui/imports/underscore-imports/invalid-path-110164.ed2021.stderr similarity index 79% rename from tests/ui/underscore-imports/issue-110164.ed2021.stderr rename to tests/ui/imports/underscore-imports/invalid-path-110164.ed2021.stderr index f34b5ab5dde74..e023ec58d1adf 100644 --- a/tests/ui/underscore-imports/issue-110164.ed2021.stderr +++ b/tests/ui/imports/underscore-imports/invalid-path-110164.ed2021.stderr @@ -1,35 +1,35 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:8:5 + --> $DIR/invalid-path-110164.rs:8:5 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:10:5 + --> $DIR/invalid-path-110164.rs:10:5 | LL | use _::*; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:14:9 + --> $DIR/invalid-path-110164.rs:14:9 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:16:9 + --> $DIR/invalid-path-110164.rs:16:9 | LL | use _::*; | ^ expected identifier, found reserved identifier error[E0432]: unresolved import `self::*` - --> $DIR/issue-110164.rs:4:5 + --> $DIR/invalid-path-110164.rs:4:5 | LL | use self::*; | ^^^^^^^ cannot glob-import a module into itself error[E0432]: unresolved import `crate::*` - --> $DIR/issue-110164.rs:6:5 + --> $DIR/invalid-path-110164.rs:6:5 | LL | use crate::*; | ^^^^^^^^ cannot glob-import a module into itself diff --git a/tests/ui/underscore-imports/issue-110164.rs b/tests/ui/imports/underscore-imports/invalid-path-110164.rs similarity index 100% rename from tests/ui/underscore-imports/issue-110164.rs rename to tests/ui/imports/underscore-imports/invalid-path-110164.rs diff --git a/tests/ui/underscore-imports/macro-expanded.rs b/tests/ui/imports/underscore-imports/macro-expanded.rs similarity index 100% rename from tests/ui/underscore-imports/macro-expanded.rs rename to tests/ui/imports/underscore-imports/macro-expanded.rs diff --git a/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2015.stderr b/tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2015.stderr similarity index 100% rename from tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2015.stderr rename to tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2015.stderr diff --git a/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr b/tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2021.stderr similarity index 100% rename from tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr rename to tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.ed2021.stderr diff --git a/tests/ui/imports/multiple-extern-by-macro-for-underscore.rs b/tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.rs similarity index 100% rename from tests/ui/imports/multiple-extern-by-macro-for-underscore.rs rename to tests/ui/imports/underscore-imports/multiple-extern-by-macro-for-underscore.rs diff --git a/tests/ui/underscore-imports/multiple-uses.ed2015.stderr b/tests/ui/imports/underscore-imports/multiple-uses.ed2015.stderr similarity index 100% rename from tests/ui/underscore-imports/multiple-uses.ed2015.stderr rename to tests/ui/imports/underscore-imports/multiple-uses.ed2015.stderr diff --git a/tests/ui/underscore-imports/multiple-uses.ed2021.stderr b/tests/ui/imports/underscore-imports/multiple-uses.ed2021.stderr similarity index 100% rename from tests/ui/underscore-imports/multiple-uses.ed2021.stderr rename to tests/ui/imports/underscore-imports/multiple-uses.ed2021.stderr diff --git a/tests/ui/underscore-imports/multiple-uses.rs b/tests/ui/imports/underscore-imports/multiple-uses.rs similarity index 100% rename from tests/ui/underscore-imports/multiple-uses.rs rename to tests/ui/imports/underscore-imports/multiple-uses.rs diff --git a/tests/ui/underscore-imports/shadow.rs b/tests/ui/imports/underscore-imports/shadow.rs similarity index 100% rename from tests/ui/underscore-imports/shadow.rs rename to tests/ui/imports/underscore-imports/shadow.rs diff --git a/tests/ui/underscore-imports/shadow.stderr b/tests/ui/imports/underscore-imports/shadow.stderr similarity index 100% rename from tests/ui/underscore-imports/shadow.stderr rename to tests/ui/imports/underscore-imports/shadow.stderr diff --git a/tests/ui/underscore-imports/unused-2018.rs b/tests/ui/imports/underscore-imports/unused-2018.rs similarity index 100% rename from tests/ui/underscore-imports/unused-2018.rs rename to tests/ui/imports/underscore-imports/unused-2018.rs diff --git a/tests/ui/underscore-imports/unused-2018.stderr b/tests/ui/imports/underscore-imports/unused-2018.stderr similarity index 100% rename from tests/ui/underscore-imports/unused-2018.stderr rename to tests/ui/imports/underscore-imports/unused-2018.stderr From 863caf8b6b776f684bda74657d4f05a34d935549 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 8 Feb 2026 12:56:06 +0000 Subject: [PATCH 4/8] Move btreemap, hashmap tests into collections subdir --- tests/ui/README.md | 12 +----------- .../btreemap/btreemap-index-mut-2.rs | 0 .../btreemap/btreemap-index-mut-2.stderr | 0 .../{ => collections}/btreemap/btreemap-index-mut.rs | 0 .../btreemap/btreemap-index-mut.stderr | 0 .../ui/{ => collections}/btreemap/btreemap_dropck.rs | 0 .../btreemap/btreemap_dropck.stderr | 0 .../btreemap/btreemap_into_iterator_lifetime.rs | 0 .../hashmap/hashmap-capacity-overflow.rs | 0 .../{ => collections}/hashmap/hashmap-index-mut.rs | 0 .../hashmap/hashmap-index-mut.stderr | 0 .../hashmap/hashmap-iter-value-lifetime.rs | 0 .../hashmap/hashmap-iter-value-lifetime.stderr | 0 .../{ => collections}/hashmap/hashmap-lifetimes.rs | 0 .../hashmap/hashmap-lifetimes.stderr | 0 tests/ui/{ => collections}/hashmap/hashmap-memory.rs | 0 .../ui/{ => collections}/hashmap/hashmap-path-key.rs | 0 .../hashmap/hashset-enum-variant.rs | 0 .../ui/{ => collections}/hashmap/hashset_generics.rs | 0 .../hashmap/hashset_generics.stderr | 0 20 files changed, 1 insertion(+), 11 deletions(-) rename tests/ui/{ => collections}/btreemap/btreemap-index-mut-2.rs (100%) rename tests/ui/{ => collections}/btreemap/btreemap-index-mut-2.stderr (100%) rename tests/ui/{ => collections}/btreemap/btreemap-index-mut.rs (100%) rename tests/ui/{ => collections}/btreemap/btreemap-index-mut.stderr (100%) rename tests/ui/{ => collections}/btreemap/btreemap_dropck.rs (100%) rename tests/ui/{ => collections}/btreemap/btreemap_dropck.stderr (100%) rename tests/ui/{ => collections}/btreemap/btreemap_into_iterator_lifetime.rs (100%) rename tests/ui/{ => collections}/hashmap/hashmap-capacity-overflow.rs (100%) rename tests/ui/{ => collections}/hashmap/hashmap-index-mut.rs (100%) rename tests/ui/{ => collections}/hashmap/hashmap-index-mut.stderr (100%) rename tests/ui/{ => collections}/hashmap/hashmap-iter-value-lifetime.rs (100%) rename tests/ui/{ => collections}/hashmap/hashmap-iter-value-lifetime.stderr (100%) rename tests/ui/{ => collections}/hashmap/hashmap-lifetimes.rs (100%) rename tests/ui/{ => collections}/hashmap/hashmap-lifetimes.stderr (100%) rename tests/ui/{ => collections}/hashmap/hashmap-memory.rs (100%) rename tests/ui/{ => collections}/hashmap/hashmap-path-key.rs (100%) rename tests/ui/{ => collections}/hashmap/hashset-enum-variant.rs (100%) rename tests/ui/{ => collections}/hashmap/hashset_generics.rs (100%) rename tests/ui/{ => collections}/hashmap/hashset_generics.stderr (100%) diff --git a/tests/ui/README.md b/tests/ui/README.md index faf1721e0b033..947949ff7181e 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -172,10 +172,6 @@ See: - [`std::box::Boxed`](https://doc.rust-lang.org/std/boxed/struct.Box.html) - [Tracking issue for `box_patterns` feature #29641](https://github.com/rust-lang/rust/issues/29641) -## `tests/ui/btreemap/`: B-Tree Maps - -Tests focused on `BTreeMap` collections and their compiler interactions. E.g. collection patterns, iterator behavior, and trait implementations specific to `BTreeMap`. See [`std::collections::BTreeMap`](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html). - ## `tests/ui/builtin-superkinds/`: Built-in Trait Hierarchy Tests Tests for built-in trait hierarchy (Send, Sync, Sized, etc.) and their supertrait relationships. E.g. auto traits and marker trait constraints. @@ -262,12 +258,10 @@ This directory only contains one highly specific test. Other coinduction tests c ## `tests/ui/collections` -These tests exercise the `collections` library. +These tests exercise the `collections` library. For example, `BTreeMap` and `HashMap`. See [`std::collections`](https://doc.rust-lang.org/std/collections/index.html) -**FIXME**: consider merge with `tests/ui/btreemap` and `tests/ui/hashmap` - ## `tests/ui/command/`: `std::process::Command` This directory is actually for the standard library [`std::process::Command`](https://doc.rust-lang.org/std/process/struct.Command.html) type, where some tests are too difficult or inconvenient to write as unit tests or integration tests within the standard library itself. @@ -684,10 +678,6 @@ Tests on range patterns where one of the bounds is not a direct value. **FIXME**: Overlaps with `ui/range`. `impossible_range.rs` is particularly suspected to be a duplicate test. -## `tests/ui/hashmap/` - -Tests for the standard library collection [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html). - ## `tests/ui/higher-ranked/` Tests for higher-ranked trait bounds. diff --git a/tests/ui/btreemap/btreemap-index-mut-2.rs b/tests/ui/collections/btreemap/btreemap-index-mut-2.rs similarity index 100% rename from tests/ui/btreemap/btreemap-index-mut-2.rs rename to tests/ui/collections/btreemap/btreemap-index-mut-2.rs diff --git a/tests/ui/btreemap/btreemap-index-mut-2.stderr b/tests/ui/collections/btreemap/btreemap-index-mut-2.stderr similarity index 100% rename from tests/ui/btreemap/btreemap-index-mut-2.stderr rename to tests/ui/collections/btreemap/btreemap-index-mut-2.stderr diff --git a/tests/ui/btreemap/btreemap-index-mut.rs b/tests/ui/collections/btreemap/btreemap-index-mut.rs similarity index 100% rename from tests/ui/btreemap/btreemap-index-mut.rs rename to tests/ui/collections/btreemap/btreemap-index-mut.rs diff --git a/tests/ui/btreemap/btreemap-index-mut.stderr b/tests/ui/collections/btreemap/btreemap-index-mut.stderr similarity index 100% rename from tests/ui/btreemap/btreemap-index-mut.stderr rename to tests/ui/collections/btreemap/btreemap-index-mut.stderr diff --git a/tests/ui/btreemap/btreemap_dropck.rs b/tests/ui/collections/btreemap/btreemap_dropck.rs similarity index 100% rename from tests/ui/btreemap/btreemap_dropck.rs rename to tests/ui/collections/btreemap/btreemap_dropck.rs diff --git a/tests/ui/btreemap/btreemap_dropck.stderr b/tests/ui/collections/btreemap/btreemap_dropck.stderr similarity index 100% rename from tests/ui/btreemap/btreemap_dropck.stderr rename to tests/ui/collections/btreemap/btreemap_dropck.stderr diff --git a/tests/ui/btreemap/btreemap_into_iterator_lifetime.rs b/tests/ui/collections/btreemap/btreemap_into_iterator_lifetime.rs similarity index 100% rename from tests/ui/btreemap/btreemap_into_iterator_lifetime.rs rename to tests/ui/collections/btreemap/btreemap_into_iterator_lifetime.rs diff --git a/tests/ui/hashmap/hashmap-capacity-overflow.rs b/tests/ui/collections/hashmap/hashmap-capacity-overflow.rs similarity index 100% rename from tests/ui/hashmap/hashmap-capacity-overflow.rs rename to tests/ui/collections/hashmap/hashmap-capacity-overflow.rs diff --git a/tests/ui/hashmap/hashmap-index-mut.rs b/tests/ui/collections/hashmap/hashmap-index-mut.rs similarity index 100% rename from tests/ui/hashmap/hashmap-index-mut.rs rename to tests/ui/collections/hashmap/hashmap-index-mut.rs diff --git a/tests/ui/hashmap/hashmap-index-mut.stderr b/tests/ui/collections/hashmap/hashmap-index-mut.stderr similarity index 100% rename from tests/ui/hashmap/hashmap-index-mut.stderr rename to tests/ui/collections/hashmap/hashmap-index-mut.stderr diff --git a/tests/ui/hashmap/hashmap-iter-value-lifetime.rs b/tests/ui/collections/hashmap/hashmap-iter-value-lifetime.rs similarity index 100% rename from tests/ui/hashmap/hashmap-iter-value-lifetime.rs rename to tests/ui/collections/hashmap/hashmap-iter-value-lifetime.rs diff --git a/tests/ui/hashmap/hashmap-iter-value-lifetime.stderr b/tests/ui/collections/hashmap/hashmap-iter-value-lifetime.stderr similarity index 100% rename from tests/ui/hashmap/hashmap-iter-value-lifetime.stderr rename to tests/ui/collections/hashmap/hashmap-iter-value-lifetime.stderr diff --git a/tests/ui/hashmap/hashmap-lifetimes.rs b/tests/ui/collections/hashmap/hashmap-lifetimes.rs similarity index 100% rename from tests/ui/hashmap/hashmap-lifetimes.rs rename to tests/ui/collections/hashmap/hashmap-lifetimes.rs diff --git a/tests/ui/hashmap/hashmap-lifetimes.stderr b/tests/ui/collections/hashmap/hashmap-lifetimes.stderr similarity index 100% rename from tests/ui/hashmap/hashmap-lifetimes.stderr rename to tests/ui/collections/hashmap/hashmap-lifetimes.stderr diff --git a/tests/ui/hashmap/hashmap-memory.rs b/tests/ui/collections/hashmap/hashmap-memory.rs similarity index 100% rename from tests/ui/hashmap/hashmap-memory.rs rename to tests/ui/collections/hashmap/hashmap-memory.rs diff --git a/tests/ui/hashmap/hashmap-path-key.rs b/tests/ui/collections/hashmap/hashmap-path-key.rs similarity index 100% rename from tests/ui/hashmap/hashmap-path-key.rs rename to tests/ui/collections/hashmap/hashmap-path-key.rs diff --git a/tests/ui/hashmap/hashset-enum-variant.rs b/tests/ui/collections/hashmap/hashset-enum-variant.rs similarity index 100% rename from tests/ui/hashmap/hashset-enum-variant.rs rename to tests/ui/collections/hashmap/hashset-enum-variant.rs diff --git a/tests/ui/hashmap/hashset_generics.rs b/tests/ui/collections/hashmap/hashset_generics.rs similarity index 100% rename from tests/ui/hashmap/hashset_generics.rs rename to tests/ui/collections/hashmap/hashset_generics.rs diff --git a/tests/ui/hashmap/hashset_generics.stderr b/tests/ui/collections/hashmap/hashset_generics.stderr similarity index 100% rename from tests/ui/hashmap/hashset_generics.stderr rename to tests/ui/collections/hashmap/hashset_generics.stderr From 86f1affe5a3a7fe71bc8b59044522c3a6e479b03 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 8 Feb 2026 13:02:57 +0000 Subject: [PATCH 5/8] Move higher-ranked-trait-bounds tests into higher-ranked subdir --- tests/ui/README.md | 4 ---- .../trait-bounds}/higher-trait-bounds-ice-60218.rs | 4 +--- .../trait-bounds}/higher-trait-bounds-ice-60218.stderr | 6 +++--- 3 files changed, 4 insertions(+), 10 deletions(-) rename tests/ui/{higher-ranked-trait-bounds => higher-ranked/trait-bounds}/higher-trait-bounds-ice-60218.rs (81%) rename tests/ui/{higher-ranked-trait-bounds => higher-ranked/trait-bounds}/higher-trait-bounds-ice-60218.stderr (85%) diff --git a/tests/ui/README.md b/tests/ui/README.md index 947949ff7181e..5892083771d24 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -687,10 +687,6 @@ See: - [Higher-ranked trait bounds | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/traits/hrtb.html) - [Higher-ranked trait bounds | Nomicon](https://doc.rust-lang.org/nomicon/hrtb.html) -## `tests/ui/higher-ranked-trait-bounds` - -**FIXME**: move to `tests/ui/higher-ranked/trait-bounds` - ## `tests/ui/hygiene/` This seems to have been originally intended for "hygienic macros" - macros which work in all contexts, independent of what surrounds them. However, this category has grown into a mish-mash of many tests that may belong in the other directories. diff --git a/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.rs b/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.rs similarity index 81% rename from tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.rs rename to tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.rs index d1a4e09243ecf..d0d09f11a5748 100644 --- a/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.rs +++ b/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.rs @@ -1,6 +1,4 @@ -// https://github.com/rust-lang/rust/issues/60218 -// Regression test for #60218 -// +// Regression test for https://github.com/rust-lang/rust/issues/60218 // This was reported to cause ICEs. use std::iter::Map; diff --git a/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.stderr b/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr similarity index 85% rename from tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.stderr rename to tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr index 4c403bcbd601f..b02179f141251 100644 --- a/tests/ui/higher-ranked-trait-bounds/higher-trait-bounds-ice-60218.stderr +++ b/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `&u32: Foo` is not satisfied - --> $DIR/higher-trait-bounds-ice-60218.rs:19:19 + --> $DIR/higher-trait-bounds-ice-60218.rs:17:19 | LL | trigger_error(vec![], |x: &u32| x) | ------------- ^^^^^^ the trait `Foo` is not implemented for `&u32` @@ -7,12 +7,12 @@ LL | trigger_error(vec![], |x: &u32| x) | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/higher-trait-bounds-ice-60218.rs:8:1 + --> $DIR/higher-trait-bounds-ice-60218.rs:6:1 | LL | pub trait Foo {} | ^^^^^^^^^^^^^ note: required by a bound in `trigger_error` - --> $DIR/higher-trait-bounds-ice-60218.rs:14:72 + --> $DIR/higher-trait-bounds-ice-60218.rs:12:72 | LL | pub fn trigger_error(iterable: I, functor: F) | ------------- required by a bound in this function From c92f384eb111d0994bbbe984f503c6c6edfa8404 Mon Sep 17 00:00:00 2001 From: reddevilmidzy Date: Sun, 8 Feb 2026 13:09:08 +0000 Subject: [PATCH 6/8] Move meta tests to compiletest-self-test, bootstrap dir --- tests/ui/README.md | 6 ------ tests/ui/{meta => bootstrap}/no_std-extern-libc.rs | 0 tests/ui/{meta => compiletest-self-test}/auxiliary/env.rs | 0 .../{meta => compiletest-self-test}/dir.with.dots/test.rs | 0 .../expected-error-correct-rev.a.stderr | 0 .../expected-error-correct-rev.rs | 0 .../meta-expected-error-wrong-rev.a.stderr | 0 .../meta-expected-error-wrong-rev.rs | 0 tests/ui/{meta => compiletest-self-test}/revision-bad.rs | 0 tests/ui/{meta => compiletest-self-test}/revision-ok.rs | 0 tests/ui/{meta => compiletest-self-test}/rustc-env.rs | 0 11 files changed, 6 deletions(-) rename tests/ui/{meta => bootstrap}/no_std-extern-libc.rs (100%) rename tests/ui/{meta => compiletest-self-test}/auxiliary/env.rs (100%) rename tests/ui/{meta => compiletest-self-test}/dir.with.dots/test.rs (100%) rename tests/ui/{meta => compiletest-self-test}/expected-error-correct-rev.a.stderr (100%) rename tests/ui/{meta => compiletest-self-test}/expected-error-correct-rev.rs (100%) rename tests/ui/{meta => compiletest-self-test}/meta-expected-error-wrong-rev.a.stderr (100%) rename tests/ui/{meta => compiletest-self-test}/meta-expected-error-wrong-rev.rs (100%) rename tests/ui/{meta => compiletest-self-test}/revision-bad.rs (100%) rename tests/ui/{meta => compiletest-self-test}/revision-ok.rs (100%) rename tests/ui/{meta => compiletest-self-test}/rustc-env.rs (100%) diff --git a/tests/ui/README.md b/tests/ui/README.md index 5892083771d24..16cdde08431c0 100644 --- a/tests/ui/README.md +++ b/tests/ui/README.md @@ -909,12 +909,6 @@ See [Tracking issue for allowing overlapping implementations for marker trait #2 Broad category of tests on `match` constructs. -## `tests/ui/meta/`: Tests for compiletest itself - -These tests check the function of the UI test suite at large and Compiletest in itself. - -**FIXME**: This should absolutely be merged with `tests/ui/compiletest-self-test/`. - ## `tests/ui/methods/` A broad category for anything related to methods and method resolution. diff --git a/tests/ui/meta/no_std-extern-libc.rs b/tests/ui/bootstrap/no_std-extern-libc.rs similarity index 100% rename from tests/ui/meta/no_std-extern-libc.rs rename to tests/ui/bootstrap/no_std-extern-libc.rs diff --git a/tests/ui/meta/auxiliary/env.rs b/tests/ui/compiletest-self-test/auxiliary/env.rs similarity index 100% rename from tests/ui/meta/auxiliary/env.rs rename to tests/ui/compiletest-self-test/auxiliary/env.rs diff --git a/tests/ui/meta/dir.with.dots/test.rs b/tests/ui/compiletest-self-test/dir.with.dots/test.rs similarity index 100% rename from tests/ui/meta/dir.with.dots/test.rs rename to tests/ui/compiletest-self-test/dir.with.dots/test.rs diff --git a/tests/ui/meta/expected-error-correct-rev.a.stderr b/tests/ui/compiletest-self-test/expected-error-correct-rev.a.stderr similarity index 100% rename from tests/ui/meta/expected-error-correct-rev.a.stderr rename to tests/ui/compiletest-self-test/expected-error-correct-rev.a.stderr diff --git a/tests/ui/meta/expected-error-correct-rev.rs b/tests/ui/compiletest-self-test/expected-error-correct-rev.rs similarity index 100% rename from tests/ui/meta/expected-error-correct-rev.rs rename to tests/ui/compiletest-self-test/expected-error-correct-rev.rs diff --git a/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr b/tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.a.stderr similarity index 100% rename from tests/ui/meta/meta-expected-error-wrong-rev.a.stderr rename to tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.a.stderr diff --git a/tests/ui/meta/meta-expected-error-wrong-rev.rs b/tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.rs similarity index 100% rename from tests/ui/meta/meta-expected-error-wrong-rev.rs rename to tests/ui/compiletest-self-test/meta-expected-error-wrong-rev.rs diff --git a/tests/ui/meta/revision-bad.rs b/tests/ui/compiletest-self-test/revision-bad.rs similarity index 100% rename from tests/ui/meta/revision-bad.rs rename to tests/ui/compiletest-self-test/revision-bad.rs diff --git a/tests/ui/meta/revision-ok.rs b/tests/ui/compiletest-self-test/revision-ok.rs similarity index 100% rename from tests/ui/meta/revision-ok.rs rename to tests/ui/compiletest-self-test/revision-ok.rs diff --git a/tests/ui/meta/rustc-env.rs b/tests/ui/compiletest-self-test/rustc-env.rs similarity index 100% rename from tests/ui/meta/rustc-env.rs rename to tests/ui/compiletest-self-test/rustc-env.rs From fa753a46c15d9992eedb7b6cf9ac3da4044b45d2 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 13 Feb 2026 09:58:04 +0000 Subject: [PATCH 7/8] Remove code for ThinLTO from cg_gcc It was just a dummy implementation to workarround the fact that thin local lto is the default in rustc. By adding a thin_lto_supported thin local lto can be automatically disabled for cg_gcc, removing the need for this dummy implementation. This makes improvements to the LTO handling on the cg_ssa side a lot easier. --- compiler/rustc_codegen_gcc/src/back/lto.rs | 395 +----------------- compiler/rustc_codegen_gcc/src/lib.rs | 46 +- .../rustc_codegen_ssa/src/traits/backend.rs | 5 + compiler/rustc_interface/src/interface.rs | 1 + .../rustc_macros/src/diagnostics/message.rs | 1 + compiler/rustc_session/src/errors.rs | 4 + compiler/rustc_session/src/session.rs | 13 + 7 files changed, 56 insertions(+), 409 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/back/lto.rs b/compiler/rustc_codegen_gcc/src/back/lto.rs index 9a9040708ef89..a08e3dc0df87d 100644 --- a/compiler/rustc_codegen_gcc/src/back/lto.rs +++ b/compiler/rustc_codegen_gcc/src/back/lto.rs @@ -17,15 +17,13 @@ // /usr/bin/ld: warning: type of symbol `_RNvNvNvNvNtNtNtCsAj5i4SGTR7_3std4sync4mpmc5waker17current_thread_id5DUMMY7___getit5___KEY' changed from 1 to 6 in /tmp/ccKeUSiR.ltrans0.ltrans.o // /usr/bin/ld: warning: incremental linking of LTO and non-LTO objects; using -flinker-output=nolto-rel which will bypass whole program optimization // cSpell:enable -use std::ffi::{CStr, CString}; +use std::ffi::CString; use std::fs::{self, File}; use std::path::{Path, PathBuf}; -use std::sync::Arc; -use std::sync::atomic::Ordering; -use gccjit::{Context, OutputKind}; +use gccjit::OutputKind; use object::read::archive::ArchiveFile; -use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared}; +use rustc_codegen_ssa::back::lto::SerializedModule; use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, SharedEmitter}; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file}; @@ -33,15 +31,12 @@ use rustc_data_structures::memmap::Mmap; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_errors::{DiagCtxt, DiagCtxtHandle}; use rustc_log::tracing::info; -use rustc_middle::bug; -use rustc_middle::dep_graph::WorkProduct; use rustc_session::config::Lto; -use rustc_target::spec::RelocModel; use tempfile::{TempDir, tempdir}; use crate::back::write::save_temp_bitcode; use crate::errors::LtoBitcodeFromRlib; -use crate::{GccCodegenBackend, GccContext, LTO_SUPPORTED, LtoMode, SyncContext, to_gcc_opt_level}; +use crate::{GccCodegenBackend, GccContext, LtoMode, to_gcc_opt_level}; struct LtoData { // TODO(antoyo): use symbols_below_threshold. @@ -281,385 +276,3 @@ impl ModuleBufferMethods for ModuleBuffer { &[] } } - -/// Performs thin LTO by performing necessary global analysis and returning two -/// lists, one of the modules that need optimization and another for modules that -/// can simply be copied over from the incr. comp. cache. -pub(crate) fn run_thin( - cgcx: &CodegenContext, - prof: &SelfProfilerRef, - dcx: DiagCtxtHandle<'_>, - each_linked_rlib_for_lto: &[PathBuf], - modules: Vec<(String, ThinBuffer)>, - cached_modules: Vec<(SerializedModule, WorkProduct)>, -) -> (Vec>, Vec) { - let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx); - if cgcx.use_linker_plugin_lto { - unreachable!( - "We should never reach this case if the LTO step \ - is deferred to the linker" - ); - } - thin_lto( - cgcx, - prof, - dcx, - modules, - lto_data.upstream_modules, - lto_data.tmp_path, - cached_modules, - //<o_data.symbols_below_threshold, - ) -} - -pub(crate) fn prepare_thin(module: ModuleCodegen) -> (String, ThinBuffer) { - let name = module.name; - //let buffer = ThinBuffer::new(module.module_llvm.context, true); - let buffer = ThinBuffer::new(&module.module_llvm.context); - (name, buffer) -} - -/// Prepare "thin" LTO to get run on these modules. -/// -/// The general structure of ThinLTO is quite different from the structure of -/// "fat" LTO above. With "fat" LTO all LLVM modules in question are merged into -/// one giant LLVM module, and then we run more optimization passes over this -/// big module after internalizing most symbols. Thin LTO, on the other hand, -/// avoid this large bottleneck through more targeted optimization. -/// -/// At a high level Thin LTO looks like: -/// -/// 1. Prepare a "summary" of each LLVM module in question which describes -/// the values inside, cost of the values, etc. -/// 2. Merge the summaries of all modules in question into one "index" -/// 3. Perform some global analysis on this index -/// 4. For each module, use the index and analysis calculated previously to -/// perform local transformations on the module, for example inlining -/// small functions from other modules. -/// 5. Run thin-specific optimization passes over each module, and then code -/// generate everything at the end. -/// -/// The summary for each module is intended to be quite cheap, and the global -/// index is relatively quite cheap to create as well. As a result, the goal of -/// ThinLTO is to reduce the bottleneck on LTO and enable LTO to be used in more -/// situations. For example one cheap optimization is that we can parallelize -/// all codegen modules, easily making use of all the cores on a machine. -/// -/// With all that in mind, the function here is designed at specifically just -/// calculating the *index* for ThinLTO. This index will then be shared amongst -/// all of the `LtoModuleCodegen` units returned below and destroyed once -/// they all go out of scope. -fn thin_lto( - _cgcx: &CodegenContext, - prof: &SelfProfilerRef, - _dcx: DiagCtxtHandle<'_>, - modules: Vec<(String, ThinBuffer)>, - serialized_modules: Vec<(SerializedModule, CString)>, - tmp_path: TempDir, - cached_modules: Vec<(SerializedModule, WorkProduct)>, - //_symbols_below_threshold: &[String], -) -> (Vec>, Vec) { - let _timer = prof.generic_activity("LLVM_thin_lto_global_analysis"); - info!("going for that thin, thin LTO"); - - /*let green_modules: FxHashMap<_, _> = - cached_modules.iter().map(|(_, wp)| (wp.cgu_name.clone(), wp.clone())).collect();*/ - - let full_scope_len = modules.len() + serialized_modules.len() + cached_modules.len(); - let mut thin_buffers = Vec::with_capacity(modules.len()); - let mut module_names = Vec::with_capacity(full_scope_len); - //let mut thin_modules = Vec::with_capacity(full_scope_len); - - for (i, (name, buffer)) in modules.into_iter().enumerate() { - info!("local module: {} - {}", i, name); - let cname = CString::new(name.as_bytes()).unwrap(); - /*thin_modules.push(llvm::ThinLTOModule { - identifier: cname.as_ptr(), - data: buffer.data().as_ptr(), - len: buffer.data().len(), - });*/ - thin_buffers.push(buffer); - module_names.push(cname); - } - - // FIXME: All upstream crates are deserialized internally in the - // function below to extract their summary and modules. Note that - // unlike the loop above we *must* decode and/or read something - // here as these are all just serialized files on disk. An - // improvement, however, to make here would be to store the - // module summary separately from the actual module itself. Right - // now this is store in one large bitcode file, and the entire - // file is deflate-compressed. We could try to bypass some of the - // decompression by storing the index uncompressed and only - // lazily decompressing the bytecode if necessary. - // - // Note that truly taking advantage of this optimization will - // likely be further down the road. We'd have to implement - // incremental ThinLTO first where we could actually avoid - // looking at upstream modules entirely sometimes (the contents, - // we must always unconditionally look at the index). - let mut serialized = Vec::with_capacity(serialized_modules.len() + cached_modules.len()); - - let cached_modules = - cached_modules.into_iter().map(|(sm, wp)| (sm, CString::new(wp.cgu_name).unwrap())); - - for (module, name) in serialized_modules.into_iter().chain(cached_modules) { - info!("upstream or cached module {:?}", name); - /*thin_modules.push(llvm::ThinLTOModule { - identifier: name.as_ptr(), - data: module.data().as_ptr(), - len: module.data().len(), - });*/ - - match module { - SerializedModule::Local(_) => { - //let path = module_buffer.0.to_str().expect("path"); - //let my_path = PathBuf::from(path); - //let exists = my_path.exists(); - /*module.module_llvm.should_combine_object_files = true; - module - .module_llvm - .context - .add_driver_option(module_buffer.0.to_str().expect("path"));*/ - } - SerializedModule::FromRlib(_) => unimplemented!("from rlib"), - SerializedModule::FromUncompressedFile(_) => { - unimplemented!("from uncompressed file") - } - } - - serialized.push(module); - module_names.push(name); - } - - // Sanity check - //assert_eq!(thin_modules.len(), module_names.len()); - - // Delegate to the C++ bindings to create some data here. Once this is a - // tried-and-true interface we may wish to try to upstream some of this - // to LLVM itself, right now we reimplement a lot of what they do - // upstream... - /*let data = llvm::LLVMRustCreateThinLTOData( - thin_modules.as_ptr(), - thin_modules.len() as u32, - symbols_below_threshold.as_ptr(), - symbols_below_threshold.len() as u32, - ) - .ok_or_else(|| write::llvm_err(dcx, LlvmError::PrepareThinLtoContext))?; - */ - - let data = ThinData; //(Arc::new(tmp_path))/*(data)*/; - - info!("thin LTO data created"); - - /*let (key_map_path, prev_key_map, curr_key_map) = - if let Some(ref incr_comp_session_dir) = cgcx.incr_comp_session_dir { - let path = incr_comp_session_dir.join(THIN_LTO_KEYS_INCR_COMP_FILE_NAME); - // If the previous file was deleted, or we get an IO error - // reading the file, then we'll just use `None` as the - // prev_key_map, which will force the code to be recompiled. - let prev = - if path.exists() { ThinLTOKeysMap::load_from_file(&path).ok() } else { None }; - let curr = ThinLTOKeysMap::from_thin_lto_modules(&data, &thin_modules, &module_names); - (Some(path), prev, curr) - } - else { - // If we don't compile incrementally, we don't need to load the - // import data from LLVM. - assert!(green_modules.is_empty()); - let curr = ThinLTOKeysMap::default(); - (None, None, curr) - }; - info!("thin LTO cache key map loaded"); - info!("prev_key_map: {:#?}", prev_key_map); - info!("curr_key_map: {:#?}", curr_key_map);*/ - - // Throw our data in an `Arc` as we'll be sharing it across threads. We - // also put all memory referenced by the C++ data (buffers, ids, etc) - // into the arc as well. After this we'll create a thin module - // codegen per module in this data. - let shared = - Arc::new(ThinShared { data, thin_buffers, serialized_modules: serialized, module_names }); - - let copy_jobs = vec![]; - let mut opt_jobs = vec![]; - - info!("checking which modules can be-reused and which have to be re-optimized."); - for (module_index, module_name) in shared.module_names.iter().enumerate() { - let module_name = module_name_to_str(module_name); - /*if let (Some(prev_key_map), true) = - (prev_key_map.as_ref(), green_modules.contains_key(module_name)) - { - assert!(cgcx.incr_comp_session_dir.is_some()); - - // If a module exists in both the current and the previous session, - // and has the same LTO cache key in both sessions, then we can re-use it - if prev_key_map.keys.get(module_name) == curr_key_map.keys.get(module_name) { - let work_product = green_modules[module_name].clone(); - copy_jobs.push(work_product); - info!(" - {}: re-used", module_name); - assert!(cgcx.incr_comp_session_dir.is_some()); - continue; - } - }*/ - - info!(" - {}: re-compiled", module_name); - opt_jobs.push(ThinModule { shared: shared.clone(), idx: module_index }); - } - - // Save the current ThinLTO import information for the next compilation - // session, overwriting the previous serialized data (if any). - /*if let Some(path) = key_map_path { - if let Err(err) = curr_key_map.save_to_file(&path) { - return Err(write::llvm_err(dcx, LlvmError::WriteThinLtoKey { err })); - } - }*/ - - // NOTE: save the temporary directory used by LTO so that it gets deleted after linking instead - // of now. - //module.module_llvm.temp_dir = Some(tmp_path); - // TODO: save the directory so that it gets deleted later. - std::mem::forget(tmp_path); - - (opt_jobs, copy_jobs) -} - -pub fn optimize_thin_module( - thin_module: ThinModule, - _cgcx: &CodegenContext, -) -> ModuleCodegen { - //let module_name = &thin_module.shared.module_names[thin_module.idx]; - - // Right now the implementation we've got only works over serialized - // modules, so we create a fresh new LLVM context and parse the module - // into that context. One day, however, we may do this for upstream - // crates but for locally codegened modules we may be able to reuse - // that LLVM Context and Module. - //let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); - //let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &dcx)? as *const _; - let mut lto_mode = LtoMode::None; - let context = match thin_module.shared.thin_buffers.get(thin_module.idx) { - Some(thin_buffer) => Arc::clone(&thin_buffer.context), - None => { - let context = Context::default(); - let len = thin_module.shared.thin_buffers.len(); - let module = &thin_module.shared.serialized_modules[thin_module.idx - len]; - match *module { - SerializedModule::Local(ref module_buffer) => { - let path = module_buffer.0.to_str().expect("path"); - context.add_driver_option(path); - lto_mode = LtoMode::Thin; - /*module.module_llvm.should_combine_object_files = true; - module - .module_llvm - .context - .add_driver_option(module_buffer.0.to_str().expect("path"));*/ - } - SerializedModule::FromRlib(_) => unimplemented!("from rlib"), - SerializedModule::FromUncompressedFile(_) => { - unimplemented!("from uncompressed file") - } - } - Arc::new(SyncContext::new(context)) - } - }; - let lto_supported = LTO_SUPPORTED.load(Ordering::SeqCst); - let module = ModuleCodegen::new_regular( - thin_module.name().to_string(), - GccContext { - context, - lto_mode, - lto_supported, - // TODO(antoyo): use the correct relocation model here. - relocation_model: RelocModel::Pic, - temp_dir: None, - }, - ); - /*{ - let target = &*module.module_llvm.tm; - let llmod = module.module_llvm.llmod(); - save_temp_bitcode(cgcx, &module, "thin-lto-input"); - - // Up next comes the per-module local analyses that we do for Thin LTO. - // Each of these functions is basically copied from the LLVM - // implementation and then tailored to suit this implementation. Ideally - // each of these would be supported by upstream LLVM but that's perhaps - // a patch for another day! - // - // You can find some more comments about these functions in the LLVM - // bindings we've got (currently `PassWrapper.cpp`) - { - let _timer = - cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_rename", thin_module.name()); - unsafe { llvm::LLVMRustPrepareThinLTORename(thin_module.shared.data.0, llmod, target) }; - save_temp_bitcode(cgcx, &module, "thin-lto-after-rename"); - } - - { - let _timer = cgcx - .prof - .generic_activity_with_arg("LLVM_thin_lto_resolve_weak", thin_module.name()); - if !llvm::LLVMRustPrepareThinLTOResolveWeak(thin_module.shared.data.0, llmod) { - return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule)); - } - save_temp_bitcode(cgcx, &module, "thin-lto-after-resolve"); - } - - { - let _timer = cgcx - .prof - .generic_activity_with_arg("LLVM_thin_lto_internalize", thin_module.name()); - if !llvm::LLVMRustPrepareThinLTOInternalize(thin_module.shared.data.0, llmod) { - return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule)); - } - save_temp_bitcode(cgcx, &module, "thin-lto-after-internalize"); - } - - { - let _timer = - cgcx.prof.generic_activity_with_arg("LLVM_thin_lto_import", thin_module.name()); - if !llvm::LLVMRustPrepareThinLTOImport(thin_module.shared.data.0, llmod, target) { - return Err(write::llvm_err(&dcx, LlvmError::PrepareThinLtoModule)); - } - save_temp_bitcode(cgcx, &module, "thin-lto-after-import"); - } - - // Alright now that we've done everything related to the ThinLTO - // analysis it's time to run some optimizations! Here we use the same - // `run_pass_manager` as the "fat" LTO above except that we tell it to - // populate a thin-specific pass manager, which presumably LLVM treats a - // little differently. - { - info!("running thin lto passes over {}", module.name); - run_pass_manager(cgcx, &dcx, &mut module, true)?; - save_temp_bitcode(cgcx, &module, "thin-lto-after-pm"); - } - }*/ - // FIXME: switch to #[expect] when the clippy bug is fixed. - #[allow(clippy::let_and_return)] - module -} - -pub struct ThinBuffer { - context: Arc, -} - -impl ThinBuffer { - pub(crate) fn new(context: &Arc) -> Self { - Self { context: Arc::clone(context) } - } -} - -impl ThinBufferMethods for ThinBuffer { - fn data(&self) -> &[u8] { - &[] - } -} - -pub struct ThinData; //(Arc); - -fn module_name_to_str(c_str: &CStr) -> &str { - c_str.to_str().unwrap_or_else(|e| { - bug!("Encountered non-utf8 GCC module name `{}`: {}", c_str.to_string_lossy(), e) - }) -} diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 1b3d78c42e65b..5d03d2406870f 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -76,7 +76,6 @@ use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; -use back::lto::{ThinBuffer, ThinData}; use gccjit::{CType, Context, OptimizationLevel}; #[cfg(feature = "master")] use gccjit::{TargetInfo, Version}; @@ -87,7 +86,9 @@ use rustc_codegen_ssa::back::write::{ }; use rustc_codegen_ssa::base::codegen_crate; use rustc_codegen_ssa::target_features::cfg_target_feature; -use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods}; +use rustc_codegen_ssa::traits::{ + CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods, +}; use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig}; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::SelfProfilerRef; @@ -177,8 +178,6 @@ pub struct GccCodegenBackend { lto_supported: Arc, } -static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false); - fn load_libgccjit_if_needed(libgccjit_target_lib_file: &Path) { if gccjit::is_loaded() { // Do not load a libgccjit second time. @@ -251,7 +250,6 @@ impl CodegenBackend for GccCodegenBackend { #[cfg(feature = "master")] { let lto_supported = gccjit::is_lto_supported(); - LTO_SUPPORTED.store(lto_supported, Ordering::SeqCst); self.lto_supported.store(lto_supported, Ordering::SeqCst); gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); @@ -281,6 +279,10 @@ impl CodegenBackend for GccCodegenBackend { } } + fn thin_lto_supported(&self) -> bool { + false + } + fn provide(&self, providers: &mut Providers) { providers.queries.global_backend_features = |tcx, ()| gcc_util::global_gcc_features(tcx.sess) @@ -421,11 +423,19 @@ unsafe impl Send for SyncContext {} // FIXME(antoyo): that shouldn't be Sync. Parallel compilation is currently disabled with "CodegenBackend::supports_parallel()". unsafe impl Sync for SyncContext {} +pub struct ThinBuffer; + +impl ThinBufferMethods for ThinBuffer { + fn data(&self) -> &[u8] { + &[] + } +} + impl WriteBackendMethods for GccCodegenBackend { type Module = GccContext; type TargetMachine = (); type ModuleBuffer = ModuleBuffer; - type ThinData = ThinData; + type ThinData = (); type ThinBuffer = ThinBuffer; fn run_and_optimize_fat_lto( @@ -442,16 +452,16 @@ impl WriteBackendMethods for GccCodegenBackend { } fn run_thin_lto( - cgcx: &CodegenContext, - prof: &SelfProfilerRef, - dcx: DiagCtxtHandle<'_>, + _cgcx: &CodegenContext, + _prof: &SelfProfilerRef, + _dcx: DiagCtxtHandle<'_>, // FIXME(bjorn3): Limit LTO exports to these symbols _exported_symbols_for_lto: &[String], - each_linked_rlib_for_lto: &[PathBuf], - modules: Vec<(String, Self::ThinBuffer)>, - cached_modules: Vec<(SerializedModule, WorkProduct)>, + _each_linked_rlib_for_lto: &[PathBuf], + _modules: Vec<(String, Self::ThinBuffer)>, + _cached_modules: Vec<(SerializedModule, WorkProduct)>, ) -> (Vec>, Vec) { - back::lto::run_thin(cgcx, prof, dcx, each_linked_rlib_for_lto, modules, cached_modules) + unreachable!() } fn print_pass_timings(&self) { @@ -473,13 +483,13 @@ impl WriteBackendMethods for GccCodegenBackend { } fn optimize_thin( - cgcx: &CodegenContext, + _cgcx: &CodegenContext, _prof: &SelfProfilerRef, _shared_emitter: &SharedEmitter, _tm_factory: TargetMachineFactoryFn, - thin: ThinModule, + _thin: ThinModule, ) -> ModuleCodegen { - back::lto::optimize_thin_module(thin, cgcx) + unreachable!() } fn codegen( @@ -492,8 +502,8 @@ impl WriteBackendMethods for GccCodegenBackend { back::write::codegen(cgcx, prof, shared_emitter, module, config) } - fn prepare_thin(module: ModuleCodegen) -> (String, Self::ThinBuffer) { - back::lto::prepare_thin(module) + fn prepare_thin(_module: ModuleCodegen) -> (String, Self::ThinBuffer) { + unreachable!() } fn serialize_module(_module: ModuleCodegen) -> (String, Self::ModuleBuffer) { diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 996e87b7f31e9..7ebff77710fb0 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -80,6 +80,11 @@ pub trait CodegenBackend { vec![] } + /// Is ThinLTO supported by this backend? + fn thin_lto_supported(&self) -> bool { + true + } + /// Value printed by `--print=backend-has-zstd`. /// /// Used by compiletest to determine whether tests involving zstd compression diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 6cbc184e8f1b7..34c064362168e 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -463,6 +463,7 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se codegen_backend.init(&sess); sess.replaced_intrinsics = FxHashSet::from_iter(codegen_backend.replaced_intrinsics()); + sess.thin_lto_supported = codegen_backend.thin_lto_supported(); let cfg = parse_cfg(sess.dcx(), config.crate_cfg); let mut cfg = config::build_configuration(&sess, cfg); diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs index 3276abfce4132..dfc5c7e800c65 100644 --- a/compiler/rustc_macros/src/diagnostics/message.rs +++ b/compiler/rustc_macros/src/diagnostics/message.rs @@ -101,6 +101,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[ "NaNs", "OK", "Rust", + "ThinLTO", "Unicode", "VS", // tidy-alphabetical-end diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 0c6a33f228082..04a32c20a7915 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -537,3 +537,7 @@ pub(crate) struct UnexpectedBuiltinCfg { pub(crate) cfg_name: Symbol, pub(crate) controlled_by: &'static str, } + +#[derive(Diagnostic)] +#[diag("ThinLTO is not supported by the codegen backend")] +pub(crate) struct ThinLtoNotSupportedByBackend; diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index ed37e9e960cd8..bb22e4a8db047 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -158,6 +158,9 @@ pub struct Session { /// The names of intrinsics that the current codegen backend replaces /// with its own implementations. pub replaced_intrinsics: FxHashSet, + + /// Does the codegen backend support ThinLTO? + pub thin_lto_supported: bool, } #[derive(Clone, Copy)] @@ -606,10 +609,19 @@ impl Session { } config::LtoCli::Thin => { // The user explicitly asked for ThinLTO + if !self.thin_lto_supported { + // Backend doesn't support ThinLTO, disable LTO. + self.dcx().emit_warn(errors::ThinLtoNotSupportedByBackend); + return config::Lto::No; + } return config::Lto::Thin; } } + if !self.thin_lto_supported { + return config::Lto::No; + } + // Ok at this point the target doesn't require anything and the user // hasn't asked for anything. Our next decision is whether or not // we enable "auto" ThinLTO where we use multiple codegen units and @@ -1088,6 +1100,7 @@ pub fn build_session( host_filesearch, invocation_temp, replaced_intrinsics: FxHashSet::default(), // filled by `run_compiler` + thin_lto_supported: true, // filled by `run_compiler` }; validate_commandline_args_with_session_available(&sess); From 88f0ac34dce0e0d21da576aa111ce3b7d66bfafc Mon Sep 17 00:00:00 2001 From: lapla Date: Sat, 7 Feb 2026 18:51:44 +0900 Subject: [PATCH 8/8] Fix const normalization for generic const items with trait assoc consts --- .../src/traits/query/normalize.rs | 10 +++++++--- .../type-const-nested-assoc-const.rs | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/ui/generic-const-items/type-const-nested-assoc-const.rs diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index 02438b24ca7f4..2f83ee046498a 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -376,10 +376,14 @@ impl<'a, 'tcx> QueryNormalizer<'a, 'tcx> { // `tcx.normalize_canonicalized_projection` may normalize to a type that // still has unevaluated consts, so keep normalizing here if that's the case. // Similarly, `tcx.normalize_canonicalized_free_alias` will only unwrap one layer - // of type and we need to continue folding it to reveal the TAIT behind it. + // of type/const and we need to continue folding it to reveal the TAIT behind it + // or further normalize nested unevaluated consts. if res != term.to_term(tcx) - && (res.as_type().map_or(false, |t| t.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION)) - || term.kind(tcx) == ty::AliasTermKind::FreeTy) + && (res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) + || matches!( + term.kind(tcx), + ty::AliasTermKind::FreeTy | ty::AliasTermKind::FreeConst + )) { res.try_fold_with(self) } else { diff --git a/tests/ui/generic-const-items/type-const-nested-assoc-const.rs b/tests/ui/generic-const-items/type-const-nested-assoc-const.rs new file mode 100644 index 0000000000000..72a3098b76cfe --- /dev/null +++ b/tests/ui/generic-const-items/type-const-nested-assoc-const.rs @@ -0,0 +1,18 @@ +//@ check-pass + +#![feature(generic_const_items, min_generic_const_args)] +#![allow(incomplete_features)] + +type const CT: usize = { ::N }; + +trait Trait { + type const N: usize; +} + +impl Trait for T { + type const N:usize = 0; +} + +fn f(_x: [(); CT::<()>]) {} + +fn main() {}