skip const eval if we have an error in borrowck
This commit is contained in:
parent
4ad272b282
commit
77dae2d25d
3 changed files with 22 additions and 2 deletions
|
@ -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(
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -8,7 +8,9 @@ use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
|
|||
use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath};
|
||||
use crate::middle::stability;
|
||||
use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
|
||||
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
|
||||
use crate::mir::{
|
||||
Body, BorrowCheckResult, Field, Local, Place, PlaceElem, ProjectionKind, Promoted,
|
||||
};
|
||||
use crate::thir::Thir;
|
||||
use crate::traits;
|
||||
use crate::ty::query::{self, TyCtxtAt};
|
||||
|
@ -1061,6 +1063,17 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mir_borrowck_opt_const_arg(
|
||||
self,
|
||||
def: ty::WithOptConstParam<LocalDefId>,
|
||||
) -> &'tcx BorrowCheckResult<'tcx> {
|
||||
if let Some(param_did) = def.const_param_did {
|
||||
self.mir_borrowck_const_arg((def.did, param_did))
|
||||
} else {
|
||||
self.mir_borrowck(def.did)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alloc_steal_thir(self, thir: Thir<'tcx>) -> &'tcx Steal<Thir<'tcx>> {
|
||||
self.arena.alloc(Steal::new(thir))
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue