Skip to content

Commit c10ad0d

Browse files
committed
review
1 parent ef6100e commit c10ad0d

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ pub struct Body<'tcx> {
197197
/// let _ = [0; std::mem::size_of::<*mut T>()];
198198
/// }
199199
/// ```
200+
///
201+
/// **WARNING**: Do not change this flags after the MIR was originally created, even if an optimization
202+
/// removed the last mention of all generic params. We do not want to rely on optimizations and
203+
/// potentially allow things like `[u8; std::mem::size_of::<T>() * 0]` due to this.
200204
pub is_polymorphic: bool,
201205

202206
predecessor_cache: PredecessorCache,

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,16 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
459459
}
460460

461461
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
462-
const_evaluatable::is_const_evaluatable(
462+
match const_evaluatable::is_const_evaluatable(
463463
self.selcx.infcx(),
464464
def_id,
465465
substs,
466466
obligation.param_env,
467467
obligation.cause.span,
468-
)
469-
.map_or_else(
470-
|e| ProcessResult::Error(CodeSelectionError(ConstEvalFailure(e))),
471-
|()| ProcessResult::Changed(vec![]),
472-
)
468+
) {
469+
Ok(()) => ProcessResult::Changed(vec![]),
470+
Err(e) => ProcessResult::Error(CodeSelectionError(ConstEvalFailure(e))),
471+
}
473472
}
474473

475474
ty::PredicateAtom::ConstEquate(c1, c2) => {

compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
543543
}
544544

545545
ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
546-
const_evaluatable::is_const_evaluatable(
546+
match const_evaluatable::is_const_evaluatable(
547547
self.infcx,
548548
def_id,
549549
substs,
550550
obligation.param_env,
551551
obligation.cause.span,
552-
)
553-
.map(|()| EvaluatedToOk)
554-
.or_else(|e| match e {
555-
ErrorHandled::TooGeneric => Ok(EvaluatedToAmbig),
556-
_ => Ok(EvaluatedToErr),
557-
})
552+
) {
553+
Ok(()) => Ok(EvaluatedToOk),
554+
Err(ErrorHandled::TooGeneric) => Ok(EvaluatedToAmbig),
555+
Err(_) => Ok(EvaluatedToErr),
556+
}
558557
}
559558

560559
ty::PredicateAtom::ConstEquate(c1, c2) => {

0 commit comments

Comments
 (0)