From 60f733ec6e04aafd5fe1f31632d02b863f249aed Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 7 Jun 2024 20:42:31 +0300 Subject: [PATCH] WIP --- compiler/rustc_lint/messages.ftl | 2 + .../rustc_lint/src/context/diagnostics.rs | 3 + compiler/rustc_lint/src/lints.rs | 6 + compiler/rustc_lint_defs/src/builtin.rs | 37 ++++++ compiler/rustc_lint_defs/src/lib.rs | 3 + .../rustc_resolve/src/build_reduced_graph.rs | 19 ++- compiler/rustc_resolve/src/diagnostics.rs | 1 + compiler/rustc_resolve/src/ident.rs | 1 + compiler/rustc_resolve/src/late.rs | 2 +- compiler/rustc_resolve/src/macros.rs | 73 ++++++++++-- .../key-value-expansion-scope-pass.rs | 16 +++ .../attributes/key-value-expansion-scope.rs | 12 +- .../key-value-expansion-scope.stderr | 110 +++++++++++------- .../proc-macro/ambiguous-builtin-attrs.stderr | 30 ++--- 14 files changed, 240 insertions(+), 75 deletions(-) create mode 100644 tests/ui/attributes/key-value-expansion-scope-pass.rs diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index da1f36112ab38..118a12ed5493f 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -603,6 +603,8 @@ lint_opaque_hidden_inferred_bound_sugg = add this bound lint_or_patterns_back_compat = the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro .suggestion = use pat_param to preserve semantics +lint_out_of_scope_macro_calls = cannot find macro `{$path}` in this scope + lint_overflowing_bin_hex = literal out of range for `{$ty}` .negative_note = the literal `{$lit}` (decimal `{$dec}`) does not fit into the type `{$ty}` .negative_becomes_note = and the value `-{$lit}` will become `{$actually}{$ty}` diff --git a/compiler/rustc_lint/src/context/diagnostics.rs b/compiler/rustc_lint/src/context/diagnostics.rs index 290bb5173dbe7..e8bad575fe49d 100644 --- a/compiler/rustc_lint/src/context/diagnostics.rs +++ b/compiler/rustc_lint/src/context/diagnostics.rs @@ -424,5 +424,8 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: & lints::InnerAttributeUnstable::CustomInnerAttribute } .decorate_lint(diag), + BuiltinLintDiag::OutOfScopeMacroCalls { path } => { + lints::OutOfScopeMacroCalls { path }.decorate_lint(diag) + } } } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index f60f8f7c6b7f4..8f1c6fca5fe0b 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -2888,3 +2888,9 @@ pub struct RedundantImportVisibility { pub import_vis: String, pub max_vis: String, } + +#[derive(LintDiagnostic)] +#[diag(lint_out_of_scope_macro_calls)] +pub struct OutOfScopeMacroCalls { + pub path: String, +} diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 1913b9d6a1c31..392969a9f58ea 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4902,3 +4902,40 @@ declare_lint! { reference: "issue #123743 ", }; } + +declare_lint! { + /// The `missing_unsafe_on_extern` lint detects missing unsafe keyword on extern declarations. + /// + /// ### Example + /// + /// ```rust + /// #![feature(unsafe_extern_blocks)] + /// #![warn(missing_unsafe_on_extern)] + /// #![allow(dead_code)] + /// + /// extern "C" { + /// fn foo(_: i32); + /// } + /// + /// fn main() {} + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Declaring extern items, even without ever using them, can cause Undefined Behavior. We + /// should consider all sources of Undefined Behavior to be unsafe. + /// + /// This is a [future-incompatible] lint to transition this to a + /// hard error in the future. + /// + /// [future-incompatible]: ../index.md#future-incompatible-lints + pub OUT_OF_SCOPE_MACRO_CALLS, + Deny, + "detects out of scope calls to `macro_rules` in key-value attributes", + @future_incompatible = FutureIncompatibleInfo { + reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, + reference: "issue #124535 ", + }; +} diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 70330c4457766..b4a8f7cbc9eb4 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -742,6 +742,9 @@ pub enum BuiltinLintDiag { InnerAttributeUnstable { is_macro: bool, }, + OutOfScopeMacroCalls { + path: String, + }, } /// Lints that are buffered up early on in the `Session` before the diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 689109b2840f8..82547ac3653f3 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -14,7 +14,7 @@ use crate::{Determinacy, ExternPreludeEntry, Finalize, Module, ModuleKind, Modul use crate::{NameBinding, NameBindingKind, ParentScope, PathResult, ResolutionError}; use crate::{Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError}; -use rustc_ast::visit::{self, AssocCtxt, Visitor}; +use rustc_ast::visit::{self, AssocCtxt, Visitor, WalkItemKind}; use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind}; use rustc_ast::{Block, ForeignItem, ForeignItemKind, Impl, Item, ItemKind, NodeId}; use rustc_attr as attr; @@ -1312,7 +1312,17 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> { _ => { let orig_macro_rules_scope = self.parent_scope.macro_rules; self.build_reduced_graph_for_item(item); - visit::walk_item(self, item); + match item.kind { + ItemKind::Mod(..) => { + // Visit attributes after items for backward compatibility. + // This way they can use `macro_rules` defined later. + self.visit_vis(&item.vis); + self.visit_ident(item.ident); + item.kind.walk(item, AssocCtxt::Trait, self); + visit::walk_list!(self, visit_attribute, &item.attrs); + } + _ => visit::walk_item(self, item), + } match item.kind { ItemKind::Mod(..) if self.contains_macro_use(&item.attrs) => { self.parent_scope.macro_rules @@ -1502,7 +1512,10 @@ impl<'a, 'b, 'tcx> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b, 'tcx> { if krate.is_placeholder { self.visit_invoc_in_module(krate.id); } else { - visit::walk_crate(self, krate); + // Visit attributes after items for backward compatibility. + // This way they can use `macro_rules` defined later. + visit::walk_list!(self, visit_item, &krate.items); + visit::walk_list!(self, visit_attribute, &krate.attrs); self.contains_macro_use(&krate.attrs); } } diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 8d470c6c61ef4..8470beba54bce 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1046,6 +1046,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { parent_scope, false, false, + None, ) { suggestions.extend( ext.helper_attrs diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index b6a23317dc99d..9405bc62cc83a 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -457,6 +457,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { parent_scope, true, force, + None, ) { Ok((Some(ext), _)) => { if ext.helper_attrs.contains(&ident.name) { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index c1e83c59f98ce..b2d1d28d7cc88 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -4144,7 +4144,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { let path_seg = |seg: &Segment| PathSegment::from_ident(seg.ident); let path = Path { segments: path.iter().map(path_seg).collect(), span, tokens: None }; if let Ok((_, res)) = - self.r.resolve_macro_path(&path, None, &self.parent_scope, false, false) + self.r.resolve_macro_path(&path, None, &self.parent_scope, false, false, None) { return Ok(Some(PartialRes::new(res))); } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 268e7f06d0423..5a1c81a8fe801 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -5,7 +5,7 @@ use crate::errors::CannotDetermineMacroResolution; use crate::errors::{self, AddAsNonDerive, CannotFindIdentInThisScope}; use crate::errors::{MacroExpectedFound, RemoveSurroundingDerive}; use crate::Namespace::*; -use crate::{BuiltinMacroState, Determinacy, MacroData, Used}; +use crate::{BuiltinMacroState, Determinacy, MacroData, NameBindingKind, Used}; use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet}; use crate::{ModuleKind, ModuleOrUniformRoot, NameBinding, PathResult, Segment, ToNameBinding}; use rustc_ast::expand::StrippedCfgItem; @@ -18,15 +18,18 @@ use rustc_errors::{Applicability, StashKey}; use rustc_expand::base::{Annotatable, DeriveResolution, Indeterminate, ResolverExpand}; use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::compile_declarative_macro; -use rustc_expand::expand::{AstFragment, Invocation, InvocationKind, SupportsMacroExpansion}; +use rustc_expand::expand::{ + AstFragment, AstFragmentKind, Invocation, InvocationKind, SupportsMacroExpansion, +}; use rustc_hir::def::{self, DefKind, Namespace, NonMacroAttrKind}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_middle::middle::stability; use rustc_middle::ty::RegisteredTools; use rustc_middle::ty::{TyCtxt, Visibility}; -use rustc_session::lint::builtin::UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES; -use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE}; -use rustc_session::lint::builtin::{UNUSED_MACROS, UNUSED_MACRO_RULES}; +use rustc_session::lint::builtin::{ + LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE, + UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACROS, UNUSED_MACRO_RULES, +}; use rustc_session::lint::BuiltinLintDiag; use rustc_session::parse::feature_err; use rustc_span::edit_distance::edit_distance; @@ -277,6 +280,15 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> { let parent_scope = &ParentScope { derives, ..parent_scope }; let supports_macro_expansion = invoc.fragment_kind.supports_macro_expansion(); let node_id = invoc.expansion_data.lint_node_id; + let invoc_in_mod_inert_attr = self + .invocation_parents + .get(&invoc_id) + .or_else(|| self.invocation_parents.get(&eager_expansion_root)) + .map(|&(mod_def_id, _)| mod_def_id) + .filter(|&mod_def_id| { + invoc.fragment_kind == AstFragmentKind::Expr + && self.tcx.def_kind(mod_def_id) == DefKind::Mod + }); let (ext, res) = self.smart_resolve_macro_path( path, kind, @@ -286,6 +298,7 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> { node_id, force, soft_custom_inner_attributes_gate(path, invoc), + invoc_in_mod_inert_attr, )?; let span = invoc.span(); @@ -366,6 +379,7 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> { &parent_scope, true, force, + None, ) { Ok((Some(ext), _)) => { if !ext.helper_attrs.is_empty() { @@ -468,9 +482,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { node_id: NodeId, force: bool, soft_custom_inner_attributes_gate: bool, + invoc_in_mod_inert_attr: Option, ) -> Result<(Lrc, Res), Indeterminate> { - 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, + invoc_in_mod_inert_attr.map(|def_id| (def_id, node_id)), + ) { Ok((Some(ext), res)) => (ext, res), Ok((None, res)) => (self.dummy_ext(kind), res), Err(Determinacy::Determined) => (self.dummy_ext(kind), Res::Err), @@ -600,14 +621,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { pub(crate) fn resolve_macro_path( &mut self, - path: &ast::Path, + ast_path: &ast::Path, kind: Option, parent_scope: &ParentScope<'a>, trace: bool, force: bool, + invoc_in_mod_inert_attr: Option<(LocalDefId, NodeId)>, ) -> Result<(Option>, Res), Determinacy> { - let path_span = path.span; - let mut path = Segment::from_path(path); + let path_span = ast_path.span; + let mut path = Segment::from_path(ast_path); // Possibly apply the macro helper hack if kind == Some(MacroKind::Bang) @@ -667,6 +689,37 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let res = binding.map(|binding| binding.res()); self.prohibit_imported_non_macro_attrs(binding.ok(), res.ok(), path_span); + if let Ok(binding) = binding + && matches!(binding.kind, NameBindingKind::Res(..)) + && let Some((mod_def_id, node_id)) = invoc_in_mod_inert_attr + && let Ok(Res::Def(DefKind::Macro(MacroKind::Bang), def_id)) = res + && self.tcx.parent(def_id) == mod_def_id.to_def_id() + { + let tralala = self.early_resolve_ident_in_lexical_scope( + path[0].ident, + scope_set, + &ParentScope { + macro_rules: self.arenas.alloc_macro_rules_scope(MacroRulesScope::Empty), + ..*parent_scope + }, + None, + false, + None, + ); + + if tralala.ok().and_then(|binding| binding.res().opt_def_id()) == Some(def_id) { + // Nothing + } else { + self.tcx.sess.psess.buffer_lint( + OUT_OF_SCOPE_MACRO_CALLS, + path_span, + node_id, + BuiltinLintDiag::OutOfScopeMacroCalls { + path: pprust::path_to_string(ast_path), + }, + ); + } + } res }; diff --git a/tests/ui/attributes/key-value-expansion-scope-pass.rs b/tests/ui/attributes/key-value-expansion-scope-pass.rs new file mode 100644 index 0000000000000..ee27f4422c1dd --- /dev/null +++ b/tests/ui/attributes/key-value-expansion-scope-pass.rs @@ -0,0 +1,16 @@ +//@ check-pass +//@ edition:2018 + +#![doc = in_root!()] + +macro_rules! in_root { () => { "" } } +use in_root; + +mod macros_stay { + #![doc = in_mod!()] + + macro_rules! in_mod { () => { "" } } + use in_mod; +} + +fn main() {} diff --git a/tests/ui/attributes/key-value-expansion-scope.rs b/tests/ui/attributes/key-value-expansion-scope.rs index 147e9bdbe241c..6a97da89c9c52 100644 --- a/tests/ui/attributes/key-value-expansion-scope.rs +++ b/tests/ui/attributes/key-value-expansion-scope.rs @@ -1,6 +1,7 @@ #![doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope + //~| WARN this was previously accepted by the compiler #![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope -#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope +#![doc = in_mod_escape!()] //FIXME ERROR cannot find macro `in_mod_escape` in this scope #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope #[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope @@ -16,8 +17,11 @@ fn before() { macro_rules! in_root { () => { "" } } +#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope + //~| WARN this was previously accepted by the compiler mod macros_stay { #![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope + //~| WARN this was previously accepted by the compiler macro_rules! in_mod { () => { "" } } @@ -28,8 +32,11 @@ mod macros_stay { } #[macro_use] +#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope + //~| WARN this was previously accepted by the compiler mod macros_escape { #![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope + //~| WARN this was previously accepted by the compiler macro_rules! in_mod_escape { () => { "" } } @@ -39,8 +46,9 @@ mod macros_escape { } } +#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope fn block() { - #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope + #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope macro_rules! in_block { () => { "" } } diff --git a/tests/ui/attributes/key-value-expansion-scope.stderr b/tests/ui/attributes/key-value-expansion-scope.stderr index c7713a0ee09f2..0fcde595d88fa 100644 --- a/tests/ui/attributes/key-value-expansion-scope.stderr +++ b/tests/ui/attributes/key-value-expansion-scope.stderr @@ -1,29 +1,13 @@ -error: cannot find macro `in_root` in this scope - --> $DIR/key-value-expansion-scope.rs:1:10 - | -LL | #![doc = in_root!()] - | ^^^^^^^ - | - = help: have you added the `#[macro_use]` on the module/import? - error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:2:10 + --> $DIR/key-value-expansion-scope.rs:3:10 | LL | #![doc = in_mod!()] | ^^^^^^ | = help: have you added the `#[macro_use]` on the module/import? -error: cannot find macro `in_mod_escape` in this scope - --> $DIR/key-value-expansion-scope.rs:3:10 - | -LL | #![doc = in_mod_escape!()] - | ^^^^^^^^^^^^^ - | - = help: have you added the `#[macro_use]` on the module/import? - error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:4:10 + --> $DIR/key-value-expansion-scope.rs:5:10 | LL | #![doc = in_block!()] | ^^^^^^^^ @@ -31,7 +15,7 @@ LL | #![doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_root` in this scope - --> $DIR/key-value-expansion-scope.rs:6:9 + --> $DIR/key-value-expansion-scope.rs:7:9 | LL | #[doc = in_root!()] | ^^^^^^^ @@ -39,7 +23,7 @@ LL | #[doc = in_root!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:7:9 + --> $DIR/key-value-expansion-scope.rs:8:9 | LL | #[doc = in_mod!()] | ^^^^^^ @@ -47,7 +31,7 @@ LL | #[doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod_escape` in this scope - --> $DIR/key-value-expansion-scope.rs:8:9 + --> $DIR/key-value-expansion-scope.rs:9:9 | LL | #[doc = in_mod_escape!()] | ^^^^^^^^^^^^^ @@ -55,7 +39,7 @@ LL | #[doc = in_mod_escape!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:9:9 + --> $DIR/key-value-expansion-scope.rs:10:9 | LL | #[doc = in_block!()] | ^^^^^^^^ @@ -63,7 +47,7 @@ LL | #[doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_root` in this scope - --> $DIR/key-value-expansion-scope.rs:11:14 + --> $DIR/key-value-expansion-scope.rs:12:14 | LL | #![doc = in_root!()] | ^^^^^^^ @@ -71,7 +55,7 @@ LL | #![doc = in_root!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:12:14 + --> $DIR/key-value-expansion-scope.rs:13:14 | LL | #![doc = in_mod!()] | ^^^^^^ @@ -79,7 +63,7 @@ LL | #![doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod_escape` in this scope - --> $DIR/key-value-expansion-scope.rs:13:14 + --> $DIR/key-value-expansion-scope.rs:14:14 | LL | #![doc = in_mod_escape!()] | ^^^^^^^^^^^^^ @@ -87,31 +71,23 @@ LL | #![doc = in_mod_escape!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:14:14 + --> $DIR/key-value-expansion-scope.rs:15:14 | LL | #![doc = in_block!()] | ^^^^^^^^ | = help: have you added the `#[macro_use]` on the module/import? -error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:20:14 - | -LL | #![doc = in_mod!()] - | ^^^^^^ - | - = help: have you added the `#[macro_use]` on the module/import? - -error: cannot find macro `in_mod_escape` in this scope - --> $DIR/key-value-expansion-scope.rs:32:14 +error: cannot find macro `in_block` in this scope + --> $DIR/key-value-expansion-scope.rs:49:9 | -LL | #![doc = in_mod_escape!()] - | ^^^^^^^^^^^^^ +LL | #[doc = in_block!()] + | ^^^^^^^^ | = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:43:14 + --> $DIR/key-value-expansion-scope.rs:51:14 | LL | #![doc = in_block!()] | ^^^^^^^^ @@ -119,7 +95,7 @@ LL | #![doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:54:9 + --> $DIR/key-value-expansion-scope.rs:62:9 | LL | #[doc = in_mod!()] | ^^^^^^ @@ -127,7 +103,7 @@ LL | #[doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:56:9 + --> $DIR/key-value-expansion-scope.rs:64:9 | LL | #[doc = in_block!()] | ^^^^^^^^ @@ -135,7 +111,7 @@ LL | #[doc = in_block!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_mod` in this scope - --> $DIR/key-value-expansion-scope.rs:59:14 + --> $DIR/key-value-expansion-scope.rs:67:14 | LL | #![doc = in_mod!()] | ^^^^^^ @@ -143,12 +119,58 @@ LL | #![doc = in_mod!()] = help: have you added the `#[macro_use]` on the module/import? error: cannot find macro `in_block` in this scope - --> $DIR/key-value-expansion-scope.rs:61:14 + --> $DIR/key-value-expansion-scope.rs:69:14 | LL | #![doc = in_block!()] | ^^^^^^^^ | = help: have you added the `#[macro_use]` on the module/import? -error: aborting due to 19 previous errors +error: cannot find macro `in_root` in this scope + --> $DIR/key-value-expansion-scope.rs:1:10 + | +LL | #![doc = in_root!()] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 + = note: `#[deny(out_of_scope_macro_calls)]` on by default + +error: cannot find macro `in_mod` in this scope + --> $DIR/key-value-expansion-scope.rs:20:9 + | +LL | #[doc = in_mod!()] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 + +error: cannot find macro `in_mod` in this scope + --> $DIR/key-value-expansion-scope.rs:23:14 + | +LL | #![doc = in_mod!()] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 + +error: cannot find macro `in_mod_escape` in this scope + --> $DIR/key-value-expansion-scope.rs:35:9 + | +LL | #[doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 + +error: cannot find macro `in_mod_escape` in this scope + --> $DIR/key-value-expansion-scope.rs:38:14 + | +LL | #![doc = in_mod_escape!()] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #124535 + +error: aborting due to 21 previous errors diff --git a/tests/ui/proc-macro/ambiguous-builtin-attrs.stderr b/tests/ui/proc-macro/ambiguous-builtin-attrs.stderr index 2690c68a83415..0f4ddc065a742 100644 --- a/tests/ui/proc-macro/ambiguous-builtin-attrs.stderr +++ b/tests/ui/proc-macro/ambiguous-builtin-attrs.stderr @@ -4,21 +4,6 @@ error[E0425]: cannot find value `NonExistent` in this scope LL | NonExistent; | ^^^^^^^^^^^ not found in this scope -error[E0659]: `feature` is ambiguous - --> $DIR/ambiguous-builtin-attrs.rs:3:4 - | -LL | #![feature(decl_macro)] - | ^^^^^^^ ambiguous name - | - = note: ambiguous because of a name conflict with a builtin attribute - = note: `feature` could refer to a built-in attribute -note: `feature` could also refer to the attribute macro imported here - --> $DIR/ambiguous-builtin-attrs.rs:6:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ - = help: use `crate::feature` to refer to this attribute macro unambiguously - error[E0659]: `repr` is ambiguous --> $DIR/ambiguous-builtin-attrs.rs:9:3 | @@ -94,6 +79,21 @@ LL | use deny as allow; | ^^^^^^^^^^^^^ = help: use `crate::allow` to refer to this built-in attribute unambiguously +error[E0659]: `feature` is ambiguous + --> $DIR/ambiguous-builtin-attrs.rs:3:4 + | +LL | #![feature(decl_macro)] + | ^^^^^^^ ambiguous name + | + = note: ambiguous because of a name conflict with a builtin attribute + = note: `feature` could refer to a built-in attribute +note: `feature` could also refer to the attribute macro imported here + --> $DIR/ambiguous-builtin-attrs.rs:6:5 + | +LL | use builtin_attrs::*; + | ^^^^^^^^^^^^^^^^ + = help: use `crate::feature` to refer to this attribute macro unambiguously + error[E0517]: attribute should be applied to a struct, enum, or union --> $DIR/ambiguous-builtin-attrs.rs:20:39 |