Unwrap allocated Location at creation

This commit is contained in:
Smitty
2021-06-18 17:33:33 -04:00
parent 43b55cf893
commit 3e735a52fe
3 changed files with 9 additions and 14 deletions

View File

@@ -31,11 +31,7 @@ pub(crate) fn const_caller_location(
trace!("const_caller_location: {}:{}:{}", file, line, col);
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), false);
// This can fail if rustc runs out of memory right here. Trying to emit an error would be
// pointless, since that would require allocating more memory than a Location.
let loc_place = ecx
.alloc_caller_location(file, line, col)
.expect("not enough memory to allocate location?");
let loc_place = ecx.alloc_caller_location(file, line, col);
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() {
bug!("intern_const_alloc_recursive should not error in this case")
}