diff options
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 49 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 4 |
2 files changed, 10 insertions, 43 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d768aa6a8dd..10c532b436a 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -207,9 +207,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { Attribute::Parsed(AttributeKind::ConstContinue(attr_span)) => { self.check_const_continue(hir_id, *attr_span, target) } - Attribute::Parsed(AttributeKind::AllowInternalUnsafe(attr_span)) => { - self.check_allow_internal_unsafe(hir_id, *attr_span, span, target, attrs) - } Attribute::Parsed(AttributeKind::AllowInternalUnstable(_, first_span)) => { self.check_allow_internal_unstable(hir_id, *first_span, span, target, attrs) } @@ -416,6 +413,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // internal | sym::prelude_import | sym::panic_handler + | sym::allow_internal_unsafe | sym::lang | sym::needs_allocator | sym::default_lib_allocator @@ -2214,49 +2212,14 @@ impl<'tcx> CheckAttrVisitor<'tcx> { /// Outputs an error for `#[allow_internal_unstable]` which can only be applied to macros. /// (Allows proc_macro functions) - fn check_allow_internal_unstable( - &self, - hir_id: HirId, - attr_span: Span, - span: Span, - target: Target, - attrs: &[Attribute], - ) { - self.check_macro_only_attr( - hir_id, - attr_span, - span, - target, - attrs, - "allow_internal_unstable", - ) - } - - /// Outputs an error for `#[allow_internal_unsafe]` which can only be applied to macros. - /// (Allows proc_macro functions) - fn check_allow_internal_unsafe( - &self, - hir_id: HirId, - attr_span: Span, - span: Span, - target: Target, - attrs: &[Attribute], - ) { - self.check_macro_only_attr(hir_id, attr_span, span, target, attrs, "allow_internal_unsafe") - } - - /// Outputs an error for attributes that can only be applied to macros, such as - /// `#[allow_internal_unsafe]` and `#[allow_internal_unstable]`. - /// (Allows proc_macro functions) // FIXME(jdonszelmann): if possible, move to attr parsing - fn check_macro_only_attr( + fn check_allow_internal_unstable( &self, hir_id: HirId, attr_span: Span, span: Span, target: Target, attrs: &[Attribute], - attr_name: &str, ) { match target { Target::Fn => { @@ -2275,14 +2238,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // erroneously allowed it and some crates used it accidentally, to be compatible // with crates depending on them, we can't throw an error here. Target::Field | Target::Arm => { - self.inline_attr_str_error_without_macro_def(hir_id, attr_span, attr_name); + self.inline_attr_str_error_without_macro_def( + hir_id, + attr_span, + "allow_internal_unstable", + ); return; } // otherwise continue out of the match _ => {} } - self.tcx.dcx().emit_err(errors::MacroOnlyAttribute { attr_span, span }); + self.tcx.dcx().emit_err(errors::AllowInternalUnstable { attr_span, span }); } /// Checks if the items on the `#[debugger_visualizer]` attribute are valid. diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 10b30fbe8c9..c6ab6b0d601 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -643,8 +643,8 @@ pub(crate) struct UsedStatic { } #[derive(Diagnostic)] -#[diag(passes_macro_only_attribute)] -pub(crate) struct MacroOnlyAttribute { +#[diag(passes_allow_internal_unstable)] +pub(crate) struct AllowInternalUnstable { #[primary_span] pub attr_span: Span, #[label] |
