This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-19
lines changed
compiler/rustc_hir_analysis/src Expand file tree Collapse file tree 3 files changed +22
-19
lines changed Original file line number Diff line number Diff line change @@ -56,25 +56,6 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) {
5656 let unused_extern_crates: FxHashMap < LocalDefId , Span > = tcx
5757 . maybe_unused_extern_crates ( ( ) )
5858 . iter ( )
59- . filter ( |& & ( def_id, _) | {
60- // The `def_id` here actually was calculated during resolution (at least
61- // at the time of this writing) and is being shipped to us via a side
62- // channel of the tcx. There may have been extra expansion phases,
63- // however, which ended up removing the `def_id` *after* expansion.
64- //
65- // As a result we need to verify that `def_id` is indeed still valid for
66- // our AST and actually present in the HIR map. If it's not there then
67- // there's safely nothing to warn about, and otherwise we carry on with
68- // our execution.
69- //
70- // Note that if we carry through to the `extern_mod_stmt_cnum` query
71- // below it'll cause a panic because `def_id` is actually bogus at this
72- // point in time otherwise.
73- if tcx. hir ( ) . find ( tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ) . is_none ( ) {
74- return false ;
75- }
76- true
77- } )
7859 . filter ( |& & ( def_id, _) | {
7960 tcx. extern_mod_stmt_cnum ( def_id) . map_or ( true , |cnum| {
8061 !tcx. is_compiler_builtins ( cnum)
Original file line number Diff line number Diff line change 1+ #[ w = { extern crate alloc; } ]
2+ //~^ ERROR unexpected expression: `{
3+ //~| ERROR cannot find attribute `w` in this scope
4+ fn f ( ) { }
5+
6+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: unexpected expression: `{
2+ extern crate alloc;
3+ }`
4+ --> $DIR/unused-item-in-attr.rs:1:7
5+ |
6+ LL | #[w = { extern crate alloc; }]
7+ | ^^^^^^^^^^^^^^^^^^^^^^^
8+
9+ error: cannot find attribute `w` in this scope
10+ --> $DIR/unused-item-in-attr.rs:1:3
11+ |
12+ LL | #[w = { extern crate alloc; }]
13+ | ^
14+
15+ error: aborting due to 2 previous errors
16+
You can’t perform that action at this time.
0 commit comments