Rollup merge of #142892 - jdonszelmann:fix-142891, r=oli-obk

Fix ICE on debug builds where lints are delayed on the crate root

r? ``@oli-obk``

Closes rust-lang/rust#142891

thanks to ``@JonathanBrouwer`` for finding it!
This commit is contained in:
Jana Dönszelmann 2025-06-23 12:39:09 +02:00 committed by GitHub
commit 6cee0a6ead
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 1 deletions

View file

@ -1254,10 +1254,18 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
body_owners,
opaques,
nested_bodies,
delayed_lint_items,
mut delayed_lint_items,
..
} = collector;
// The crate could have delayed lints too, but would not be picked up by the visitor.
// The `delayed_lint_items` list is smart - it only contains items which we know from
// earlier passes is guaranteed to contain lints. It's a little harder to determine that
// for sure here, so we simply always add the crate to the list. If it has no lints,
// we'll discover that later. The cost of this should be low, there's only one crate
// after all compared to the many items we have we wouldn't want to iterate over later.
delayed_lint_items.push(CRATE_OWNER_ID);
ModuleItems {
add_root: true,
submodules: submodules.into_boxed_slice(),

View file

@ -0,0 +1,7 @@
// NOTE: this used to panic in debug builds (by a sanity assertion)
// and not emit any lint on release builds. See https://github.com/rust-lang/rust/issues/142891.
#![inline = ""]
//~^ ERROR valid forms for the attribute are `#[inline(always|never)]` and `#[inline]`
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
fn main() {}

View file

@ -0,0 +1,12 @@
error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]`
--> $DIR/lint_on_root.rs:3:1
|
LL | #![inline = ""]
| ^^^^^^^^^^^^^^^
|
= 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 #57571 <https://github.com/rust-lang/rust/issues/57571>
= note: `#[deny(ill_formed_attribute_input)]` on by default
error: aborting due to 1 previous error