Skip to content

Commit 5fdacfe

Browse files
committed
Force exhaustive handling of every parsed attribute
1 parent dc14e73 commit 5fdacfe

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

compiler/rustc_passes/src/check_attr.rs

Lines changed: 16 additions & 6 deletions
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
}
@@ -229,7 +241,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
229241
[sym::link_name, ..] => self.check_link_name(hir_id, attr, span, target),
230242
[sym::link_section, ..] => self.check_link_section(hir_id, attr, span, target),
231243
[sym::no_mangle, ..] => self.check_no_mangle(hir_id, attr, span, target),
232-
[sym::deprecated, ..] => self.check_deprecated(hir_id, attr, span, target),
233244
[sym::macro_use, ..] | [sym::macro_escape, ..] => {
234245
self.check_macro_use(hir_id, attr, target)
235246
}
@@ -283,7 +294,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
283294
| sym::pointee // FIXME(derive_coerce_pointee)
284295
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
285296
| sym::used // handled elsewhere to restrict to static items
286-
| sym::repr // handled elsewhere to restrict to type decls items
287297
| sym::instruction_set // broken on stable!!!
288298
| sym::windows_subsystem // broken on stable!!!
289299
| sym::patchable_function_entry // FIXME(patchable_function_entry)

0 commit comments

Comments
 (0)