@@ -713,6 +713,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
713713 & self ,
714714 trait_ref : & hir:: TraitRef < ' _ > ,
715715 self_ty : Ty < ' tcx > ,
716+ constness : hir:: Constness ,
716717 ) -> ty:: TraitRef < ' tcx > {
717718 self . prohibit_generics ( trait_ref. path . segments . split_last ( ) . unwrap ( ) . 1 . iter ( ) , |_| { } ) ;
718719
@@ -722,6 +723,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
722723 self_ty,
723724 trait_ref. path . segments . last ( ) . unwrap ( ) ,
724725 true ,
726+ match constness {
727+ hir:: Constness :: Const => ty:: ConstnessArg :: Param ,
728+ hir:: Constness :: NotConst => ty:: ConstnessArg :: Not ,
729+ } ,
725730 )
726731 }
727732
@@ -877,13 +882,15 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
877882 self_ty : Ty < ' tcx > ,
878883 trait_segment : & hir:: PathSegment < ' _ > ,
879884 is_impl : bool ,
885+ constness : ty:: ConstnessArg ,
880886 ) -> ty:: TraitRef < ' tcx > {
881887 let ( substs, _) = self . create_substs_for_ast_trait_ref (
882888 span,
883889 trait_def_id,
884890 self_ty,
885891 trait_segment,
886892 is_impl,
893+ constness,
887894 ) ;
888895 let assoc_bindings = self . create_assoc_bindings_for_generic_args ( trait_segment. args ( ) ) ;
889896 if let Some ( b) = assoc_bindings. first ( ) {
@@ -900,6 +907,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
900907 self_ty : Ty < ' tcx > ,
901908 trait_segment : & ' a hir:: PathSegment < ' a > ,
902909 is_impl : bool ,
910+ constness : ty:: ConstnessArg ,
903911 ) -> ( SubstsRef < ' tcx > , GenericArgCountResult ) {
904912 self . complain_about_internal_fn_trait ( span, trait_def_id, trait_segment, is_impl) ;
905913
@@ -911,7 +919,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
911919 trait_segment. args ( ) ,
912920 trait_segment. infer_args ,
913921 Some ( self_ty) ,
914- Some ( ty :: ConstnessArg :: Not ) ,
922+ Some ( constness ) ,
915923 )
916924 }
917925
@@ -2122,8 +2130,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21222130
21232131 debug ! ( "qpath_to_ty: self_type={:?}" , self_ty) ;
21242132
2125- let trait_ref =
2126- self . ast_path_to_mono_trait_ref ( span, trait_def_id, self_ty, trait_segment, false ) ;
2133+ let trait_ref = self . ast_path_to_mono_trait_ref (
2134+ span,
2135+ trait_def_id,
2136+ self_ty,
2137+ trait_segment,
2138+ false ,
2139+ ty:: ConstnessArg :: Not ,
2140+ ) ;
21272141
21282142 let item_substs = self . create_substs_for_associated_item (
21292143 tcx,
@@ -2926,8 +2940,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
29262940 let hir:: Node :: Item ( hir:: Item { kind : hir:: ItemKind :: Impl ( i) , .. } ) =
29272941 hir. get ( hir. get_parent_node ( fn_hir_id) ) else { bug ! ( "ImplItem should have Impl parent" ) } ;
29282942
2929- let trait_ref =
2930- self . instantiate_mono_trait_ref ( i. of_trait . as_ref ( ) ?, self . ast_ty_to_ty ( i. self_ty ) ) ;
2943+ let trait_ref = self . instantiate_mono_trait_ref (
2944+ i. of_trait . as_ref ( ) ?,
2945+ self . ast_ty_to_ty ( i. self_ty ) ,
2946+ hir:: Constness :: NotConst ,
2947+ ) ;
29312948
29322949 let assoc = tcx. associated_items ( trait_ref. def_id ) . find_by_name_and_kind (
29332950 tcx,
0 commit comments