Skip to content

Commit b7de175

Browse files
committed
Fix remap_constness
`~const Drop` was renamed to `~const Destruct` and this special case should be removed
1 parent 74f600b commit b7de175

File tree

2 files changed

+6
-13
lines changed
  • compiler
    • rustc_middle/src/ty
    • rustc_trait_selection/src/traits/select

2 files changed

+6
-13
lines changed

compiler/rustc_middle/src/ty/mod.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -790,22 +790,15 @@ pub struct TraitPredicate<'tcx> {
790790
pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
791791

792792
impl<'tcx> TraitPredicate<'tcx> {
793-
pub fn remap_constness(&mut self, tcx: TyCtxt<'tcx>, param_env: &mut ParamEnv<'tcx>) {
794-
if std::intrinsics::unlikely(Some(self.trait_ref.def_id) == tcx.lang_items().drop_trait()) {
795-
// remap without changing constness of this predicate.
796-
// this is because `T: ~const Drop` has a different meaning to `T: Drop`
797-
// FIXME(fee1-dead): remove this logic after beta bump
798-
param_env.remap_constness_with(self.constness)
799-
} else {
800-
*param_env = param_env.with_constness(self.constness.and(param_env.constness()))
801-
}
793+
pub fn remap_constness(&mut self, param_env: &mut ParamEnv<'tcx>) {
794+
*param_env = param_env.with_constness(self.constness.and(param_env.constness()))
802795
}
803796

804797
/// Remap the constness of this predicate before emitting it for diagnostics.
805798
pub fn remap_constness_diag(&mut self, param_env: ParamEnv<'tcx>) {
806799
// this is different to `remap_constness` that callees want to print this predicate
807800
// in case of selection errors. `T: ~const Drop` bounds cannot end up here when the
808-
// param_env is not const because we it is always satisfied in non-const contexts.
801+
// param_env is not const because it is always satisfied in non-const contexts.
809802
if let hir::Constness::NotConst = param_env.constness() {
810803
self.constness = ty::BoundConstness::NotConst;
811804
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
789789
let mut param_env = obligation.param_env;
790790

791791
fresh_trait_pred = fresh_trait_pred.map_bound(|mut pred| {
792-
pred.remap_constness(self.tcx(), &mut param_env);
792+
pred.remap_constness(&mut param_env);
793793
pred
794794
});
795795

@@ -1321,7 +1321,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13211321
}
13221322
let tcx = self.tcx();
13231323
let mut pred = cache_fresh_trait_pred.skip_binder();
1324-
pred.remap_constness(tcx, &mut param_env);
1324+
pred.remap_constness(&mut param_env);
13251325

13261326
if self.can_use_global_caches(param_env) {
13271327
if let Some(res) = tcx.selection_cache.get(&(param_env, pred), tcx) {
@@ -1375,7 +1375,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13751375
let tcx = self.tcx();
13761376
let mut pred = cache_fresh_trait_pred.skip_binder();
13771377

1378-
pred.remap_constness(tcx, &mut param_env);
1378+
pred.remap_constness(&mut param_env);
13791379

13801380
if !self.can_cache_candidate(&candidate) {
13811381
debug!(?pred, ?candidate, "insert_candidate_cache - candidate is not cacheable");

0 commit comments

Comments
 (0)