Skip to content

Commit 578a7dd

Browse files
authored
Rollup merge of #118967 - RossSmyth:panic-messages, r=TaKO8Ki
Add better ICE messages for some undescriptive panics Add some better messages at some panics re: #118955 I took a look at some others but either was not able to figure out what they did, or it was unclear what they should say instead. For example in the query system whether each time a poisoned value is matched upon if they should all just call `FatalError.raise()`
2 parents 18294d6 + 663bea5 commit 578a7dd

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

compiler/rustc_ast_lowering/src/path.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_ast::{self as ast, *};
99
use rustc_hir as hir;
1010
use rustc_hir::def::{DefKind, PartialRes, Res};
1111
use rustc_hir::GenericArg;
12+
use rustc_middle::span_bug;
1213
use rustc_span::symbol::{kw, sym, Ident};
1314
use rustc_span::{BytePos, Span, DUMMY_SP};
1415

@@ -285,7 +286,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
285286
let (start, end) = match self.resolver.get_lifetime_res(segment_id) {
286287
Some(LifetimeRes::ElidedAnchor { start, end }) => (start, end),
287288
None => return,
288-
Some(_) => panic!(),
289+
Some(res) => {
290+
span_bug!(path_span, "expected an elided lifetime to insert. found {res:?}")
291+
}
289292
};
290293
let expected_lifetimes = end.as_usize() - start.as_usize();
291294
debug!(expected_lifetimes);

compiler/rustc_ast_pretty/src/pprust/state.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,9 @@ impl<'a> State<'a> {
15971597
}
15981598
match bound {
15991599
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
1600-
_ => panic!(),
1600+
_ => {
1601+
panic!("expected a lifetime bound, found a trait bound")
1602+
}
16011603
}
16021604
}
16031605
}

compiler/rustc_span/src/caching_source_map_view.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'sm> CachingSourceMapView<'sm> {
117117
self.time_stamp += 1;
118118

119119
// Check if lo and hi are in the cached lines.
120-
let lo_cache_idx = self.cache_entry_index(span_data.lo);
120+
let lo_cache_idx: isize = self.cache_entry_index(span_data.lo);
121121
let hi_cache_idx = self.cache_entry_index(span_data.hi);
122122

123123
if lo_cache_idx != -1 && hi_cache_idx != -1 {
@@ -205,7 +205,9 @@ impl<'sm> CachingSourceMapView<'sm> {
205205
(lo_cache_idx as usize, oldest)
206206
}
207207
_ => {
208-
panic!();
208+
panic!(
209+
"the case of neither value being equal to -1 was handled above and the function returns."
210+
);
209211
}
210212
};
211213

0 commit comments

Comments
 (0)