rust/tests/ui/attributes/key-value-expansion-scope.rs
Esteban Küber fe7ed278b7 Specify scope in out_of_scope_macro_calls lint
```
warning: cannot find macro `in_root` in the crate root
  --> $DIR/key-value-expansion-scope.rs:1:10
   |
LL | #![doc = in_root!()]
   |          ^^^^^^^ not found in the crate 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 <https://github.com/rust-lang/rust/issues/124535>
   = help: import `macro_rules` with `use` to make it callable above its definition
   = note: `#[warn(out_of_scope_macro_calls)]` on by default
```
2025-02-19 18:29:00 +00:00

74 lines
2.7 KiB
Rust

#![doc = in_root!()] //~ WARN cannot find macro `in_root`
//~| WARN this was previously accepted by the compiler
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape`
//~| WARN this was previously accepted by the compiler
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
#[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
#[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_block!()] //~ ERROR cannot find macro `in_block` in this scope
fn before() {
#![doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
#![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_block!()] //~ ERROR cannot find macro `in_block` in this scope
}
macro_rules! in_root { () => { "" } }
#[doc = in_mod!()] //~ WARN cannot find macro `in_mod`
//~| WARN this was previously accepted by the compiler
mod macros_stay {
#![doc = in_mod!()] //~ WARN cannot find macro `in_mod`
//~| WARN this was previously accepted by the compiler
macro_rules! in_mod { () => { "" } }
#[doc = in_mod!()] // OK
fn f() {
#![doc = in_mod!()] // OK
}
}
#[macro_use]
#[doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape`
//~| WARN this was previously accepted by the compiler
mod macros_escape {
#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape`
//~| WARN this was previously accepted by the compiler
macro_rules! in_mod_escape { () => { "" } }
#[doc = in_mod_escape!()] // OK
fn f() {
#![doc = in_mod_escape!()] // OK
}
}
#[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
macro_rules! in_block { () => { "" } }
#[doc = in_block!()] // OK
fn f() {
#![doc = in_block!()] // OK
}
}
#[doc = in_root!()] // OK
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#[doc = in_mod_escape!()] // OK
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
fn after() {
#![doc = in_root!()] // OK
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#![doc = in_mod_escape!()] // OK
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
}
fn main() {}