@@ -30,9 +30,9 @@ use rustc_hir::{GenericArg, GenericArgs, OpaqueTyOrigin};
30
30
use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
31
31
use rustc_middle:: middle:: stability:: AllowUnstable ;
32
32
use rustc_middle:: ty:: subst:: { self , GenericArgKind , InternalSubsts , SubstsRef } ;
33
+ use rustc_middle:: ty:: DynKind ;
33
34
use rustc_middle:: ty:: GenericParamDefKind ;
34
35
use rustc_middle:: ty:: { self , Const , DefIdTree , IsSuggestable , Ty , TyCtxt , TypeVisitable } ;
35
- use rustc_middle:: ty:: { DynKind , EarlyBinder } ;
36
36
use rustc_session:: lint:: builtin:: { AMBIGUOUS_ASSOCIATED_ITEMS , BARE_TRAIT_OBJECTS } ;
37
37
use rustc_span:: edition:: Edition ;
38
38
use rustc_span:: lev_distance:: find_best_match_for_name;
@@ -450,7 +450,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
450
450
. into ( )
451
451
}
452
452
( & GenericParamDefKind :: Const { .. } , hir:: GenericArg :: Infer ( inf) ) => {
453
- let ty = tcx. at ( self . span ) . type_of ( param. def_id ) ;
453
+ let ty = tcx
454
+ . at ( self . span )
455
+ . type_of ( param. def_id )
456
+ . no_bound_vars ( )
457
+ . expect ( "const parameter types cannot be generic" ) ;
454
458
if self . astconv . allow_ty_infer ( ) {
455
459
self . astconv . ct_infer ( ty, Some ( param) , inf. span ) . into ( )
456
460
} else {
@@ -494,7 +498,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
494
498
// Avoid ICE #86756 when type error recovery goes awry.
495
499
return tcx. ty_error ( ) . into ( ) ;
496
500
}
497
- tcx. at ( self . span ) . bound_type_of ( param. def_id ) . subst ( tcx, substs) . into ( )
501
+ tcx. at ( self . span ) . type_of ( param. def_id ) . subst ( tcx, substs) . into ( )
498
502
} else if infer_args {
499
503
self . astconv . ty_infer ( Some ( param) , self . span ) . into ( )
500
504
} else {
@@ -503,7 +507,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
503
507
}
504
508
}
505
509
GenericParamDefKind :: Const { has_default } => {
506
- let ty = tcx. at ( self . span ) . type_of ( param. def_id ) ;
510
+ let ty = tcx
511
+ . at ( self . span )
512
+ . type_of ( param. def_id )
513
+ . no_bound_vars ( )
514
+ . expect ( "const parameter types cannot be generic" ) ;
507
515
if ty. references_error ( ) {
508
516
return tcx. const_error ( ty) . into ( ) ;
509
517
}
@@ -1230,7 +1238,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1230
1238
}
1231
1239
hir:: def:: DefKind :: AssocConst => tcx
1232
1240
. const_error_with_guaranteed (
1233
- tcx. bound_type_of ( assoc_item_def_id)
1241
+ tcx. type_of ( assoc_item_def_id)
1234
1242
. subst ( tcx, projection_ty. skip_binder ( ) . substs ) ,
1235
1243
reported,
1236
1244
)
@@ -1267,7 +1275,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1267
1275
item_segment : & hir:: PathSegment < ' _ > ,
1268
1276
) -> Ty < ' tcx > {
1269
1277
let substs = self . ast_path_substs_for_ty ( span, did, item_segment) ;
1270
- self . tcx ( ) . at ( span) . bound_type_of ( did) . subst ( self . tcx ( ) , substs)
1278
+ self . tcx ( ) . at ( span) . type_of ( did) . subst ( self . tcx ( ) , substs)
1271
1279
}
1272
1280
1273
1281
fn conv_object_ty_poly_trait_ref (
@@ -2046,7 +2054,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2046
2054
assoc_segment,
2047
2055
adt_substs,
2048
2056
) ;
2049
- let ty = tcx. bound_type_of ( assoc_ty_did) . subst ( tcx, item_substs) ;
2057
+ let ty = tcx. type_of ( assoc_ty_did) . subst ( tcx, item_substs) ;
2050
2058
return Ok ( ( ty, DefKind :: AssocTy , assoc_ty_did) ) ;
2051
2059
}
2052
2060
}
@@ -2703,7 +2711,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2703
2711
// `Self` in impl (we know the concrete type).
2704
2712
assert_eq ! ( opt_self_ty, None ) ;
2705
2713
// Try to evaluate any array length constants.
2706
- let ty = tcx. at ( span) . type_of ( def_id) ;
2714
+ let ty = tcx. at ( span) . type_of ( def_id) . subst_identity ( ) ;
2707
2715
let span_of_impl = tcx. span_of_impl ( def_id) ;
2708
2716
self . prohibit_generics ( path. segments . iter ( ) , |err| {
2709
2717
let def_id = match * ty. kind ( ) {
@@ -2960,7 +2968,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2960
2968
None ,
2961
2969
ty:: BoundConstness :: NotConst ,
2962
2970
) ;
2963
- EarlyBinder ( tcx. at ( span) . type_of ( def_id) ) . subst ( tcx, substs)
2971
+ tcx. at ( span) . type_of ( def_id) . subst ( tcx, substs)
2964
2972
}
2965
2973
hir:: TyKind :: Array ( ty, length) => {
2966
2974
let length = match length {
@@ -2973,7 +2981,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2973
2981
tcx. mk_array_with_const_len ( self . ast_ty_to_ty ( ty) , length)
2974
2982
}
2975
2983
hir:: TyKind :: Typeof ( e) => {
2976
- let ty_erased = tcx. type_of ( e. def_id ) ;
2984
+ let ty_erased = tcx. type_of ( e. def_id ) . subst_identity ( ) ;
2977
2985
let ty = tcx. fold_regions ( ty_erased, |r, _| {
2978
2986
if r. is_erased ( ) { tcx. lifetimes . re_static } else { r }
2979
2987
} ) ;
0 commit comments