add error_occured field to ConstQualifs, fix #76064
This commit is contained in:
parent
7f5a42b073
commit
8bce9af78c
6 changed files with 30 additions and 6 deletions
|
@ -9,6 +9,7 @@ use crate::interpret::{
|
|||
use rustc_hir::def::DefKind;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::ErrorHandled;
|
||||
use rustc_errors::ErrorReported;
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::{self, subst::Subst, TyCtxt};
|
||||
|
@ -274,6 +275,10 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
|
|||
return Err(ErrorHandled::Reported(error_reported));
|
||||
}
|
||||
}
|
||||
let qualif = tcx.mir_const_qualif_opt_const_arg(def);
|
||||
if qualif.error_occured {
|
||||
return Err(ErrorHandled::Reported(ErrorReported {}));
|
||||
}
|
||||
}
|
||||
|
||||
let is_static = tcx.is_static(def.did);
|
||||
|
|
|
@ -9,11 +9,12 @@ use rustc_trait_selection::traits;
|
|||
|
||||
use super::ConstCx;
|
||||
|
||||
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> ConstQualifs {
|
||||
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>, error_occured: bool) -> ConstQualifs {
|
||||
ConstQualifs {
|
||||
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
|
||||
needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty),
|
||||
custom_eq: CustomEq::in_any_value_of_ty(cx, ty),
|
||||
error_occured,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ impl Qualifs<'mir, 'tcx> {
|
|||
has_mut_interior.get().contains(local) || self.indirectly_mutable(ccx, local, location)
|
||||
}
|
||||
|
||||
fn in_return_place(&mut self, ccx: &'mir ConstCx<'mir, 'tcx>) -> ConstQualifs {
|
||||
fn in_return_place(&mut self, ccx: &'mir ConstCx<'mir, 'tcx>, error_occured: bool) -> ConstQualifs {
|
||||
// Find the `Return` terminator if one exists.
|
||||
//
|
||||
// If no `Return` terminator exists, this MIR is divergent. Just return the conservative
|
||||
|
@ -139,7 +139,7 @@ impl Qualifs<'mir, 'tcx> {
|
|||
.map(|(bb, _)| bb);
|
||||
|
||||
let return_block = match return_block {
|
||||
None => return qualifs::in_any_value_of_ty(ccx, ccx.body.return_ty()),
|
||||
None => return qualifs::in_any_value_of_ty(ccx, ccx.body.return_ty(), error_occured),
|
||||
Some(bb) => bb,
|
||||
};
|
||||
|
||||
|
@ -170,6 +170,7 @@ impl Qualifs<'mir, 'tcx> {
|
|||
needs_drop: self.needs_drop(ccx, RETURN_PLACE, return_loc),
|
||||
has_mut_interior: self.has_mut_interior(ccx, RETURN_PLACE, return_loc),
|
||||
custom_eq,
|
||||
error_occured,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -276,7 +277,7 @@ impl Validator<'mir, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn qualifs_in_return_place(&mut self) -> ConstQualifs {
|
||||
self.qualifs.in_return_place(self.ccx)
|
||||
self.qualifs.in_return_place(self.ccx, self.error_emitted)
|
||||
}
|
||||
|
||||
/// Emits an error if an expression cannot be evaluated in the current context.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue