Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion compiler/rustc_middle/src/hir/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/attributes/lint_on_root.rs
Original file line number Diff line number Diff line change
@@ -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() {}
12 changes: 12 additions & 0 deletions tests/ui/attributes/lint_on_root.stderr
Original file line number Diff line number Diff line change
@@ -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

Loading