about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2022-05-22 04:25:40 +0200
committerest31 <MTest31@outlook.com>2022-05-24 17:27:34 +0200
commit2a8b60f915c9fdc61e18be3392ea4330d9617da4 (patch)
tree2f23c58b67578dd37aae12f9b6d61fd2c51ace40 /src/test
parentcd251fb48e93509b7ddb34aa973ef2c12e25e8dd (diff)
downloadrust-2a8b60f915c9fdc61e18be3392ea4330d9617da4.tar.gz
rust-2a8b60f915c9fdc61e18be3392ea4330d9617da4.zip
Emit weird lint name lints after expansion
Previously, we were emitting weird name lints (for renamed or unknown lints)
before expansion, most importantly before cfg expansion.
This meant that the weird name lints would not fire
for lint attributes hidden inside cfg_attr. The same applied
for lint level specifications of those lints.

By moving the lints for the lint names to the post-expansion
phase, these issues are resolved.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui-fulldeps/lint-tool-test.stderr16
-rw-r--r--src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr28
-rw-r--r--src/test/ui/lint/issue-97094.interleaved.stderr53
-rw-r--r--src/test/ui/lint/issue-97094.nointerleaved.stderr53
-rw-r--r--src/test/ui/lint/issue-97094.rs59
-rw-r--r--src/test/ui/lint/reasons-erroneous.stderr16
6 files changed, 195 insertions, 30 deletions
diff --git a/src/test/ui-fulldeps/lint-tool-test.stderr b/src/test/ui-fulldeps/lint-tool-test.stderr
index 513f70d0f05..af9b8dedc73 100644
--- a/src/test/ui-fulldeps/lint-tool-test.stderr
+++ b/src/test/ui-fulldeps/lint-tool-test.stderr
@@ -18,14 +18,6 @@ warning: lint name `test_group` is deprecated and may not have an effect in the
 LL | #[allow(test_group)]
    |         ^^^^^^^^^^ help: change it to: `clippy::test_group`
 
-warning: unknown lint: `this_lint_does_not_exist`
-  --> $DIR/lint-tool-test.rs:36:8
-   |
-LL | #[deny(this_lint_does_not_exist)]
-   |        ^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: `#[warn(unknown_lints)]` on by default
-
 warning: lint name `test_lint` is deprecated and may not have an effect in the future.
   --> $DIR/lint-tool-test.rs:9:23
    |
@@ -44,6 +36,14 @@ warning: lint name `test_group` is deprecated and may not have an effect in the
 LL | #[allow(test_group)]
    |         ^^^^^^^^^^ help: change it to: `clippy::test_group`
 
+warning: unknown lint: `this_lint_does_not_exist`
+  --> $DIR/lint-tool-test.rs:36:8
+   |
+LL | #[deny(this_lint_does_not_exist)]
+   |        ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(unknown_lints)]` on by default
+
 warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
   --> $DIR/lint-tool-test.rs:6:1
    |
diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
index cf9f89d8fde..06e1bd84c8b 100644
--- a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
+++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
@@ -1,3 +1,17 @@
+warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:401:17
+   |
+LL |     mod inner { #![macro_escape] }
+   |                 ^^^^^^^^^^^^^^^^
+   |
+   = help: try an outer attribute: `#[macro_use]`
+
+warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:1
+   |
+LL | #[macro_escape]
+   | ^^^^^^^^^^^^^^^
+
 warning: unknown lint: `x5400`
   --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9
    |
@@ -172,20 +186,6 @@ warning: unknown lint: `x5100`
 LL |     #[deny(x5100)] impl S { }
    |            ^^^^^
 
-warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:401:17
-   |
-LL |     mod inner { #![macro_escape] }
-   |                 ^^^^^^^^^^^^^^^^
-   |
-   = help: try an outer attribute: `#[macro_use]`
-
-warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:1
-   |
-LL | #[macro_escape]
-   | ^^^^^^^^^^^^^^^
-
 warning: use of deprecated attribute `crate_id`: no longer used.
   --> $DIR/issue-43106-gating-of-builtin-attrs.rs:85:1
    |
diff --git a/src/test/ui/lint/issue-97094.interleaved.stderr b/src/test/ui/lint/issue-97094.interleaved.stderr
new file mode 100644
index 00000000000..a2581658920
--- /dev/null
+++ b/src/test/ui/lint/issue-97094.interleaved.stderr
@@ -0,0 +1,53 @@
+error: unknown lint: `nonex_lint_top_level`
+  --> $DIR/issue-97094.rs:14:26
+   |
+LL | #![cfg_attr(all(), allow(nonex_lint_top_level))]
+   |                          ^^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-97094.rs:10:9
+   |
+LL | #![deny(warnings)]
+   |         ^^^^^^^^
+   = note: `#[deny(unknown_lints)]` implied by `#[deny(warnings)]`
+
+error: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+  --> $DIR/issue-97094.rs:16:26
+   |
+LL | #![cfg_attr(all(), allow(bare_trait_object))]
+   |                          ^^^^^^^^^^^^^^^^^ help: use the new name: `bare_trait_objects`
+   |
+   = note: `#[deny(renamed_and_removed_lints)]` implied by `#[deny(warnings)]`
+
+error: unknown lint: `nonex_lint_mod`
+  --> $DIR/issue-97094.rs:19:25
+   |
+LL | #[cfg_attr(all(), allow(nonex_lint_mod))]
+   |                         ^^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_mod_inner`
+  --> $DIR/issue-97094.rs:22:30
+   |
+LL |     #![cfg_attr(all(), allow(nonex_lint_mod_inner))]
+   |                              ^^^^^^^^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_fn`
+  --> $DIR/issue-97094.rs:26:25
+   |
+LL | #[cfg_attr(all(), allow(nonex_lint_fn))]
+   |                         ^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_in_macro`
+  --> $DIR/issue-97094.rs:37:29
+   |
+LL |     #[cfg_attr(all(), allow(nonex_lint_in_macro))]
+   |                             ^^^^^^^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_fn`
+  --> $DIR/issue-97094.rs:56:13
+   |
+LL |     #[allow(nonex_lint_fn)]
+   |             ^^^^^^^^^^^^^
+
+error: aborting due to 7 previous errors
+
diff --git a/src/test/ui/lint/issue-97094.nointerleaved.stderr b/src/test/ui/lint/issue-97094.nointerleaved.stderr
new file mode 100644
index 00000000000..a2581658920
--- /dev/null
+++ b/src/test/ui/lint/issue-97094.nointerleaved.stderr
@@ -0,0 +1,53 @@
+error: unknown lint: `nonex_lint_top_level`
+  --> $DIR/issue-97094.rs:14:26
+   |
+LL | #![cfg_attr(all(), allow(nonex_lint_top_level))]
+   |                          ^^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/issue-97094.rs:10:9
+   |
+LL | #![deny(warnings)]
+   |         ^^^^^^^^
+   = note: `#[deny(unknown_lints)]` implied by `#[deny(warnings)]`
+
+error: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+  --> $DIR/issue-97094.rs:16:26
+   |
+LL | #![cfg_attr(all(), allow(bare_trait_object))]
+   |                          ^^^^^^^^^^^^^^^^^ help: use the new name: `bare_trait_objects`
+   |
+   = note: `#[deny(renamed_and_removed_lints)]` implied by `#[deny(warnings)]`
+
+error: unknown lint: `nonex_lint_mod`
+  --> $DIR/issue-97094.rs:19:25
+   |
+LL | #[cfg_attr(all(), allow(nonex_lint_mod))]
+   |                         ^^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_mod_inner`
+  --> $DIR/issue-97094.rs:22:30
+   |
+LL |     #![cfg_attr(all(), allow(nonex_lint_mod_inner))]
+   |                              ^^^^^^^^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_fn`
+  --> $DIR/issue-97094.rs:26:25
+   |
+LL | #[cfg_attr(all(), allow(nonex_lint_fn))]
+   |                         ^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_in_macro`
+  --> $DIR/issue-97094.rs:37:29
+   |
+LL |     #[cfg_attr(all(), allow(nonex_lint_in_macro))]
+   |                             ^^^^^^^^^^^^^^^^^^^
+
+error: unknown lint: `nonex_lint_fn`
+  --> $DIR/issue-97094.rs:56:13
+   |
+LL |     #[allow(nonex_lint_fn)]
+   |             ^^^^^^^^^^^^^
+
+error: aborting due to 7 previous errors
+
diff --git a/src/test/ui/lint/issue-97094.rs b/src/test/ui/lint/issue-97094.rs
new file mode 100644
index 00000000000..aeaead1bd11
--- /dev/null
+++ b/src/test/ui/lint/issue-97094.rs
@@ -0,0 +1,59 @@
+// revisions: interleaved nointerleaved
+// [nointerleaved]compile-flags: -Z no-interleave-lints
+
+// This test has two revisions because the logic change
+// needed to make this test pass had to be adjusted
+// for no-interleave-lints. Should the debug option
+// be removed one day, please don't remove this
+// test entirely, just remove the revision from it.
+
+#![deny(warnings)]
+
+// Ensure that unknown lints inside cfg-attr's are linted for
+
+#![cfg_attr(all(), allow(nonex_lint_top_level))]
+//~^ ERROR unknown lint
+#![cfg_attr(all(), allow(bare_trait_object))]
+//~^ ERROR has been renamed
+
+#[cfg_attr(all(), allow(nonex_lint_mod))]
+//~^ ERROR unknown lint
+mod baz {
+    #![cfg_attr(all(), allow(nonex_lint_mod_inner))]
+    //~^ ERROR unknown lint
+}
+
+#[cfg_attr(all(), allow(nonex_lint_fn))]
+//~^ ERROR unknown lint
+pub fn main() {}
+
+macro_rules! bar {
+    ($($t:tt)*) => {
+        $($t)*
+    };
+}
+
+bar!(
+    #[cfg_attr(all(), allow(nonex_lint_in_macro))]
+    //~^ ERROR unknown lint
+    pub fn _bar() {}
+);
+
+// No warning for non-applying cfg
+#[cfg_attr(any(), allow(nonex_lint_fn))]
+pub fn _foo() {}
+
+// Allowing unknown lints works if inside cfg_attr
+#[cfg_attr(all(), allow(unknown_lints))]
+mod bar_allowed {
+    #[allow(nonex_lint_fn)]
+    fn _foo() {}
+}
+
+// ... but not if the cfg_attr doesn't evaluate
+#[cfg_attr(any(), allow(unknown_lints))]
+mod bar_not_allowed {
+    #[allow(nonex_lint_fn)]
+    //~^ ERROR unknown lint
+    fn _foo() {}
+}
diff --git a/src/test/ui/lint/reasons-erroneous.stderr b/src/test/ui/lint/reasons-erroneous.stderr
index f65ca08694d..5521af17c84 100644
--- a/src/test/ui/lint/reasons-erroneous.stderr
+++ b/src/test/ui/lint/reasons-erroneous.stderr
@@ -58,14 +58,6 @@ error[E0452]: malformed lint attribute input
 LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)]
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last
 
-warning: unknown lint: `reason`
-  --> $DIR/reasons-erroneous.rs:50:39
-   |
-LL | #![warn(missing_copy_implementations, reason)]
-   |                                       ^^^^^^
-   |
-   = note: `#[warn(unknown_lints)]` on by default
-
 error[E0452]: malformed lint attribute input
   --> $DIR/reasons-erroneous.rs:3:58
    |
@@ -126,6 +118,14 @@ error[E0452]: malformed lint attribute input
 LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)]
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^ reason in lint attribute must come last
 
+warning: unknown lint: `reason`
+  --> $DIR/reasons-erroneous.rs:50:39
+   |
+LL | #![warn(missing_copy_implementations, reason)]
+   |                                       ^^^^^^
+   |
+   = note: `#[warn(unknown_lints)]` on by default
+
 error: aborting due to 20 previous errors; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0452`.