diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index c3d5bae32e6..ec4cefa3537 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -76,6 +76,9 @@ impl CheckAttrVisitor<'_> { sym::inline => self.check_inline(hir_id, attr, span, target), sym::non_exhaustive => self.check_non_exhaustive(hir_id, attr, span, target), sym::marker => self.check_marker(hir_id, attr, span, target), + sym::rustc_must_implement_one_of => { + self.check_rustc_must_implement_one_of(attr, span, target) + } sym::target_feature => self.check_target_feature(hir_id, attr, span, target), sym::track_caller => { self.check_track_caller(hir_id, &attr.span, attrs, span, target) @@ -477,6 +480,26 @@ impl CheckAttrVisitor<'_> { } } + /// Checks if the `#[rustc_must_implement_one_of]` attribute on a `target` is valid. Returns `true` if valid. + fn check_rustc_must_implement_one_of( + &self, + attr: &Attribute, + span: &Span, + target: Target, + ) -> bool { + match target { + Target::Trait => true, + _ => { + self.tcx + .sess + .struct_span_err(attr.span, "attribute can only be applied to a trait") + .span_label(*span, "not a trait") + .emit(); + false + } + } + } + /// Checks if the `#[target_feature]` attribute on `item` is valid. Returns `true` if valid. fn check_target_feature( &self, |
