Skip to content

Commit 62aea8c

Browse files
committed
Address review comments
1 parent 17aef21 commit 62aea8c

File tree

4 files changed

+362
-638
lines changed

4 files changed

+362
-638
lines changed

compiler/rustc_feature/src/builtin_attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
251251
// Modules, prelude, and resolution:
252252
ungated!(path, Normal, template!(NameValueStr: "file")),
253253
ungated!(no_std, CrateLevel, template!(Word)),
254-
ungated!(no_implicit_prelude, CrateLevel, template!(Word)),
254+
ungated!(no_implicit_prelude, Normal, template!(Word)),
255255
ungated!(non_exhaustive, Normal, template!(Word)),
256256

257257
// Runtime

compiler/rustc_passes/src/check_attr.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ impl CheckAttrVisitor<'tcx> {
130130
sym::ignore | sym::should_panic | sym::proc_macro_derive => {
131131
self.check_generic_attr(hir_id, attr, target, &[Target::Fn])
132132
}
133+
sym::automatically_derived => {
134+
self.check_generic_attr(hir_id, attr, target, &[Target::Impl])
135+
}
136+
sym::no_implicit_prelude => {
137+
self.check_generic_attr(hir_id, attr, target, &[Target::Mod])
138+
}
133139
_ => {}
134140
}
135141

@@ -290,7 +296,6 @@ impl CheckAttrVisitor<'tcx> {
290296
b.push_str(&(allowed_target.to_string() + "s"));
291297
b
292298
});
293-
//let supported_names = allowed_targets.iter().fold(String::new(), |msg, t| msg + ", " + &t.to_string());
294299
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
295300
lint.build(&format!("`#[{name}]` only has an effect on {}", supported_names))
296301
.emit();

src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,20 @@ mod path {
275275
//~^ WARN `#[path]` only has an effect
276276
}
277277

278-
// Don't warn on `automatically_derived` - a custom derive
279-
// could reasonally annotate anything that it emits with
280-
// this attribute
281278
#[automatically_derived]
279+
//~^ WARN `#[automatically_derived]` only has an effect
282280
mod automatically_derived {
283281
mod inner { #![automatically_derived] }
282+
//~^ WARN `#[automatically_derived]
284283

285284
#[automatically_derived] fn f() { }
285+
//~^ WARN `#[automatically_derived]
286286

287287
#[automatically_derived] struct S;
288+
//~^ WARN `#[automatically_derived]
288289

289290
#[automatically_derived] type T = S;
291+
//~^ WARN `#[automatically_derived]
290292

291293
#[automatically_derived] impl S { }
292294
}
@@ -368,22 +370,20 @@ mod ignore {
368370
}
369371

370372
#[no_implicit_prelude]
371-
//~^ WARN crate-level attribute
372373
mod no_implicit_prelude {
373374
mod inner { #![no_implicit_prelude] }
374-
//~^ WARN crate-level attribute
375375

376376
#[no_implicit_prelude] fn f() { }
377-
//~^ WARN crate-level attribute
377+
//~^ WARN `#[no_implicit_prelude]` only has an effect
378378

379379
#[no_implicit_prelude] struct S;
380-
//~^ WARN crate-level attribute
380+
//~^ WARN `#[no_implicit_prelude]` only has an effect
381381

382382
#[no_implicit_prelude] type T = S;
383-
//~^ WARN crate-level attribute
383+
//~^ WARN `#[no_implicit_prelude]` only has an effect
384384

385385
#[no_implicit_prelude] impl S { }
386-
//~^ WARN crate-level attribute
386+
//~^ WARN `#[no_implicit_prelude]` only has an effect
387387
}
388388

389389
#[reexport_test_harness_main = "2900"]

0 commit comments

Comments
 (0)