Rollup merge of #121208 - nnethercote:delayed_bug-to-bug, r=lcnr
Convert `delayed_bug`s to `bug`s. I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. This is too dangerous to merge. Increased coverage (fuzzing or a crater run) would likely hit more cases. But it might be useful for people to look at and think about which paths are genuinely unreachable. r? `@ghost`
This commit is contained in:
commit
d5206c6ecd
39 changed files with 130 additions and 155 deletions
|
@ -110,15 +110,12 @@ fn lit_to_mir_constant<'tcx>(
|
|||
let LitToConstInput { lit, ty, neg } = lit_input;
|
||||
let trunc = |n| {
|
||||
let param_ty = ty::ParamEnv::reveal_all().and(ty);
|
||||
let width =
|
||||
tcx.layout_of(param_ty)
|
||||
.map_err(|_| {
|
||||
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||
"couldn't compute width of literal: {:?}",
|
||||
lit_input.lit
|
||||
)))
|
||||
})?
|
||||
.size;
|
||||
let width = match tcx.layout_of(param_ty) {
|
||||
Ok(layout) => layout.size,
|
||||
Err(_) => {
|
||||
tcx.dcx().bug(format!("couldn't compute width of literal: {:?}", lit_input.lit))
|
||||
}
|
||||
};
|
||||
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
||||
let result = width.truncate(n);
|
||||
trace!("trunc result: {}", result);
|
||||
|
|
|
@ -12,15 +12,12 @@ pub(crate) fn lit_to_const<'tcx>(
|
|||
|
||||
let trunc = |n| {
|
||||
let param_ty = ParamEnv::reveal_all().and(ty);
|
||||
let width =
|
||||
tcx.layout_of(param_ty)
|
||||
.map_err(|_| {
|
||||
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||
"couldn't compute width of literal: {:?}",
|
||||
lit_input.lit
|
||||
)))
|
||||
})?
|
||||
.size;
|
||||
let width = match tcx.layout_of(param_ty) {
|
||||
Ok(layout) => layout.size,
|
||||
Err(_) => {
|
||||
tcx.dcx().bug(format!("couldn't compute width of literal: {:?}", lit_input.lit))
|
||||
}
|
||||
};
|
||||
trace!("trunc {} with size {} and shift {}", n, width.bits(), 128 - width.bits());
|
||||
let result = width.truncate(n);
|
||||
trace!("trunc result: {}", result);
|
||||
|
@ -59,15 +56,11 @@ pub(crate) fn lit_to_const<'tcx>(
|
|||
}
|
||||
(ast::LitKind::Bool(b), ty::Bool) => ty::ValTree::from_scalar_int((*b).into()),
|
||||
(ast::LitKind::Float(n, _), ty::Float(fty)) => {
|
||||
let bits =
|
||||
parse_float_into_scalar(*n, *fty, neg)
|
||||
.ok_or_else(|| {
|
||||
LitToConstError::Reported(tcx.dcx().delayed_bug(format!(
|
||||
"couldn't parse float literal: {:?}",
|
||||
lit_input.lit
|
||||
)))
|
||||
})?
|
||||
.assert_int();
|
||||
let bits = parse_float_into_scalar(*n, *fty, neg)
|
||||
.ok_or_else(|| {
|
||||
tcx.dcx().bug(format!("couldn't parse float literal: {:?}", lit_input.lit))
|
||||
})?
|
||||
.assert_int();
|
||||
ty::ValTree::from_scalar_int(bits)
|
||||
}
|
||||
(ast::LitKind::Char(c), ty::Char) => ty::ValTree::from_scalar_int((*c).into()),
|
||||
|
|
|
@ -175,7 +175,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
) -> Result<PatKind<'tcx>, ErrorGuaranteed> {
|
||||
if lo_expr.is_none() && hi_expr.is_none() {
|
||||
let msg = "found twice-open range pattern (`..`) outside of error recovery";
|
||||
return Err(self.tcx.dcx().span_delayed_bug(span, msg));
|
||||
self.tcx.dcx().span_bug(span, msg);
|
||||
}
|
||||
|
||||
let (lo, lo_ascr, lo_inline) = self.lower_pattern_range_endpoint(lo_expr)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue