Skip to content

Commit 91a9866

Browse files
committed
Make panic/assert calls in rustc compatible with Rust 2021.
1 parent 6f90365 commit 91a9866

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub trait ExpectOne<A: Array> {
2828

2929
impl<A: Array> ExpectOne<A> for SmallVec<A> {
3030
fn expect_one(self, err: &'static str) -> A::Item {
31-
assert!(self.len() == 1, err);
31+
assert!(self.len() == 1, "{}", err);
3232
self.into_iter().next().unwrap()
3333
}
3434
}

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ impl HandlerInner {
901901

902902
fn span_bug(&mut self, sp: impl Into<MultiSpan>, msg: &str) -> ! {
903903
self.emit_diag_at_span(Diagnostic::new(Bug, msg), sp);
904-
panic!(ExplicitBug);
904+
panic::panic_any(ExplicitBug);
905905
}
906906

907907
fn emit_diag_at_span(&mut self, mut diag: Diagnostic, sp: impl Into<MultiSpan>) {
@@ -955,7 +955,7 @@ impl HandlerInner {
955955

956956
fn bug(&mut self, msg: &str) -> ! {
957957
self.emit_diagnostic(&Diagnostic::new(Bug, msg));
958-
panic!(ExplicitBug);
958+
panic::panic_any(ExplicitBug);
959959
}
960960

961961
fn delay_as_bug(&mut self, diagnostic: Diagnostic) {

compiler/rustc_middle/src/util/bug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::ty::{tls, TyCtxt};
44
use rustc_span::{MultiSpan, Span};
55
use std::fmt;
6-
use std::panic::Location;
6+
use std::panic::{panic_any, Location};
77

88
#[cold]
99
#[inline(never)]
@@ -32,7 +32,7 @@ fn opt_span_bug_fmt<S: Into<MultiSpan>>(
3232
match (tcx, span) {
3333
(Some(tcx), Some(span)) => tcx.sess.diagnostic().span_bug(span, &msg),
3434
(Some(tcx), None) => tcx.sess.diagnostic().bug(&msg),
35-
(None, _) => panic!(msg),
35+
(None, _) => panic_any(msg),
3636
}
3737
});
3838
unreachable!();

0 commit comments

Comments
 (0)