1
Fork 0

skip const eval if we have an error in borrowck

This commit is contained in:
Michael Goulet 2022-02-06 12:16:49 -08:00
parent 4ad272b282
commit 77dae2d25d
3 changed files with 22 additions and 2 deletions

View file

@ -287,6 +287,9 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
if let Some(error_reported) = tcx.typeck_opt_const_arg(def).tainted_by_errors {
return Err(ErrorHandled::Reported(error_reported));
}
if tcx.mir_borrowck_opt_const_arg(def).tainted_by_errors {
return Err(ErrorHandled::Reported(ErrorReported {}));
}
}
if !tcx.is_mir_available(def.did) {
tcx.sess.delay_span_bug(

View file

@ -514,10 +514,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
if let Some(def) = def.as_local() {
if self.tcx.has_typeck_results(def.did) {
if let Some(error_reported) = self.tcx.typeck_opt_const_arg(def).tainted_by_errors {
throw_inval!(AlreadyReported(error_reported))
throw_inval!(AlreadyReported(error_reported));
}
if self.tcx.mir_borrowck_opt_const_arg(def).tainted_by_errors {
throw_inval!(AlreadyReported(rustc_errors::ErrorReported {}));
}
}
}
trace!("load mir(instance={:?}, promoted={:?})", instance, promoted);
if let Some(promoted) = promoted {
return Ok(&self.tcx.promoted_mir_opt_const_arg(def)[promoted]);