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:
commit
6cee0a6ead
3 changed files with 28 additions and 1 deletions
|
|
@ -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(),
|
||||
|
|
|
|||
7
tests/ui/attributes/lint_on_root.rs
Normal file
7
tests/ui/attributes/lint_on_root.rs
Normal 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() {}
|
||||
12
tests/ui/attributes/lint_on_root.stderr
Normal file
12
tests/ui/attributes/lint_on_root.stderr
Normal 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
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue