Skip to content

Commit d01e5b2

Browse files
committed
Force exhaustive handling of every parsed attribute
1 parent 95bc992 commit d01e5b2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

compiler/rustc_passes/src/check_attr.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,22 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
132132
target,
133133
attrs,
134134
),
135-
_ => {
135+
Attribute::Parsed(AttributeKind::AllowConstFnUnstable { .. }) => {
136+
self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target)
137+
}
138+
Attribute::Parsed(AttributeKind::Deprecation { .. }) => {
139+
self.check_deprecated(hir_id, attr, span, target)
140+
}
141+
Attribute::Parsed(AttributeKind::DocComment { .. }) => { /* `#[doc]` is actually a lot more than just doc comments, so is checked below*/
142+
}
143+
Attribute::Parsed(AttributeKind::Repr(_)) => { /* handled below this loop and elsewhere */
144+
}
145+
Attribute::Parsed(
146+
AttributeKind::BodyStability { .. }
147+
| AttributeKind::ConstStabilityIndirect
148+
| AttributeKind::MacroTransparency(_),
149+
) => { /* do nothing */ }
150+
Attribute::Unparsed(_) => {
136151
match attr.path().as_slice() {
137152
[sym::diagnostic, sym::do_not_recommend, ..] => {
138153
self.check_do_not_recommend(attr.span(), hir_id, target, attr, item)
@@ -169,9 +184,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
169184
self.check_rustc_layout_scalar_valid_range(attr, span, target)
170185
}
171186
[sym::debugger_visualizer, ..] => self.check_debugger_visualizer(attr, target),
172-
[sym::rustc_allow_const_fn_unstable, ..] => {
173-
self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target)
174-
}
175187
[sym::rustc_std_internal_symbol, ..] => {
176188
self.check_rustc_std_internal_symbol(attr, span, target)
177189
}
@@ -226,7 +238,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
226238
[sym::link_name, ..] => self.check_link_name(hir_id, attr, span, target),
227239
[sym::link_section, ..] => self.check_link_section(hir_id, attr, span, target),
228240
[sym::no_mangle, ..] => self.check_no_mangle(hir_id, attr, span, target),
229-
[sym::deprecated, ..] => self.check_deprecated(hir_id, attr, span, target),
230241
[sym::macro_use, ..] | [sym::macro_escape, ..] => {
231242
self.check_macro_use(hir_id, attr, target)
232243
}
@@ -279,7 +290,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
279290
| sym::pointee // FIXME(derive_coerce_pointee)
280291
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
281292
| sym::used // handled elsewhere to restrict to static items
282-
| sym::repr // handled elsewhere to restrict to type decls items
283293
| sym::instruction_set // broken on stable!!!
284294
| sym::windows_subsystem // broken on stable!!!
285295
| sym::patchable_function_entry // FIXME(patchable_function_entry)

0 commit comments

Comments
 (0)