Skip to content
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

Add better ICE messages for some undescriptive panics #118967

Merged
merged 1 commit into from
Dec 18, 2023
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
5 changes: 4 additions & 1 deletion compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_ast::{self as ast, *};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, PartialRes, Res};
use rustc_hir::GenericArg;
use rustc_middle::span_bug;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{BytePos, Span, DUMMY_SP};

Expand Down Expand Up @@ -285,7 +286,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let (start, end) = match self.resolver.get_lifetime_res(segment_id) {
Some(LifetimeRes::ElidedAnchor { start, end }) => (start, end),
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();
debug!(expected_lifetimes);
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,9 @@ impl<'a> State<'a> {
}
match bound {
ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
_ => panic!(),
_ => {
panic!("expected a lifetime bound, found a trait bound")
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_span/src/caching_source_map_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<'sm> CachingSourceMapView<'sm> {
self.time_stamp += 1;

// 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);

if lo_cache_idx != -1 && hi_cache_idx != -1 {
Expand Down Expand Up @@ -205,7 +205,9 @@ impl<'sm> CachingSourceMapView<'sm> {
(lo_cache_idx as usize, oldest)
}
_ => {
panic!();
panic!(
"the case of neither value being equal to -1 was handled above and the function returns."
);
}
};

Expand Down