Add better ICE messages for some undescriptive panics
This commit is contained in:
parent
03515c6a22
commit
663bea5a96
3 changed files with 11 additions and 4 deletions
|
@ -9,6 +9,7 @@ use rustc_ast::{self as ast, *};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::{DefKind, PartialRes, Res};
|
use rustc_hir::def::{DefKind, PartialRes, Res};
|
||||||
use rustc_hir::GenericArg;
|
use rustc_hir::GenericArg;
|
||||||
|
use rustc_middle::span_bug;
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
use rustc_span::{BytePos, Span, DUMMY_SP};
|
use rustc_span::{BytePos, Span, DUMMY_SP};
|
||||||
|
|
||||||
|
@ -285,7 +286,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
let (start, end) = match self.resolver.get_lifetime_res(segment_id) {
|
let (start, end) = match self.resolver.get_lifetime_res(segment_id) {
|
||||||
Some(LifetimeRes::ElidedAnchor { start, end }) => (start, end),
|
Some(LifetimeRes::ElidedAnchor { start, end }) => (start, end),
|
||||||
None => return,
|
None => return,
|
||||||
Some(_) => panic!(),
|
Some(res) => {
|
||||||
|
span_bug!(path_span, "expected an elided lifetime to insert. found {res:?}")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let expected_lifetimes = end.as_usize() - start.as_usize();
|
let expected_lifetimes = end.as_usize() - start.as_usize();
|
||||||
debug!(expected_lifetimes);
|
debug!(expected_lifetimes);
|
||||||
|
|
|
@ -1597,7 +1597,9 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
match bound {
|
match bound {
|
||||||
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
|
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
|
||||||
_ => panic!(),
|
_ => {
|
||||||
|
panic!("expected a lifetime bound, found a trait bound")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl<'sm> CachingSourceMapView<'sm> {
|
||||||
self.time_stamp += 1;
|
self.time_stamp += 1;
|
||||||
|
|
||||||
// Check if lo and hi are in the cached lines.
|
// Check if lo and hi are in the cached lines.
|
||||||
let lo_cache_idx = self.cache_entry_index(span_data.lo);
|
let lo_cache_idx: isize = self.cache_entry_index(span_data.lo);
|
||||||
let hi_cache_idx = self.cache_entry_index(span_data.hi);
|
let hi_cache_idx = self.cache_entry_index(span_data.hi);
|
||||||
|
|
||||||
if lo_cache_idx != -1 && hi_cache_idx != -1 {
|
if lo_cache_idx != -1 && hi_cache_idx != -1 {
|
||||||
|
@ -205,7 +205,9 @@ impl<'sm> CachingSourceMapView<'sm> {
|
||||||
(lo_cache_idx as usize, oldest)
|
(lo_cache_idx as usize, oldest)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
panic!();
|
panic!(
|
||||||
|
"the case of neither value being equal to -1 was handled above and the function returns."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue