Skip to content

Commit 8ee2d2e

Browse files
committed
fix 142891
1 parent 07eb758 commit 8ee2d2e

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

compiler/rustc_middle/src/hir/map.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,10 +1254,18 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
12541254
body_owners,
12551255
opaques,
12561256
nested_bodies,
1257-
delayed_lint_items,
1257+
mut delayed_lint_items,
12581258
..
12591259
} = collector;
12601260

1261+
// The crate could have delayed lints too, but would not be picked up by the visitor.
1262+
// The `delayed_lint_items` list is smart - it only contains items which we know from
1263+
// earlier passes is guaranteed to contain lints. It's a little harder to determine that
1264+
// for sure here, so we simply always add the crate to the list. If it has no lints,
1265+
// we'll discover that later. The cost of this should be low, there's only one crate
1266+
// after all compared to the many items we have we wouldn't want to iterate over later.
1267+
delayed_lint_items.push(CRATE_OWNER_ID);
1268+
12611269
ModuleItems {
12621270
add_root: true,
12631271
submodules: submodules.into_boxed_slice(),

tests/ui/attributes/lint_on_root.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// NOTE: this used to panic in debug builds (by a sanety assertion)
2+
// and not emit any lint on release builds. See https://github.com/rust-lang/rust/issues/142891.
13
#![inline = ""]
4+
//~^ ERROR valid forms for the attribute are `#[inline(always|never)]` and `#[inline]`
5+
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
26

37
fn main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]`
2+
--> $DIR/lint_on_root.rs:3:1
3+
|
4+
LL | #![inline = ""]
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
9+
= note: `#[deny(ill_formed_attribute_input)]` on by default
10+
11+
error: aborting due to 1 previous error
12+

0 commit comments

Comments
 (0)