diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 450b9d6c6bbc6..65c8867424d80 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -1335,7 +1335,7 @@ impl<'tcx> ItemCollector<'tcx> { let delayed_kinds = krate.delayed_ids.iter().copied().map(|id| (id, krate.owners[id].expect_delayed())); - // FIXME(fn_delegation): need to add delayed lints, eiis + // FIXME(fn_delegation): need to add eiis for (def_id, kind) in delayed_kinds { let owner_id = OwnerId { def_id }; @@ -1350,6 +1350,9 @@ impl<'tcx> ItemCollector<'tcx> { }; collector.body_owners.push(def_id); + // Delegation items are skipped by the HIR walk (see `visit_if_delayed`), + // so we have to account for their delayed lints manually. + collector.delayed_lint_items.push(owner_id); } } diff --git a/tests/ui/delegation/ice-issue-155127.rs b/tests/ui/delegation/ice-issue-155127.rs new file mode 100644 index 0000000000000..f23170fa45063 --- /dev/null +++ b/tests/ui/delegation/ice-issue-155127.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/155127 + +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +struct S; + +fn foo() {} + +impl S { + #[deprecated] + //~^ ERROR `#[deprecated]` attribute cannot be used on delegations + //~| WARN this was previously accepted by the compiler but is being phased out + reuse foo; +} + +fn main() {} diff --git a/tests/ui/delegation/ice-issue-155127.stderr b/tests/ui/delegation/ice-issue-155127.stderr new file mode 100644 index 0000000000000..a743c3e92f0c8 --- /dev/null +++ b/tests/ui/delegation/ice-issue-155127.stderr @@ -0,0 +1,12 @@ +error: `#[deprecated]` attribute cannot be used on delegations + --> $DIR/ice-issue-155127.rs:11:5 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements + = note: `#[deny(useless_deprecated)]` on by default + +error: aborting due to 1 previous error +