about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2025-06-07 00:44:08 -0700
committerJubilee Young <workingjubilee@gmail.com>2025-06-07 00:49:29 -0700
commit5bab0d2e66f77e34865026856dcd5ae21f0b2d2f (patch)
tree06e71ea7797ae63d4be40f7b5969320561928da5
parentf315e6145802e091ff9fceab6db627a4b4ec2b86 (diff)
downloadrust-5bab0d2e66f77e34865026856dcd5ae21f0b2d2f.tar.gz
rust-5bab0d2e66f77e34865026856dcd5ae21f0b2d2f.zip
compiler: Treat ForceWarning as a Warning for diagnostic level
This silences an ICE.
-rw-r--r--compiler/rustc_errors/src/lib.rs2
-rw-r--r--tests/ui/lint/force-warn/ice-free.rs9
-rw-r--r--tests/ui/lint/force-warn/ice-free.stderr32
3 files changed, 42 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index bd421a441f9..6f0090a0bd6 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1529,7 +1529,7 @@ impl DiagCtxtInner {
             // Future breakages aren't emitted if they're `Level::Allow` or
             // `Level::Expect`, but they still need to be constructed and
             // stashed below, so they'll trigger the must_produce_diag check.
-            assert_matches!(diagnostic.level, Error | Warning | Allow | Expect);
+            assert_matches!(diagnostic.level, Error | ForceWarning | Warning | Allow | Expect);
             self.future_breakage_diagnostics.push(diagnostic.clone());
         }
 
diff --git a/tests/ui/lint/force-warn/ice-free.rs b/tests/ui/lint/force-warn/ice-free.rs
new file mode 100644
index 00000000000..99b79f44648
--- /dev/null
+++ b/tests/ui/lint/force-warn/ice-free.rs
@@ -0,0 +1,9 @@
+//@ compile-flags: --force-warn pub_use_of_private_extern_crate
+//@ check-pass
+
+extern crate core;
+pub use core as reexported_core;
+//~^ warning: extern crate `core` is private
+//~| warning: this was previously accepted by the compiler
+
+fn main() {}
diff --git a/tests/ui/lint/force-warn/ice-free.stderr b/tests/ui/lint/force-warn/ice-free.stderr
new file mode 100644
index 00000000000..b64e3b138a2
--- /dev/null
+++ b/tests/ui/lint/force-warn/ice-free.stderr
@@ -0,0 +1,32 @@
+warning[E0365]: extern crate `core` is private and cannot be re-exported
+  --> $DIR/ice-free.rs:5:9
+   |
+LL | pub use core as reexported_core;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = 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 #127909 <https://github.com/rust-lang/rust/issues/127909>
+   = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate`
+help: consider making the `extern crate` item publicly accessible
+   |
+LL | pub extern crate core;
+   | +++
+
+warning: 1 warning emitted
+
+For more information about this error, try `rustc --explain E0365`.
+Future incompatibility report: Future breakage diagnostic:
+warning[E0365]: extern crate `core` is private and cannot be re-exported
+  --> $DIR/ice-free.rs:5:9
+   |
+LL | pub use core as reexported_core;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = 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 #127909 <https://github.com/rust-lang/rust/issues/127909>
+   = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate`
+help: consider making the `extern crate` item publicly accessible
+   |
+LL | pub extern crate core;
+   | +++
+