@@ -15,6 +15,7 @@ use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst,
15
15
use rustc_middle:: ty:: { self , GenericParamDefKind , Ty , TyCtxt } ;
16
16
use rustc_middle:: ty:: { ToPolyTraitRef , ToPredicate } ;
17
17
use rustc_span:: def_id:: DefId ;
18
+ use rustc_span:: sym;
18
19
19
20
use crate :: traits:: project:: { normalize_with_depth, normalize_with_depth_to} ;
20
21
use crate :: traits:: util:: { self , closure_trait_ref_and_return_type, predicate_for_trait_def} ;
@@ -44,6 +45,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
44
45
) -> Result < Selection < ' tcx > , SelectionError < ' tcx > > {
45
46
// let new_obligation;
46
47
48
+ // when const_trait_impl not enabled, all const predicates are unimplemented
49
+ if obligation. predicate . constness ( ) == ty:: ConstnessArg :: Const {
50
+ if !self . tcx ( ) . features ( ) . enabled ( sym:: const_trait_impl) {
51
+ return Err ( SelectionError :: Unimplemented )
52
+ }
53
+ }
54
+ // TODO rm
47
55
// HACK(const_trait_impl): the surrounding environment is remapped to a non-const context
48
56
// because nested obligations might be actually `~const` then (incorrectly) requiring
49
57
// const impls. for example:
@@ -1233,10 +1241,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1233
1241
. rebind ( ty:: TraitPredicate {
1234
1242
trait_ref : ty:: TraitRef {
1235
1243
def_id : self . tcx ( ) . require_lang_item ( LangItem :: Destruct , None ) ,
1236
- substs : self . tcx ( ) . mk_substs_trait (
1237
- nested_ty,
1238
- & [ ty:: ConstnessArg :: Const . into ( ) ] ,
1239
- ) ,
1244
+ substs : self
1245
+ . tcx ( )
1246
+ . mk_substs_trait ( nested_ty, & [ ty:: ConstnessArg :: Const . into ( ) ] ) ,
1240
1247
} ,
1241
1248
polarity : ty:: ImplPolarity :: Positive ,
1242
1249
} )
0 commit comments