diff --git a/plrustc/plrustc/src/lints/builtin_macros.rs b/plrustc/plrustc/src/lints/builtin_macros.rs index 8daaaec4..dbc271a7 100644 --- a/plrustc/plrustc/src/lints/builtin_macros.rs +++ b/plrustc/plrustc/src/lints/builtin_macros.rs @@ -39,7 +39,9 @@ impl PlrustBuiltinMacros { if let Some((s, ..)) = utils::check_span_against_macro_diags(cx, span, &fs_diagnostic_items) { self.lint_fs(cx, s); - return; + if span != s { + self.lint_fs(cx, span); + } } let fs_def_paths: &[&[Symbol]] = &[ &[sym!(core), sym!(macros), sym!(builtin), sym!(include)], @@ -48,15 +50,19 @@ impl PlrustBuiltinMacros { ]; if let Some((s, ..)) = utils::check_span_against_macro_def_paths(cx, span, &fs_def_paths) { self.lint_fs(cx, s); - return; + if span != s { + self.lint_fs(cx, span); + } } let env_diagnostic_items = [sym!(env_macro), sym!(option_env_macro)]; if let Some((s, ..)) = utils::check_span_against_macro_diags(cx, span, &env_diagnostic_items) { - self.lint_env(cx, s); - return; + self.lint_env(cx, span); + if span != s { + self.lint_env(cx, span); + } } let env_def_paths: &[&[Symbol]] = &[ &[sym!(core), sym!(macros), sym!(builtin), sym!(env)], @@ -67,8 +73,10 @@ impl PlrustBuiltinMacros { &[sym!(core), sym!(option_env)], ]; if let Some((s, ..)) = utils::check_span_against_macro_def_paths(cx, span, &env_def_paths) { - self.lint_env(cx, s); - return; + self.lint_env(cx, span); + if span != s { + self.lint_env(cx, span); + } } } } diff --git a/plrustc/plrustc/uitests/fs_macros.stderr b/plrustc/plrustc/uitests/fs_macros.stderr index f2b2c741..b0368c59 100644 --- a/plrustc/plrustc/uitests/fs_macros.stderr +++ b/plrustc/plrustc/uitests/fs_macros.stderr @@ -6,23 +6,55 @@ LL | const _A: &str = include_str!("fs_macros_included_file.txt"); | = note: `-F plrust-filesystem-macros` implied by `-F plrust-lints` +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:3:18 + | +LL | const _A: &str = include_str!("fs_macros_included_file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:5:19 + | +LL | const _B: &[u8] = include_bytes!("fs_macros_included_file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:5:19 | LL | const _B: &[u8] = include_bytes!("fs_macros_included_file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:7:18 + | +LL | const _C: &str = core::include_str!("fs_macros_included_file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:7:18 | LL | const _C: &str = core::include_str!("fs_macros_included_file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `core::include_str` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:8:19 + | +LL | const _D: &[u8] = core::include_bytes!("fs_macros_included_file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:8:19 | LL | const _D: &[u8] = core::include_bytes!("fs_macros_included_file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `core::include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:16:18 @@ -30,23 +62,64 @@ error: the `include_str`, `include_bytes`, and `include` macros are forbidden in LL | const _E: &str = indirect!(include_str); | ^^^^^^^^^^^^^^^^^^^^^^ +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:12:9 + | +LL | $callme!("fs_macros_included_file.txt") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | const _E: &str = indirect!(include_str); + | ---------------------- in this macro invocation + | + = note: this error originates in the macro `include_str` which comes from the expansion of the macro `indirect` (in Nightly builds, run with -Z macro-backtrace for more info) + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:17:19 | LL | const _F: &[u8] = indirect!(include_bytes); | ^^^^^^^^^^^^^^^^^^^^^^^^ +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:12:9 + | +LL | $callme!("fs_macros_included_file.txt") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | const _F: &[u8] = indirect!(include_bytes); + | ------------------------ in this macro invocation + | + = note: this error originates in the macro `include_bytes` which comes from the expansion of the macro `indirect` (in Nightly builds, run with -Z macro-backtrace for more info) + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:31:18 | LL | const _G: &str = in_macro!(); | ^^^^^^^^^^^ +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:21:9 + | +LL | include_str!("fs_macros_included_file.txt") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | const _G: &str = in_macro!(); + | ----------- in this macro invocation + | + = note: this error originates in the macro `include_str` which comes from the expansion of the macro `in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:32:28 + | +LL | const _H: &str = in_macro!(include_str!("fs_macros_included_file.txt")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:32:28 | LL | const _H: &str = in_macro!(include_str!("fs_macros_included_file.txt")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:33:29 @@ -54,17 +127,44 @@ error: the `include_str`, `include_bytes`, and `include` macros are forbidden in LL | const _I: &[u8] = in_macro!(include_bytes!("fs_macros_included_file.txt")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:33:29 + | +LL | const _I: &[u8] = in_macro!(include_bytes!("fs_macros_included_file.txt")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info) + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:34:19 | LL | const _J: &[u8] = in_macro!(include_bytes, "fs_macros_included_file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:27:9 + | +LL | $mac!($arg) + | ^^^^^^^^^^^ +... +LL | const _J: &[u8] = in_macro!(include_bytes, "fs_macros_included_file.txt"); + | ------------------------------------------------------- in this macro invocation + | + = note: this error originates in the macro `include_bytes` which comes from the expansion of the macro `in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:37:18 + | +LL | const _L: &str = sneaky!("fs_macros_included_file.txt"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:37:18 | LL | const _L: &str = sneaky!("fs_macros_included_file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the macro `sneaky` (in Nightly builds, run with -Z macro-backtrace for more info) error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:38:18 @@ -72,11 +172,33 @@ error: the `include_str`, `include_bytes`, and `include` macros are forbidden in LL | const _M: &str = in_macro!(sneaky, "fs_macros_included_file.txt"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:27:9 + | +LL | $mac!($arg) + | ^^^^^^^^^^^ +... +LL | const _M: &str = in_macro!(sneaky, "fs_macros_included_file.txt"); + | ------------------------------------------------ in this macro invocation + | + = note: this error originates in the macro `sneaky` which comes from the expansion of the macro `in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust --> $DIR/fs_macros.rs:41:21 | LL | format!("{:?}", in_macro!()) | ^^^^^^^^^^^ -error: aborting due to 13 previous errors +error: the `include_str`, `include_bytes`, and `include` macros are forbidden in PL/Rust + --> $DIR/fs_macros.rs:21:9 + | +LL | include_str!("fs_macros_included_file.txt") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | format!("{:?}", in_macro!()) + | ----------- in this macro invocation + | + = note: this error originates in the macro `include_str` which comes from the expansion of the macro `in_macro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 26 previous errors