From 1d667a0937f6242366d1f47d359a2c739f3c62b1 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Tue, 25 Jun 2024 20:05:37 +0200 Subject: Prevent ICE from expected future breakage --- compiler/rustc_errors/src/json.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_errors/src/json.rs') diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index af82d8092c2..3d2a04d5851 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -135,7 +135,12 @@ impl Emitter for JsonEmitter { let data: Vec> = diags .into_iter() .map(|mut diag| { - if diag.level == crate::Level::Allow { + // The `FutureBreakageItem` is collected and serialized. + // However, the `allow` and `expect` lint levels can't usually + // be serialized. The lint level is overwritten to allow the + // serialization again and force a lint emission. + // (This is an educated guess. I didn't originally add this) + if matches!(diag.level, crate::Level::Allow | crate::Level::Expect(..)) { diag.level = crate::Level::Warning; } FutureBreakageItem { -- cgit 1.4.1-3-g733a5 From 7666534381042f5febdc995e024af051ceecc2f5 Mon Sep 17 00:00:00 2001 From: Urgau <3616612+Urgau@users.noreply.github.com> Date: Wed, 26 Jun 2024 17:00:46 +0200 Subject: Clarify comment on changing to warn future breakage items https://github.com/rust-lang/rust/pull/120924/files#r1653512240 --- compiler/rustc_errors/src/json.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_errors/src/json.rs') diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 3d2a04d5851..764134d5335 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -135,11 +135,11 @@ impl Emitter for JsonEmitter { let data: Vec> = diags .into_iter() .map(|mut diag| { - // The `FutureBreakageItem` is collected and serialized. - // However, the `allow` and `expect` lint levels can't usually - // be serialized. The lint level is overwritten to allow the - // serialization again and force a lint emission. - // (This is an educated guess. I didn't originally add this) + // Allowed or expected lints don't normally (by definition) emit a lint + // but future incompat lints are special and are emitted anyway. + // + // So to avoid ICEs and confused users we "upgrade" the lint level for + // those `FutureBreakageItem` to warn. if matches!(diag.level, crate::Level::Allow | crate::Level::Expect(..)) { diag.level = crate::Level::Warning; } -- cgit 1.4.1-3-g733a5