This commit is contained in:
Bastian Kauschke 2020-08-06 22:12:21 +02:00
parent ef6100e846
commit c10ad0d888
3 changed files with 15 additions and 13 deletions

View File

@ -197,6 +197,10 @@ pub struct Body<'tcx> {
/// let _ = [0; std::mem::size_of::<*mut T>()];
/// }
/// ```
///
/// **WARNING**: Do not change this flags after the MIR was originally created, even if an optimization
/// removed the last mention of all generic params. We do not want to rely on optimizations and
/// potentially allow things like `[u8; std::mem::size_of::<T>() * 0]` due to this.
pub is_polymorphic: bool,
predecessor_cache: PredecessorCache,

View File

@ -459,17 +459,16 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
}
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
const_evaluatable::is_const_evaluatable(
match const_evaluatable::is_const_evaluatable(
self.selcx.infcx(),
def_id,
substs,
obligation.param_env,
obligation.cause.span,
)
.map_or_else(
|e| ProcessResult::Error(CodeSelectionError(ConstEvalFailure(e))),
|()| ProcessResult::Changed(vec![]),
)
) {
Ok(()) => ProcessResult::Changed(vec![]),
Err(e) => ProcessResult::Error(CodeSelectionError(ConstEvalFailure(e))),
}
}
ty::PredicateAtom::ConstEquate(c1, c2) => {

View File

@ -543,18 +543,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
const_evaluatable::is_const_evaluatable(
match const_evaluatable::is_const_evaluatable(
self.infcx,
def_id,
substs,
obligation.param_env,
obligation.cause.span,
)
.map(|()| EvaluatedToOk)
.or_else(|e| match e {
ErrorHandled::TooGeneric => Ok(EvaluatedToAmbig),
_ => Ok(EvaluatedToErr),
})
) {
Ok(()) => Ok(EvaluatedToOk),
Err(ErrorHandled::TooGeneric) => Ok(EvaluatedToAmbig),
Err(_) => Ok(EvaluatedToErr),
}
}
ty::PredicateAtom::ConstEquate(c1, c2) => {