self.check_export_name(&attr, span, target)
} else if self.tcx.sess.check_name(attr, sym::rustc_args_required_const) {
self.check_rustc_args_required_const(&attr, span, target, item)
+ } else if self.tcx.sess.check_name(attr, sym::allow_internal_unstable) {
+ self.check_allow_internal_unstable(&attr, span, target, &attrs)
} else {
// lint-only checks
if self.tcx.sess.check_name(attr, sym::cold) {
}
}
}
+
+ /// Outputs an error for `#[allow_internal_unstable]` which can only be applied to macros.
+ /// (Allows proc_macro functions)
+ fn check_allow_internal_unstable(
+ &self,
+ attr: &Attribute,
+ span: &Span,
+ target: Target,
+ attrs: &[Attribute],
+ ) -> bool {
+ debug!("Checking target: {:?}", target);
+ if target == Target::Fn {
+ for attr in attrs {
+ if self.tcx.sess.is_proc_macro_attr(attr) {
+ debug!("Is proc macro attr");
+ return true;
+ }
+ }
+ debug!("Is not proc macro attr");
+ }
+ self.tcx
+ .sess
+ .struct_span_err(attr.span, "attribute should be applied to a macro")
+ .span_label(*span, "not a macro")
+ .emit();
+ false
+ }
}
impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
|
= help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable
-error: aborting due to previous error
+error: attribute should be applied to a macro
+ --> $DIR/feature-gate-allow-internal-unstable-struct.rs:4:1
+ |
+LL | #[allow_internal_unstable()]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | struct S;
+ | --------- not a macro
+
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.