From 23e9a1def59ae7cc852181e9395cb467ffdbd46e Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 15 Aug 2018 03:51:12 +0300 Subject: [PATCH] resolve: Consolidate error reporting for resolved macros in `fn resolve_macro_to_def` --- src/librustc_resolve/lib.rs | 2 +- src/librustc_resolve/macros.rs | 204 ++++++++---------- .../passes/collect_intra_doc_links.rs | 4 +- src/libsyntax/ext/base.rs | 19 +- src/libsyntax/ext/expand.rs | 15 +- .../proc-macro/proc-macro-gates.rs | 2 +- .../macro-namespace-reserved-2.stderr | 18 +- ...r-unknown-attribute-macro-expansion.stderr | 2 +- src/test/ui/custom_attribute.stderr | 12 +- .../feature-gate-custom_attribute.stderr | 52 ++--- .../feature-gate-custom_derive.stderr | 4 +- .../feature-gate-rustc-attrs.stderr | 4 +- .../feature-gate-tool_attributes.stderr | 4 +- src/test/ui/issues/issue-32655.stderr | 8 +- src/test/ui/issues/issue-49074.stderr | 4 +- .../ui/macros/macro-reexport-removed.stderr | 4 +- .../ui/reserved/reserved-attr-on-macro.stderr | 4 +- src/test/ui/span/issue-36530.stderr | 8 +- 18 files changed, 172 insertions(+), 198 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 71a7fde2029..7de6358613b 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1399,7 +1399,7 @@ pub struct Resolver<'a, 'b: 'a> { proc_mac_errors: Vec, /// crate-local macro expanded `macro_export` referred to by a module-relative path macro_expanded_macro_export_errors: BTreeSet<(Span, Span)>, - + /// macro-expanded `macro_rules` shadowing existing macros disallowed_shadowing: Vec<&'a LegacyBinding<'a>>, arenas: &'a ResolverArenas<'a>, diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 2b1ccff534d..d4d1f91a48e 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -319,9 +319,9 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> { None } - fn resolve_invoc(&mut self, invoc: &Invocation, scope: Mark, force: bool) - -> Result>, Determinacy> { - let (path, macro_kind, derives_in_scope) = match invoc.kind { + fn resolve_macro_invocation(&mut self, invoc: &Invocation, scope: Mark, force: bool) + -> Result>, Determinacy> { + let (path, kind, derives_in_scope) = match invoc.kind { InvocationKind::Attr { attr: None, .. } => return Ok(None), InvocationKind::Attr { attr: Some(ref attr), ref traits, .. } => @@ -331,90 +331,26 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> { InvocationKind::Derive { ref path, .. } => (path, MacroKind::Derive, &[][..]), }; - let def = self.resolve_macro_to_def(scope, path, macro_kind, derives_in_scope, force)?; - if let Def::Macro(_, MacroKind::ProcMacroStub) = def { - self.report_proc_macro_stub(invoc.span()); - return Err(Determinacy::Determined); - } else if let Def::NonMacroAttr(attr_kind) = def { - // Note that not only attributes, but anything in macro namespace can result in a - // `Def::NonMacroAttr` definition (e.g. `inline!()`), so we must report the error - // below for these cases. - let is_attr_invoc = - if let InvocationKind::Attr { .. } = invoc.kind { true } else { false }; - let path = invoc.path().expect("no path for non-macro attr"); - match attr_kind { - NonMacroAttrKind::Tool | NonMacroAttrKind::DeriveHelper | - NonMacroAttrKind::Custom if is_attr_invoc => { - let features = self.session.features_untracked(); - if attr_kind == NonMacroAttrKind::Tool && - !features.tool_attributes { - feature_err(&self.session.parse_sess, "tool_attributes", - invoc.span(), GateIssue::Language, - "tool attributes are unstable").emit(); - } - if attr_kind == NonMacroAttrKind::Custom { - assert!(path.segments.len() == 1); - let name = path.segments[0].ident.name.as_str(); - if name.starts_with("rustc_") { - if !features.rustc_attrs { - let msg = "unless otherwise specified, attributes with the prefix \ - `rustc_` are reserved for internal compiler diagnostics"; - feature_err(&self.session.parse_sess, "rustc_attrs", invoc.span(), - GateIssue::Language, &msg).emit(); - } - } else if name.starts_with("derive_") { - if !features.custom_derive { - feature_err(&self.session.parse_sess, "custom_derive", invoc.span(), - GateIssue::Language, EXPLAIN_DERIVE_UNDERSCORE).emit(); - } - } else if !features.custom_attribute { - let msg = format!("The attribute `{}` is currently unknown to the \ - compiler and may have meaning added to it in the \ - future", path); - feature_err(&self.session.parse_sess, "custom_attribute", invoc.span(), - GateIssue::Language, &msg).emit(); - } - } + let (def, ext) = self.resolve_macro_to_def(path, kind, scope, derives_in_scope, force)?; - return Ok(Some(Lrc::new(SyntaxExtension::NonMacroAttr { - mark_used: attr_kind == NonMacroAttrKind::Tool, - }))); - } - _ => { - self.report_non_macro_attr(path.span, def); - return Err(Determinacy::Determined); - } - } + if let Def::Macro(def_id, _) = def { + self.macro_defs.insert(invoc.expansion_data.mark, def_id); + let normal_module_def_id = + self.macro_def_scope(invoc.expansion_data.mark).normal_ancestor_id; + self.definitions.add_parent_module_of_macro_def(invoc.expansion_data.mark, + normal_module_def_id); + invoc.expansion_data.mark.set_default_transparency(ext.default_transparency()); + invoc.expansion_data.mark.set_is_builtin(def_id.krate == BUILTIN_MACROS_CRATE); } - let def_id = def.def_id(); - self.macro_defs.insert(invoc.expansion_data.mark, def_id); - let normal_module_def_id = - self.macro_def_scope(invoc.expansion_data.mark).normal_ancestor_id; - self.definitions.add_parent_module_of_macro_def(invoc.expansion_data.mark, - normal_module_def_id); - - self.unused_macros.remove(&def_id); - let ext = self.get_macro(def); - invoc.expansion_data.mark.set_default_transparency(ext.default_transparency()); - invoc.expansion_data.mark.set_is_builtin(def_id.krate == BUILTIN_MACROS_CRATE); Ok(Some(ext)) } - fn resolve_macro(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, force: bool) - -> Result, Determinacy> { - self.resolve_macro_to_def(scope, path, kind, &[], force).and_then(|def| { - if let Def::Macro(_, MacroKind::ProcMacroStub) = def { - self.report_proc_macro_stub(path.span); - return Err(Determinacy::Determined); - } else if let Def::NonMacroAttr(..) = def { - self.report_non_macro_attr(path.span, def); - return Err(Determinacy::Determined); - } - self.unused_macros.remove(&def.def_id()); - Ok(self.get_macro(def)) - }) + fn resolve_macro_path(&mut self, path: &ast::Path, kind: MacroKind, scope: Mark, + derives_in_scope: &[ast::Path], force: bool) + -> Result, Determinacy> { + Ok(self.resolve_macro_to_def(path, kind, scope, derives_in_scope, force)?.1) } fn check_unused_macros(&self) { @@ -436,43 +372,89 @@ impl<'a, 'crateloader: 'a> base::Resolver for Resolver<'a, 'crateloader> { } impl<'a, 'cl> Resolver<'a, 'cl> { - fn report_proc_macro_stub(&self, span: Span) { - self.session.span_err(span, - "can't use a procedural macro from the same crate that defines it"); - } - - fn report_non_macro_attr(&self, span: Span, def: Def) { - self.session.span_err(span, &format!("expected a macro, found {}", def.kind_name())); - } - - fn resolve_macro_to_def(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, + fn resolve_macro_to_def(&mut self, path: &ast::Path, kind: MacroKind, scope: Mark, derives_in_scope: &[ast::Path], force: bool) - -> Result { - let def = self.resolve_macro_to_def_inner(scope, path, kind, derives_in_scope, force); + -> Result<(Def, Lrc), Determinacy> { + let def = self.resolve_macro_to_def_inner(path, kind, scope, derives_in_scope, force); + + // Report errors and enforce feature gates for the resolved macro. if def != Err(Determinacy::Undetermined) { // Do not report duplicated errors on every undetermined resolution. - path.segments.iter().find(|segment| segment.args.is_some()).map(|segment| { - self.session.span_err(segment.args.as_ref().unwrap().span(), - "generic arguments in macro path"); - }); - } - if kind != MacroKind::Bang && path.segments.len() > 1 && - def != Ok(Def::NonMacroAttr(NonMacroAttrKind::Tool)) { - if !self.session.features_untracked().proc_macro_path_invoc { - emit_feature_err( - &self.session.parse_sess, - "proc_macro_path_invoc", - path.span, - GateIssue::Language, - "paths of length greater than one in macro invocations are \ - currently unstable", - ); + for segment in &path.segments { + if let Some(args) = &segment.args { + self.session.span_err(args.span(), "generic arguments in macro path"); + } } } - def + + let def = def?; + + if path.segments.len() > 1 { + if kind != MacroKind::Bang { + if def != Def::NonMacroAttr(NonMacroAttrKind::Tool) && + !self.session.features_untracked().proc_macro_path_invoc { + let msg = format!("non-ident {} paths are unstable", kind.descr()); + emit_feature_err(&self.session.parse_sess, "proc_macro_path_invoc", + path.span, GateIssue::Language, &msg); + } + } + } + + match def { + Def::Macro(def_id, macro_kind) => { + self.unused_macros.remove(&def_id); + if macro_kind == MacroKind::ProcMacroStub { + let msg = "can't use a procedural macro from the same crate that defines it"; + self.session.span_err(path.span, msg); + return Err(Determinacy::Determined); + } + } + Def::NonMacroAttr(attr_kind) => { + if kind == MacroKind::Attr { + let features = self.session.features_untracked(); + if attr_kind == NonMacroAttrKind::Tool && !features.tool_attributes { + feature_err(&self.session.parse_sess, "tool_attributes", path.span, + GateIssue::Language, "tool attributes are unstable").emit(); + } + if attr_kind == NonMacroAttrKind::Custom { + assert!(path.segments.len() == 1); + let name = path.segments[0].ident.name.as_str(); + if name.starts_with("rustc_") { + if !features.rustc_attrs { + let msg = "unless otherwise specified, attributes with the prefix \ + `rustc_` are reserved for internal compiler diagnostics"; + feature_err(&self.session.parse_sess, "rustc_attrs", path.span, + GateIssue::Language, &msg).emit(); + } + } else if name.starts_with("derive_") { + if !features.custom_derive { + feature_err(&self.session.parse_sess, "custom_derive", path.span, + GateIssue::Language, EXPLAIN_DERIVE_UNDERSCORE).emit(); + } + } else if !features.custom_attribute { + let msg = format!("The attribute `{}` is currently unknown to the \ + compiler and may have meaning added to it in the \ + future", path); + feature_err(&self.session.parse_sess, "custom_attribute", path.span, + GateIssue::Language, &msg).emit(); + } + } + } else { + // Not only attributes, but anything in macro namespace can result in + // `Def::NonMacroAttr` definition (e.g. `inline!()`), so we must report + // an error for those cases. + let msg = format!("expected a macro, found {}", def.kind_name()); + self.session.span_err(path.span, &msg); + return Err(Determinacy::Determined); + } + } + _ => panic!("expected `Def::Macro` or `Def::NonMacroAttr`"), + } + + Ok((def, self.get_macro(def))) } - pub fn resolve_macro_to_def_inner(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, + pub fn resolve_macro_to_def_inner(&mut self, path: &ast::Path, kind: MacroKind, scope: Mark, derives_in_scope: &[ast::Path], force: bool) -> Result { let ast::Path { ref segments, span } = *path; @@ -550,7 +532,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { enum ConvertToDeriveHelper { Yes, No, DontKnow } let mut convert_to_derive_helper = ConvertToDeriveHelper::No; for derive in derives_in_scope { - match self.resolve_macro(scope, derive, MacroKind::Derive, force) { + match self.resolve_macro_path(derive, MacroKind::Derive, scope, &[], force) { Ok(ext) => if let SyntaxExtension::ProcMacroDerive(_, ref inert_attrs, _) = *ext { if inert_attrs.contains(&path[0].name) { convert_to_derive_helper = ConvertToDeriveHelper::Yes; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 9b9848f794d..c00d67aaab6 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -403,9 +403,7 @@ fn macro_resolve(cx: &DocContext, path_str: &str) -> Option { let path = ast::Path { segments: vec![segment], span: DUMMY_SP }; let mut resolver = cx.resolver.borrow_mut(); let mark = Mark::root(); - let res = resolver - .resolve_macro_to_def_inner(mark, &path, MacroKind::Bang, &[], false); - if let Ok(def) = res { + if let Ok(def) = resolver.resolve_macro_to_def_inner(&path, MacroKind::Bang, mark, &[], false) { if let SyntaxExtension::DeclMacro { .. } = *resolver.get_macro(def) { return Some(def); } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 154fe11dd35..c9925b41498 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -727,10 +727,12 @@ pub trait Resolver { fn find_legacy_attr_invoc(&mut self, attrs: &mut Vec, allow_derive: bool) -> Option; - fn resolve_invoc(&mut self, invoc: &Invocation, scope: Mark, force: bool) - -> Result>, Determinacy>; - fn resolve_macro(&mut self, scope: Mark, path: &ast::Path, kind: MacroKind, force: bool) - -> Result, Determinacy>; + fn resolve_macro_invocation(&mut self, invoc: &Invocation, scope: Mark, force: bool) + -> Result>, Determinacy>; + fn resolve_macro_path(&mut self, path: &ast::Path, kind: MacroKind, scope: Mark, + derives_in_scope: &[ast::Path], force: bool) + -> Result, Determinacy>; + fn check_unused_macros(&self); } @@ -761,12 +763,13 @@ impl Resolver for DummyResolver { fn resolve_imports(&mut self) {} fn find_legacy_attr_invoc(&mut self, _attrs: &mut Vec, _allow_derive: bool) -> Option { None } - fn resolve_invoc(&mut self, _invoc: &Invocation, _scope: Mark, _force: bool) - -> Result>, Determinacy> { + fn resolve_macro_invocation(&mut self, _invoc: &Invocation, _scope: Mark, _force: bool) + -> Result>, Determinacy> { Err(Determinacy::Determined) } - fn resolve_macro(&mut self, _scope: Mark, _path: &ast::Path, _kind: MacroKind, - _force: bool) -> Result, Determinacy> { + fn resolve_macro_path(&mut self, _path: &ast::Path, _kind: MacroKind, _scope: Mark, + _derives_in_scope: &[ast::Path], _force: bool) + -> Result, Determinacy> { Err(Determinacy::Determined) } fn check_unused_macros(&self) {} diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b12b2c49caa..66be1b0ae75 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -243,15 +243,6 @@ impl Invocation { InvocationKind::Derive { ref path, .. } => path.span, } } - - pub fn path(&self) -> Option<&Path> { - match self.kind { - InvocationKind::Bang { ref mac, .. } => Some(&mac.node.path), - InvocationKind::Attr { attr: Some(ref attr), .. } => Some(&attr.path), - InvocationKind::Attr { attr: None, .. } => None, - InvocationKind::Derive { ref path, .. } => Some(path), - } - } } pub struct MacroExpander<'a, 'b:'a> { @@ -343,7 +334,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let scope = if self.monotonic { invoc.expansion_data.mark } else { orig_expansion_data.mark }; - let ext = match self.cx.resolver.resolve_invoc(&invoc, scope, force) { + let ext = match self.cx.resolver.resolve_macro_invocation(&invoc, scope, force) { Ok(ext) => Some(ext), Err(Determinacy::Determined) => None, Err(Determinacy::Undetermined) => { @@ -393,8 +384,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { for path in &traits { let mark = Mark::fresh(self.cx.current_expansion.mark); derives.push(mark); - let item = match self.cx.resolver.resolve_macro( - Mark::root(), path, MacroKind::Derive, false) { + let item = match self.cx.resolver.resolve_macro_path( + path, MacroKind::Derive, Mark::root(), &[], false) { Ok(ext) => match *ext { BuiltinDerive(..) => item_with_markers.clone(), _ => item.clone(), diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs index 0798aa549f0..96f68341db7 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs @@ -22,7 +22,7 @@ extern crate proc_macro_gates as foo; use foo::*; -#[foo::a] //~ ERROR: paths of length greater than one +#[foo::a] //~ ERROR: non-ident attribute macro paths are unstable fn _test() {} fn _test_inner() { diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr index 342d7ddb36c..046e7dc8bfe 100644 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr +++ b/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr @@ -2,37 +2,37 @@ error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:34:5 | LL | my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^^ + | ^^^^^^^^ error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:37:5 | LL | my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:40:5 | LL | MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^ + | ^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:43:1 + --> $DIR/macro-namespace-reserved-2.rs:44:3 | LL | #[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^ + | ^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:45:1 + --> $DIR/macro-namespace-reserved-2.rs:46:3 | LL | #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:47:1 + --> $DIR/macro-namespace-reserved-2.rs:48:3 | LL | #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^ + | ^^^^^^^ error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:50:10 diff --git a/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr b/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr index 33fe52366db..0f51c7d68c6 100644 --- a/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr +++ b/src/test/ui/cfg-attr-unknown-attribute-macro-expansion.stderr @@ -2,7 +2,7 @@ error[E0658]: The attribute `unknown` is currently unknown to the compiler and m --> $DIR/cfg-attr-unknown-attribute-macro-expansion.rs:13:27 | LL | #[cfg_attr(all(), unknown)] //~ ERROR `unknown` is currently unknown - | ^^^^^^^^ + | ^^^^^^^ ... LL | foo!(); | ------- in this macro invocation diff --git a/src/test/ui/custom_attribute.stderr b/src/test/ui/custom_attribute.stderr index 4adfe1e450e..6ecad7d79b8 100644 --- a/src/test/ui/custom_attribute.stderr +++ b/src/test/ui/custom_attribute.stderr @@ -1,24 +1,24 @@ error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/custom_attribute.rs:13:1 + --> $DIR/custom_attribute.rs:13:3 | LL | #[foo] //~ ERROR The attribute `foo` - | ^^^^^^ + | ^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/custom_attribute.rs:15:5 + --> $DIR/custom_attribute.rs:15:7 | LL | #[foo] //~ ERROR The attribute `foo` - | ^^^^^^ + | ^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/custom_attribute.rs:17:5 + --> $DIR/custom_attribute.rs:17:7 | LL | #[foo] //~ ERROR The attribute `foo` - | ^^^^^^ + | ^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr b/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr index 36f5898f1c7..e60e9a342a9 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr +++ b/src/test/ui/feature-gates/feature-gate-custom_attribute.stderr @@ -1,104 +1,104 @@ error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:17:1 + --> $DIR/feature-gate-custom_attribute.rs:17:3 | LL | #[fake_attr] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:18:1 + --> $DIR/feature-gate-custom_attribute.rs:18:3 | LL | #[fake_attr(100)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:19:1 + --> $DIR/feature-gate-custom_attribute.rs:19:3 | LL | #[fake_attr(1, 2, 3)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:20:1 + --> $DIR/feature-gate-custom_attribute.rs:20:3 | LL | #[fake_attr("hello")] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:21:1 + --> $DIR/feature-gate-custom_attribute.rs:21:3 | LL | #[fake_attr(name = "hello")] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:22:1 + --> $DIR/feature-gate-custom_attribute.rs:22:3 | LL | #[fake_attr(1, "hi", key = 12, true, false)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:23:1 + --> $DIR/feature-gate-custom_attribute.rs:23:3 | LL | #[fake_attr(key = "hello", val = 10)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:24:1 + --> $DIR/feature-gate-custom_attribute.rs:24:3 | LL | #[fake_attr(key("hello"), val(10))] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:25:1 + --> $DIR/feature-gate-custom_attribute.rs:25:3 | LL | #[fake_attr(enabled = true, disabled = false)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:26:1 + --> $DIR/feature-gate-custom_attribute.rs:26:3 | LL | #[fake_attr(true)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:27:1 + --> $DIR/feature-gate-custom_attribute.rs:27:3 | LL | #[fake_attr(pi = 3.14159)] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_attr` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:28:1 + --> $DIR/feature-gate-custom_attribute.rs:28:3 | LL | #[fake_attr(b"hi")] //~ ERROR attribute `fake_attr` is currently unknown - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `fake_doc` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/feature-gate-custom_attribute.rs:29:1 + --> $DIR/feature-gate-custom_attribute.rs:29:3 | LL | #[fake_doc(r"doc")] //~ ERROR attribute `fake_doc` is currently unknown - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-custom_derive.stderr b/src/test/ui/feature-gates/feature-gate-custom_derive.stderr index e633a5a9c99..0979372daea 100644 --- a/src/test/ui/feature-gates/feature-gate-custom_derive.stderr +++ b/src/test/ui/feature-gates/feature-gate-custom_derive.stderr @@ -1,8 +1,8 @@ error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644) - --> $DIR/feature-gate-custom_derive.rs:11:1 + --> $DIR/feature-gate-custom_derive.rs:11:3 | LL | #[derive_Clone] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add #![feature(custom_derive)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr index 52a4d3664ce..882549c1eaf 100644 --- a/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr +++ b/src/test/ui/feature-gates/feature-gate-rustc-attrs.stderr @@ -1,8 +1,8 @@ error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) - --> $DIR/feature-gate-rustc-attrs.rs:15:1 + --> $DIR/feature-gate-rustc-attrs.rs:15:3 | LL | #[rustc_foo] - | ^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(rustc_attrs)] to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-tool_attributes.stderr b/src/test/ui/feature-gates/feature-gate-tool_attributes.stderr index ca9542dcc95..b024059d450 100644 --- a/src/test/ui/feature-gates/feature-gate-tool_attributes.stderr +++ b/src/test/ui/feature-gates/feature-gate-tool_attributes.stderr @@ -1,8 +1,8 @@ error[E0658]: tool attributes are unstable (see issue #44690) - --> $DIR/feature-gate-tool_attributes.rs:12:5 + --> $DIR/feature-gate-tool_attributes.rs:12:7 | LL | #[rustfmt::skip] //~ ERROR tool attributes are unstable - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = help: add #![feature(tool_attributes)] to the crate attributes to enable diff --git a/src/test/ui/issues/issue-32655.stderr b/src/test/ui/issues/issue-32655.stderr index a1323808a91..f930217fe9e 100644 --- a/src/test/ui/issues/issue-32655.stderr +++ b/src/test/ui/issues/issue-32655.stderr @@ -1,8 +1,8 @@ error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644) - --> $DIR/issue-32655.rs:16:9 + --> $DIR/issue-32655.rs:16:11 | LL | #[derive_Clone] //~ ERROR attributes of the form - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ ... LL | foo!(); | ------- in this macro invocation @@ -10,10 +10,10 @@ LL | foo!(); = help: add #![feature(custom_derive)] to the crate attributes to enable error[E0658]: attributes of the form `#[derive_*]` are reserved for the compiler (see issue #29644) - --> $DIR/issue-32655.rs:28:5 + --> $DIR/issue-32655.rs:28:7 | LL | #[derive_Clone] //~ ERROR attributes of the form - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add #![feature(custom_derive)] to the crate attributes to enable diff --git a/src/test/ui/issues/issue-49074.stderr b/src/test/ui/issues/issue-49074.stderr index 888222b69cc..6c9d1eac356 100644 --- a/src/test/ui/issues/issue-49074.stderr +++ b/src/test/ui/issues/issue-49074.stderr @@ -1,8 +1,8 @@ error[E0658]: The attribute `marco_use` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/issue-49074.rs:13:1 + --> $DIR/issue-49074.rs:13:3 | LL | #[marco_use] // typo - | ^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable diff --git a/src/test/ui/macros/macro-reexport-removed.stderr b/src/test/ui/macros/macro-reexport-removed.stderr index c93c7144f9e..8f954158a63 100644 --- a/src/test/ui/macros/macro-reexport-removed.stderr +++ b/src/test/ui/macros/macro-reexport-removed.stderr @@ -11,10 +11,10 @@ LL | #![feature(macro_reexport)] //~ ERROR feature has been removed | ^^^^^^^^^^^^^^ error[E0658]: The attribute `macro_reexport` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/macro-reexport-removed.rs:15:1 + --> $DIR/macro-reexport-removed.rs:15:3 | LL | #[macro_reexport(macro_one)] //~ ERROR attribute `macro_reexport` is currently unknown - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable diff --git a/src/test/ui/reserved/reserved-attr-on-macro.stderr b/src/test/ui/reserved/reserved-attr-on-macro.stderr index e8bfcc04f48..efcd1ec67d7 100644 --- a/src/test/ui/reserved/reserved-attr-on-macro.stderr +++ b/src/test/ui/reserved/reserved-attr-on-macro.stderr @@ -1,8 +1,8 @@ error[E0658]: unless otherwise specified, attributes with the prefix `rustc_` are reserved for internal compiler diagnostics (see issue #29642) - --> $DIR/reserved-attr-on-macro.rs:11:1 + --> $DIR/reserved-attr-on-macro.rs:11:3 | LL | #[rustc_attribute_should_be_reserved] //~ ERROR attributes with the prefix `rustc_` are reserved - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add #![feature(rustc_attrs)] to the crate attributes to enable diff --git a/src/test/ui/span/issue-36530.stderr b/src/test/ui/span/issue-36530.stderr index cbec4f6b0a6..e7dd8e7aa8f 100644 --- a/src/test/ui/span/issue-36530.stderr +++ b/src/test/ui/span/issue-36530.stderr @@ -1,16 +1,16 @@ error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/issue-36530.rs:11:1 + --> $DIR/issue-36530.rs:11:3 | LL | #[foo] //~ ERROR is currently unknown to the compiler - | ^^^^^^ + | ^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable error[E0658]: The attribute `foo` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642) - --> $DIR/issue-36530.rs:13:5 + --> $DIR/issue-36530.rs:13:8 | LL | #![foo] //~ ERROR is currently unknown to the compiler - | ^^^^^^^ + | ^^^ | = help: add #![feature(custom_attribute)] to the crate attributes to enable