Skip to content

compiler: Treat ForceWarning as a Warning for diagnostic level #142148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
9 changes: 9 additions & 0 deletions tests/ui/lint/force-warn/ice-free.rs
Original file line number Diff line number Diff line change
@@ -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() {}
32 changes: 32 additions & 0 deletions tests/ui/lint/force-warn/ice-free.stderr
Original file line number Diff line number Diff line change
@@ -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;
| +++

Loading