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")
}
/// 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>>(
self,
items: I,
@ -1014,7 +1036,7 @@ fn find_attr_invoc(
attrs: &mut Vec<ast::Attribute>,
after_derive: &mut bool,
) -> Option<ast::Attribute> {
let attr = attrs
attrs
.iter()
.position(|a| {
if a.has_name(sym::derive) {
@ -1022,22 +1044,7 @@ fn find_attr_invoc(
}
!self.cx.sess.is_attr_known(a) && !is_builtin_attr(a)
})
.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
.map(|i| attrs.remove(i))
}
/// If `item` is an attr invocation, remove and return the macro attribute and derive traits.

View file

@ -12,24 +12,24 @@
use rustc_attr::StabilityLevel;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::ptr_key::PtrKey;
use rustc_data_structures::sync::Lrc;
use rustc_errors::struct_span_err;
use rustc_expand::base::{Indeterminate, InvocationRes, ResolverExpand, SyntaxExtension};
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_hir::def::{self, DefKind, NonMacroAttrKind};
use rustc_hir::def_id;
use rustc_middle::middle::stability;
use rustc_middle::ty;
use rustc_session::lint::builtin::UNUSED_MACROS;
use rustc_session::parse::feature_err;
use rustc_session::Session;
use rustc_span::edition::Edition;
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::{Span, DUMMY_SP};
use rustc_data_structures::sync::Lrc;
use rustc_span::hygiene::{AstPass, MacroKind};
use std::cell::Cell;
use std::{mem, ptr};
@ -241,15 +241,20 @@ fn resolve_macro_invocation(
}
};
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, .. } => (
&attr.get_normal_item().path,
MacroKind::Attr,
attr.style == ast::AttrStyle::Inner,
self.arenas.alloc_ast_paths(derives),
after_derive,
),
InvocationKind::Bang { ref mac, .. } => (&mac.path, MacroKind::Bang, &[][..], false),
InvocationKind::Derive { ref path, .. } => (path, MacroKind::Derive, &[][..], false),
InvocationKind::Bang { ref mac, .. } => {
(&mac.path, MacroKind::Bang, false, &[][..], false)
}
InvocationKind::Derive { ref path, .. } => {
(path, MacroKind::Derive, false, &[][..], false)
}
InvocationKind::DeriveContainer { ref derives, .. } => {
// Block expansion of the container until we resolve all derives in it.
// This is required for two reasons:
@ -299,8 +304,17 @@ fn resolve_macro_invocation(
// Derives are not included when `invocations` are collected, so we have to add them here.
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 (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();
invoc_id.set_expn_data(ext.expn_data(
@ -318,29 +332,6 @@ fn resolve_macro_invocation(
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))
}
@ -403,10 +394,14 @@ fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result<bool,
impl<'a> Resolver<'a> {
/// 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(
&mut self,
path: &ast::Path,
kind: MacroKind,
require_inert: bool,
inner_attr: bool,
parent_scope: &ParentScope<'a>,
node_id: NodeId,
force: bool,
@ -414,7 +409,6 @@ fn smart_resolve_macro_path(
let (ext, res) = match self.resolve_macro_path(path, Some(kind), parent_scope, true, force)
{
Ok((Some(ext), res)) => (ext, res),
// Use dummy syntax extensions for unresolved macros for better recovery.
Ok((None, res)) => (self.dummy_ext(kind), res),
Err(Determinacy::Determined) => (self.dummy_ext(kind), Res::Err),
Err(Determinacy::Undetermined) => return Err(Indeterminate),
@ -451,19 +445,43 @@ fn smart_resolve_macro_path(
self.check_stability_and_deprecation(&ext, path, node_id);
Ok(if ext.macro_kind() != kind {
let expected = kind.descr_expected();
let unexpected_res = if ext.macro_kind() != kind {
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 msg = format!("expected {}, found {} `{}`", expected, res.descr(), path_str);
self.session
.struct_span_err(path.span, &msg)
.span_label(path.span, format!("not {} {}", kind.article(), expected))
.span_label(path.span, format!("not {} {}", article, expected))
.emit();
// Use dummy syntax extensions for unexpected macro kinds for better recovery.
(self.dummy_ext(kind), Res::Err)
} else {
(ext, res)
})
return Ok((self.dummy_ext(kind), Res::Err));
}
// 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(

View file

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

View file

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

View file

@ -7,11 +7,11 @@
extern crate test_macros;
fn _test_inner() {
#![empty_attr] //~ ERROR: non-builtin inner attributes are unstable
#![empty_attr] //~ ERROR: inner macro attributes are unstable
}
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

View file

@ -1,17 +1,17 @@
error[E0658]: non-builtin inner attributes are unstable
--> $DIR/proc-macro-gates.rs:10:5
error[E0658]: inner macro attributes are unstable
--> $DIR/proc-macro-gates.rs:10:8
|
LL | #![empty_attr]
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^
|
= 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
error[E0658]: non-builtin inner attributes are unstable
--> $DIR/proc-macro-gates.rs:14:5
error[E0658]: inner macro attributes are unstable
--> $DIR/proc-macro-gates.rs:14:8
|
LL | #![empty_attr]
| ^^^^^^^^^^^^^^
| ^^^^^^^^^^
|
= 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

View file

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

View file

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

View file

@ -3,7 +3,7 @@ fn ffi(
/// Foo
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -19,7 +19,7 @@ fn ffi(
/// Foo
//~^ ERROR documentation comments cannot be applied to function
#[test] a: u32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -34,7 +34,7 @@ pub fn foo(
/// Foo
//~^ ERROR documentation comments cannot be applied to function
#[test] a: u32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -54,7 +54,7 @@ fn foo(
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Baz
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -69,7 +69,7 @@ fn issue_64682_associated_fn(
/// Foo
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Baz
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -90,7 +90,7 @@ fn foo(
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Baz
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -109,7 +109,7 @@ fn foo(
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Baz
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -124,7 +124,7 @@ fn issue_64682_associated_fn(
/// Foo
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Baz
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -144,7 +144,7 @@ fn foo(
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[test] a: i32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Baz
//~^ ERROR documentation comments cannot be applied to function
#[must_use]
@ -161,7 +161,7 @@ fn main() {
/// Foo
//~^ ERROR documentation comments cannot be applied to function
#[test] a: u32,
//~^ ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
/// Bar
//~^ ERROR documentation comments cannot be applied to function
#[must_use]

View file

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

View file

@ -8,58 +8,58 @@
struct W(u8);
extern "C" { fn ffi(#[id] arg1: i32, #[id] ...); }
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
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] ...);
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
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| ();
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
}
impl W {
fn inherent1(#[id] self, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn inherent2(#[id] &self, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn inherent3<'a>(#[id] &'a mut self, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn inherent4<'a>(#[id] self: Box<Self>, #[id] arg1: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8) {}
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
}
trait A {
fn trait1(#[id] self, #[id] arg1: u8);
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn trait2(#[id] &self, #[id] arg1: u8);
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn trait3<'a>(#[id] &'a mut self, #[id] arg1: u8);
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn trait4<'a>(#[id] self: Box<Self>, #[id] arg1: u8, #[id] Vec<u8>);
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
fn issue_64682_associated_fn<'a>(#[id] arg1: u8, #[id] arg2: u8);
//~^ ERROR expected an inert attribute, found an attribute macro
//~| ERROR expected an inert attribute, found an attribute macro
//~^ ERROR expected non-macro attribute, found attribute macro
//~| ERROR expected non-macro attribute, found attribute macro
}
fn main() {}

View file

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

View file

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

View file

@ -1,8 +1,8 @@
error[E0658]: non-builtin inner attributes are unstable
--> $DIR/issue-36530.rs:9:5
error[E0658]: custom inner attributes are unstable
--> $DIR/issue-36530.rs:9:8
|
LL | #![foo]
| ^^^^^^^
| ^^^
|
= 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