1
Fork 0

resolve: Centralize some error reporting for unexpected macro resolutions

This commit is contained in:
Vadim Petrochenkov 2020-11-19 01:49:20 +03:00
parent 69894ce9ac
commit 68f94e94ed
14 changed files with 278 additions and 253 deletions

View file

@ -209,6 +209,28 @@ impl AstFragmentKind {
self.make_from(DummyResult::any(span)).expect("couldn't create a dummy AST fragment") self.make_from(DummyResult::any(span)).expect("couldn't create a dummy AST fragment")
} }
/// Fragment supports macro expansion and not just inert attributes, `cfg` and `cfg_attr`.
pub fn supports_macro_expansion(self) -> bool {
match self {
AstFragmentKind::OptExpr
| AstFragmentKind::Expr
| AstFragmentKind::Pat
| AstFragmentKind::Ty
| AstFragmentKind::Stmts
| AstFragmentKind::Items
| AstFragmentKind::TraitItems
| AstFragmentKind::ImplItems
| AstFragmentKind::ForeignItems => true,
AstFragmentKind::Arms
| AstFragmentKind::Fields
| AstFragmentKind::FieldPats
| AstFragmentKind::GenericParams
| AstFragmentKind::Params
| AstFragmentKind::StructFields
| AstFragmentKind::Variants => false,
}
}
fn expect_from_annotatables<I: IntoIterator<Item = Annotatable>>( fn expect_from_annotatables<I: IntoIterator<Item = Annotatable>>(
self, self,
items: I, items: I,
@ -1014,7 +1036,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
attrs: &mut Vec<ast::Attribute>, attrs: &mut Vec<ast::Attribute>,
after_derive: &mut bool, after_derive: &mut bool,
) -> Option<ast::Attribute> { ) -> Option<ast::Attribute> {
let attr = attrs attrs
.iter() .iter()
.position(|a| { .position(|a| {
if a.has_name(sym::derive) { if a.has_name(sym::derive) {
@ -1022,22 +1044,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
} }
!self.cx.sess.is_attr_known(a) && !is_builtin_attr(a) !self.cx.sess.is_attr_known(a) && !is_builtin_attr(a)
}) })
.map(|i| attrs.remove(i)); .map(|i| attrs.remove(i))
if let Some(attr) = &attr {
if !self.cx.ecfg.custom_inner_attributes()
&& attr.style == ast::AttrStyle::Inner
&& !attr.has_name(sym::test)
{
feature_err(
&self.cx.sess.parse_sess,
sym::custom_inner_attributes,
attr.span,
"non-builtin inner attributes are unstable",
)
.emit();
}
}
attr
} }
/// If `item` is an attr invocation, remove and return the macro attribute and derive traits. /// If `item` is an attr invocation, remove and return the macro attribute and derive traits.

View file

@ -12,24 +12,24 @@ use rustc_ast_pretty::pprust;
use rustc_attr::StabilityLevel; use rustc_attr::StabilityLevel;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::ptr_key::PtrKey; use rustc_data_structures::ptr_key::PtrKey;
use rustc_data_structures::sync::Lrc;
use rustc_errors::struct_span_err; use rustc_errors::struct_span_err;
use rustc_expand::base::{Indeterminate, InvocationRes, ResolverExpand, SyntaxExtension}; use rustc_expand::base::{Indeterminate, InvocationRes, ResolverExpand, SyntaxExtension};
use rustc_expand::compile_declarative_macro; use rustc_expand::compile_declarative_macro;
use rustc_expand::expand::{AstFragment, AstFragmentKind, Invocation, InvocationKind}; use rustc_expand::expand::{AstFragment, Invocation, InvocationKind};
use rustc_feature::is_builtin_attr_name; use rustc_feature::is_builtin_attr_name;
use rustc_hir::def::{self, DefKind, NonMacroAttrKind}; use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
use rustc_hir::def_id; use rustc_hir::def_id;
use rustc_middle::middle::stability; use rustc_middle::middle::stability;
use rustc_middle::ty; use rustc_middle::ty;
use rustc_session::lint::builtin::UNUSED_MACROS; use rustc_session::lint::builtin::UNUSED_MACROS;
use rustc_session::parse::feature_err;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::edition::Edition; use rustc_span::edition::Edition;
use rustc_span::hygiene::{self, ExpnData, ExpnId, ExpnKind}; use rustc_span::hygiene::{self, ExpnData, ExpnId, ExpnKind};
use rustc_span::hygiene::{AstPass, MacroKind};
use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP}; use rustc_span::{Span, DUMMY_SP};
use rustc_data_structures::sync::Lrc;
use rustc_span::hygiene::{AstPass, MacroKind};
use std::cell::Cell; use std::cell::Cell;
use std::{mem, ptr}; use std::{mem, ptr};
@ -241,15 +241,20 @@ impl<'a> ResolverExpand for Resolver<'a> {
} }
}; };
let (path, kind, derives, after_derive) = match invoc.kind { let (path, kind, inner_attr, derives, after_derive) = match invoc.kind {
InvocationKind::Attr { ref attr, ref derives, after_derive, .. } => ( InvocationKind::Attr { ref attr, ref derives, after_derive, .. } => (
&attr.get_normal_item().path, &attr.get_normal_item().path,
MacroKind::Attr, MacroKind::Attr,
attr.style == ast::AttrStyle::Inner,
self.arenas.alloc_ast_paths(derives), self.arenas.alloc_ast_paths(derives),
after_derive, after_derive,
), ),
InvocationKind::Bang { ref mac, .. } => (&mac.path, MacroKind::Bang, &[][..], false), InvocationKind::Bang { ref mac, .. } => {
InvocationKind::Derive { ref path, .. } => (path, MacroKind::Derive, &[][..], false), (&mac.path, MacroKind::Bang, false, &[][..], false)
}
InvocationKind::Derive { ref path, .. } => {
(path, MacroKind::Derive, false, &[][..], false)
}
InvocationKind::DeriveContainer { ref derives, .. } => { InvocationKind::DeriveContainer { ref derives, .. } => {
// Block expansion of the container until we resolve all derives in it. // Block expansion of the container until we resolve all derives in it.
// This is required for two reasons: // This is required for two reasons:
@ -299,8 +304,17 @@ impl<'a> ResolverExpand for Resolver<'a> {
// Derives are not included when `invocations` are collected, so we have to add them here. // Derives are not included when `invocations` are collected, so we have to add them here.
let parent_scope = &ParentScope { derives, ..parent_scope }; let parent_scope = &ParentScope { derives, ..parent_scope };
let require_inert = !invoc.fragment_kind.supports_macro_expansion();
let node_id = self.lint_node_id(eager_expansion_root); let node_id = self.lint_node_id(eager_expansion_root);
let (ext, res) = self.smart_resolve_macro_path(path, kind, parent_scope, node_id, force)?; let (ext, res) = self.smart_resolve_macro_path(
path,
kind,
require_inert,
inner_attr,
parent_scope,
node_id,
force,
)?;
let span = invoc.span(); let span = invoc.span();
invoc_id.set_expn_data(ext.expn_data( invoc_id.set_expn_data(ext.expn_data(
@ -318,29 +332,6 @@ impl<'a> ResolverExpand for Resolver<'a> {
self.definitions.add_parent_module_of_macro_def(invoc_id, normal_module_def_id); self.definitions.add_parent_module_of_macro_def(invoc_id, normal_module_def_id);
} }
match invoc.fragment_kind {
AstFragmentKind::Arms
| AstFragmentKind::Fields
| AstFragmentKind::FieldPats
| AstFragmentKind::GenericParams
| AstFragmentKind::Params
| AstFragmentKind::StructFields
| AstFragmentKind::Variants => {
if let Res::Def(..) = res {
self.session.span_err(
span,
&format!(
"expected an inert attribute, found {} {}",
res.article(),
res.descr()
),
);
return Ok(InvocationRes::Single(self.dummy_ext(kind)));
}
}
_ => {}
}
Ok(InvocationRes::Single(ext)) Ok(InvocationRes::Single(ext))
} }
@ -403,10 +394,14 @@ impl<'a> ResolverExpand for Resolver<'a> {
impl<'a> Resolver<'a> { impl<'a> Resolver<'a> {
/// Resolve macro path with error reporting and recovery. /// Resolve macro path with error reporting and recovery.
/// Uses dummy syntax extensions for unresolved macros or macros with unexpected resolutions
/// for better error recovery.
fn smart_resolve_macro_path( fn smart_resolve_macro_path(
&mut self, &mut self,
path: &ast::Path, path: &ast::Path,
kind: MacroKind, kind: MacroKind,
require_inert: bool,
inner_attr: bool,
parent_scope: &ParentScope<'a>, parent_scope: &ParentScope<'a>,
node_id: NodeId, node_id: NodeId,
force: bool, force: bool,
@ -414,7 +409,6 @@ impl<'a> Resolver<'a> {
let (ext, res) = match self.resolve_macro_path(path, Some(kind), parent_scope, true, force) let (ext, res) = match self.resolve_macro_path(path, Some(kind), parent_scope, true, force)
{ {
Ok((Some(ext), res)) => (ext, res), Ok((Some(ext), res)) => (ext, res),
// Use dummy syntax extensions for unresolved macros for better recovery.
Ok((None, res)) => (self.dummy_ext(kind), res), Ok((None, res)) => (self.dummy_ext(kind), res),
Err(Determinacy::Determined) => (self.dummy_ext(kind), Res::Err), Err(Determinacy::Determined) => (self.dummy_ext(kind), Res::Err),
Err(Determinacy::Undetermined) => return Err(Indeterminate), Err(Determinacy::Undetermined) => return Err(Indeterminate),
@ -451,19 +445,43 @@ impl<'a> Resolver<'a> {
self.check_stability_and_deprecation(&ext, path, node_id); self.check_stability_and_deprecation(&ext, path, node_id);
Ok(if ext.macro_kind() != kind { let unexpected_res = if ext.macro_kind() != kind {
let expected = kind.descr_expected(); Some((kind.article(), kind.descr_expected()))
} else if require_inert && matches!(res, Res::Def(..)) {
Some(("a", "non-macro attribute"))
} else {
None
};
if let Some((article, expected)) = unexpected_res {
let path_str = pprust::path_to_string(path); let path_str = pprust::path_to_string(path);
let msg = format!("expected {}, found {} `{}`", expected, res.descr(), path_str); let msg = format!("expected {}, found {} `{}`", expected, res.descr(), path_str);
self.session self.session
.struct_span_err(path.span, &msg) .struct_span_err(path.span, &msg)
.span_label(path.span, format!("not {} {}", kind.article(), expected)) .span_label(path.span, format!("not {} {}", article, expected))
.emit(); .emit();
// Use dummy syntax extensions for unexpected macro kinds for better recovery. return Ok((self.dummy_ext(kind), Res::Err));
(self.dummy_ext(kind), Res::Err) }
} else {
(ext, res) // We are trying to avoid reporting this error if other related errors were reported.
}) if inner_attr
&& !self.session.features_untracked().custom_inner_attributes
&& path != &sym::test
&& res != Res::Err
{
feature_err(
&self.session.parse_sess,
sym::custom_inner_attributes,
path.span,
match res {
Res::Def(..) => "inner macro attributes are unstable",
Res::NonMacroAttr(..) => "custom inner attributes are unstable",
_ => unreachable!(),
},
)
.emit();
}
Ok((ext, res))
} }
pub fn resolve_macro_path( pub fn resolve_macro_path(

View file

@ -1,12 +1,12 @@
enum FooEnum { enum FooEnum {
#[test] #[test]
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
Bar(i32), Bar(i32),
} }
struct FooStruct { struct FooStruct {
#[test] #[test]
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
bar: i32, bar: i32,
} }
@ -21,20 +21,20 @@ fn main() {
match foo_struct { match foo_struct {
FooStruct { FooStruct {
#[test] bar #[test] bar
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
} => {} } => {}
} }
match 1 { match 1 {
0 => {} 0 => {}
#[test] #[test]
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
_ => {} _ => {}
} }
let _another_foo_strunct = FooStruct { let _another_foo_strunct = FooStruct {
#[test] #[test]
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
bar: 1, bar: 1,
}; };
} }

View file

@ -1,32 +1,32 @@
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/attrs-resolution-errors.rs:2:5 --> $DIR/attrs-resolution-errors.rs:2:7
| |
LL | #[test] LL | #[test]
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/attrs-resolution-errors.rs:8:5 --> $DIR/attrs-resolution-errors.rs:8:7
| |
LL | #[test] LL | #[test]
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/attrs-resolution-errors.rs:23:13 --> $DIR/attrs-resolution-errors.rs:23:15
| |
LL | #[test] bar LL | #[test] bar
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/attrs-resolution-errors.rs:30:9 --> $DIR/attrs-resolution-errors.rs:30:11
| |
LL | #[test] LL | #[test]
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/attrs-resolution-errors.rs:36:9 --> $DIR/attrs-resolution-errors.rs:36:11
| |
LL | #[test] LL | #[test]
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View file

@ -7,11 +7,11 @@
extern crate test_macros; extern crate test_macros;
fn _test_inner() { fn _test_inner() {
#![empty_attr] //~ ERROR: non-builtin inner attributes are unstable #![empty_attr] //~ ERROR: inner macro attributes are unstable
} }
mod _test2_inner { mod _test2_inner {
#![empty_attr] //~ ERROR: non-builtin inner attributes are unstable #![empty_attr] //~ ERROR: inner macro attributes are unstable
} }
#[empty_attr = "y"] //~ ERROR: key-value macro attributes are not supported #[empty_attr = "y"] //~ ERROR: key-value macro attributes are not supported

View file

@ -1,17 +1,17 @@
error[E0658]: non-builtin inner attributes are unstable error[E0658]: inner macro attributes are unstable
--> $DIR/proc-macro-gates.rs:10:5 --> $DIR/proc-macro-gates.rs:10:8
| |
LL | #![empty_attr] LL | #![empty_attr]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^
| |
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable
error[E0658]: non-builtin inner attributes are unstable error[E0658]: inner macro attributes are unstable
--> $DIR/proc-macro-gates.rs:14:5 --> $DIR/proc-macro-gates.rs:14:8
| |
LL | #![empty_attr] LL | #![empty_attr]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^
| |
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable

View file

@ -10,11 +10,11 @@ extern crate test_macros;
// should either require a feature gate or not be allowed on stable. // should either require a feature gate or not be allowed on stable.
fn _test6<#[empty_attr] T>() {} fn _test6<#[empty_attr] T>() {}
//~^ ERROR: expected an inert attribute, found an attribute macro //~^ ERROR: expected non-macro attribute, found attribute macro
fn _test7() { fn _test7() {
match 1 { match 1 {
#[empty_attr] //~ ERROR: expected an inert attribute, found an attribute macro #[empty_attr] //~ ERROR: expected non-macro attribute, found attribute macro
0 => {} 0 => {}
_ => {} _ => {}
} }

View file

@ -1,14 +1,14 @@
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `empty_attr`
--> $DIR/proc-macro-gates2.rs:12:11 --> $DIR/proc-macro-gates2.rs:12:13
| |
LL | fn _test6<#[empty_attr] T>() {} LL | fn _test6<#[empty_attr] T>() {}
| ^^^^^^^^^^^^^ | ^^^^^^^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `empty_attr`
--> $DIR/proc-macro-gates2.rs:17:9 --> $DIR/proc-macro-gates2.rs:17:11
| |
LL | #[empty_attr] LL | #[empty_attr]
| ^^^^^^^^^^^^^ | ^^^^^^^^^^ not a non-macro attribute
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -3,7 +3,7 @@ extern "C" {
/// Foo /// Foo
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -19,7 +19,7 @@ type FnType = fn(
/// Foo /// Foo
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: u32, #[test] a: u32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -34,7 +34,7 @@ pub fn foo(
/// Foo /// Foo
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: u32, #[test] a: u32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -54,7 +54,7 @@ impl SelfStruct {
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Baz /// Baz
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -69,7 +69,7 @@ impl SelfStruct {
/// Foo /// Foo
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Baz /// Baz
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -90,7 +90,7 @@ impl RefStruct {
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Baz /// Baz
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -109,7 +109,7 @@ trait RefTrait {
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Baz /// Baz
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -124,7 +124,7 @@ trait RefTrait {
/// Foo /// Foo
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Baz /// Baz
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -144,7 +144,7 @@ impl RefTrait for RefStruct {
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: i32, #[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Baz /// Baz
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]
@ -161,7 +161,7 @@ fn main() {
/// Foo /// Foo
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[test] a: u32, #[test] a: u32,
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
/// Bar /// Bar
//~^ ERROR documentation comments cannot be applied to function //~^ ERROR documentation comments cannot be applied to function
#[must_use] #[must_use]

View file

@ -1,62 +1,62 @@
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:5:9 --> $DIR/param-attrs-builtin-attrs.rs:5:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:21:5 --> $DIR/param-attrs-builtin-attrs.rs:21:7
| |
LL | #[test] a: u32, LL | #[test] a: u32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:36:5 --> $DIR/param-attrs-builtin-attrs.rs:36:7
| |
LL | #[test] a: u32, LL | #[test] a: u32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:56:9 --> $DIR/param-attrs-builtin-attrs.rs:56:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:71:9 --> $DIR/param-attrs-builtin-attrs.rs:71:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:92:9 --> $DIR/param-attrs-builtin-attrs.rs:92:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:111:9 --> $DIR/param-attrs-builtin-attrs.rs:111:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:126:9 --> $DIR/param-attrs-builtin-attrs.rs:126:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:146:9 --> $DIR/param-attrs-builtin-attrs.rs:146:11
| |
LL | #[test] a: i32, LL | #[test] a: i32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `test`
--> $DIR/param-attrs-builtin-attrs.rs:163:9 --> $DIR/param-attrs-builtin-attrs.rs:163:11
| |
LL | #[test] a: u32, LL | #[test] a: u32,
| ^^^^^^^ | ^^^^ not a non-macro attribute
error: documentation comments cannot be applied to function parameters error: documentation comments cannot be applied to function parameters
--> $DIR/param-attrs-builtin-attrs.rs:3:9 --> $DIR/param-attrs-builtin-attrs.rs:3:9

View file

@ -8,58 +8,58 @@ use ident_mac::id;
struct W(u8); struct W(u8);
extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {}
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
type Alias = extern "C" fn(#[id] u8, #[id] ...); type Alias = extern "C" fn(#[id] u8, #[id] ...);
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn free(#[id] arg1: u8) { fn free(#[id] arg1: u8) {
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
let lam = |#[id] W(x), #[id] y: usize| (); let lam = |#[id] W(x), #[id] y: usize| ();
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
} }
impl W { impl W {
fn inherent1(#[id] self, #[id] arg1: u8) {} fn inherent1(#[id] self, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn inherent2(#[id] &self, #[id] arg1: u8) {} fn inherent2(#[id] &self, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {} fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
} }
trait A { trait A {
fn trait1(#[id] self, #[id] arg1: u8); fn trait1(#[id] self, #[id] arg1: u8);
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn trait2(#[id] &self, #[id] arg1: u8); fn trait2(#[id] &self, #[id] arg1: u8);
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8);
//~^ ERROR expected an inert attribute, found an attribute macro //~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected an inert attribute, found an attribute macro //~| ERROR expected non-macro attribute, found attribute macro
} }
fn main() {} fn main() {}

View file

@ -1,176 +1,176 @@
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:10:21 --> $DIR/proc-macro-cannot-be-used.rs:10:23
| |
LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:10:38 --> $DIR/proc-macro-cannot-be-used.rs:10:40
| |
LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); } LL | extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:14:38 --> $DIR/proc-macro-cannot-be-used.rs:14:40
| |
LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {} LL | unsafe extern "C" fn cvar(arg1: i32, #[id] mut args: ...) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:17:28 --> $DIR/proc-macro-cannot-be-used.rs:17:30
| |
LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); LL | type Alias = extern "C" fn(#[id] u8, #[id] ...);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:17:38 --> $DIR/proc-macro-cannot-be-used.rs:17:40
| |
LL | type Alias = extern "C" fn(#[id] u8, #[id] ...); LL | type Alias = extern "C" fn(#[id] u8, #[id] ...);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:21:9 --> $DIR/proc-macro-cannot-be-used.rs:21:11
| |
LL | fn free(#[id] arg1: u8) { LL | fn free(#[id] arg1: u8) {
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:23:16 --> $DIR/proc-macro-cannot-be-used.rs:23:18
| |
LL | let lam = |#[id] W(x), #[id] y: usize| (); LL | let lam = |#[id] W(x), #[id] y: usize| ();
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:23:28 --> $DIR/proc-macro-cannot-be-used.rs:23:30
| |
LL | let lam = |#[id] W(x), #[id] y: usize| (); LL | let lam = |#[id] W(x), #[id] y: usize| ();
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:29:18 --> $DIR/proc-macro-cannot-be-used.rs:29:20
| |
LL | fn inherent1(#[id] self, #[id] arg1: u8) {} LL | fn inherent1(#[id] self, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:29:30 --> $DIR/proc-macro-cannot-be-used.rs:29:32
| |
LL | fn inherent1(#[id] self, #[id] arg1: u8) {} LL | fn inherent1(#[id] self, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:32:18 --> $DIR/proc-macro-cannot-be-used.rs:32:20
| |
LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} LL | fn inherent2(#[id] &self, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:32:31 --> $DIR/proc-macro-cannot-be-used.rs:32:33
| |
LL | fn inherent2(#[id] &self, #[id] arg1: u8) {} LL | fn inherent2(#[id] &self, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:35:22 --> $DIR/proc-macro-cannot-be-used.rs:35:24
| |
LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:35:42 --> $DIR/proc-macro-cannot-be-used.rs:35:44
| |
LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {} LL | fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:38:22 --> $DIR/proc-macro-cannot-be-used.rs:38:24
| |
LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {} LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:38:45 --> $DIR/proc-macro-cannot-be-used.rs:38:47
| |
LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {} LL | fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:41:38 --> $DIR/proc-macro-cannot-be-used.rs:41:40
| |
LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:41:54 --> $DIR/proc-macro-cannot-be-used.rs:41:56
| |
LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {} LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {}
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:47:15 --> $DIR/proc-macro-cannot-be-used.rs:47:17
| |
LL | fn trait1(#[id] self, #[id] arg1: u8); LL | fn trait1(#[id] self, #[id] arg1: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:47:27 --> $DIR/proc-macro-cannot-be-used.rs:47:29
| |
LL | fn trait1(#[id] self, #[id] arg1: u8); LL | fn trait1(#[id] self, #[id] arg1: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:50:15 --> $DIR/proc-macro-cannot-be-used.rs:50:17
| |
LL | fn trait2(#[id] &self, #[id] arg1: u8); LL | fn trait2(#[id] &self, #[id] arg1: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:50:28 --> $DIR/proc-macro-cannot-be-used.rs:50:30
| |
LL | fn trait2(#[id] &self, #[id] arg1: u8); LL | fn trait2(#[id] &self, #[id] arg1: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:53:19 --> $DIR/proc-macro-cannot-be-used.rs:53:21
| |
LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:53:39 --> $DIR/proc-macro-cannot-be-used.rs:53:41
| |
LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8); LL | fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:56:19 --> $DIR/proc-macro-cannot-be-used.rs:56:21
| |
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:56:42 --> $DIR/proc-macro-cannot-be-used.rs:56:44
| |
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:56:58 --> $DIR/proc-macro-cannot-be-used.rs:56:60
| |
LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>); LL | fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:60:38 --> $DIR/proc-macro-cannot-be-used.rs:60:40
| |
LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: expected an inert attribute, found an attribute macro error: expected non-macro attribute, found attribute macro `id`
--> $DIR/proc-macro-cannot-be-used.rs:60:54 --> $DIR/proc-macro-cannot-be-used.rs:60:56
| |
LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8); LL | fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8);
| ^^^^^ | ^^ not a non-macro attribute
error: aborting due to 29 previous errors error: aborting due to 29 previous errors

View file

@ -6,7 +6,7 @@
#[foo] #[foo]
mod foo { mod foo {
#![foo] //~ ERROR non-builtin inner attributes are unstable #![foo] //~ ERROR custom inner attributes are unstable
} }
fn main() {} fn main() {}

View file

@ -1,8 +1,8 @@
error[E0658]: non-builtin inner attributes are unstable error[E0658]: custom inner attributes are unstable
--> $DIR/issue-36530.rs:9:5 --> $DIR/issue-36530.rs:9:8
| |
LL | #![foo] LL | #![foo]
| ^^^^^^^ | ^^^
| |
= note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information = note: see issue #54726 <https://github.com/rust-lang/rust/issues/54726> for more information
= help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable