Description
The check_attr
visitor here is missing several methods:
rust/compiler/rustc_passes/src/check_attr.rs
Lines 866 to 936 in e261649
A quick search (for attrs:
) in the HIR definition finds these additional types that can contain attributes (they're also missing from the hir::Target
enum
, which should probably be renamed to AttrTarget
but that's besides the point):
(click to see definition code snippets)
(summary: GenericParam
, MacroDef
, Arm
, Param
, StructField
)
GenericParam
, MacroDef
, Arm
, Param
, StructField
)GenericParam
rust/compiler/rustc_hir/src/hir.rs
Lines 425 to 428 in e261649
MacroDef
(is this handled elsewhere?)rust/compiler/rustc_hir/src/hir.rs
Lines 722 to 725 in e261649
Arm
rust/compiler/rustc_hir/src/hir.rs
Lines 1147 to 1151 in e261649
Param
rust/compiler/rustc_hir/src/hir.rs
Lines 2183 to 2184 in e261649
StructField
rust/compiler/rustc_hir/src/hir.rs
Lines 2390 to 2397 in e261649
This isn't necessary a bug for some of them, as there is special validation elsewhere, e.g.:
rust/compiler/rustc_ast_passes/src/ast_validation.rs
Lines 377 to 378 in e261649
But it's not as uniform and future-proof as it could be. It might even be worth having a contextual attribute Target
, and handling all attributes on visit_attr
, or a hybrid solution that ICEs when visit_attr
comes across an attribute not already handled.
And I did end up finding at least one bug, this compiles without any warnings (try on playground):
fn main() {
match 5 {
#[inline] _ => {}
}
}