diff options
| author | bors <bors@rust-lang.org> | 2020-12-19 04:32:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-12-19 04:32:50 +0000 |
| commit | 3d9ada686fb42bd036b3a4916526f413f1d5d1f8 (patch) | |
| tree | fe8db8ba112aba65766fd64d94c3179d0552d115 /compiler/rustc_passes/src | |
| parent | d1741e59cb87d3c8c794eebf6d5430d1b383f51f (diff) | |
| parent | 75eb72cc9c23d31f10bd7b4ec6331dd8383cf829 (diff) | |
| download | rust-3d9ada686fb42bd036b3a4916526f413f1d5d1f8.tar.gz rust-3d9ada686fb42bd036b3a4916526f413f1d5d1f8.zip | |
Auto merge of #79073 - davidtwco:issue-78957-const-param-attrs, r=lcnr
passes: prohibit invalid attrs on generic params Fixes #78957. This PR modifies the `check_attr` pass so that attribute placement on generic parameters is checked for validity. r? `@lcnr`
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 73fb28e5c9a..aeaa862f5fd 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -882,6 +882,18 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> { intravisit::walk_item(self, item) } + fn visit_generic_param(&mut self, generic_param: &'tcx hir::GenericParam<'tcx>) { + let target = Target::from_generic_param(generic_param); + self.check_attributes( + generic_param.hir_id, + generic_param.attrs, + &generic_param.span, + target, + None, + ); + intravisit::walk_generic_param(self, generic_param) + } + fn visit_trait_item(&mut self, trait_item: &'tcx TraitItem<'tcx>) { let target = Target::from_trait_item(trait_item); self.check_attributes(trait_item.hir_id, &trait_item.attrs, &trait_item.span, target, None); |
