@@ -763,6 +763,28 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
763763 self . resolver . get_import_res ( id) . present_items ( )
764764 }
765765
766+ fn make_lang_item_path (
767+ & mut self ,
768+ lang_item : hir:: LangItem ,
769+ span : Span ,
770+ args : Option < & ' hir hir:: GenericArgs < ' hir > > ,
771+ ) -> & ' hir hir:: Path < ' hir > {
772+ let def_id = self . tcx . require_lang_item ( lang_item, Some ( span) ) ;
773+ let def_kind = self . tcx . def_kind ( def_id) ;
774+ let res = Res :: Def ( def_kind, def_id) ;
775+ self . arena . alloc ( hir:: Path {
776+ span,
777+ res,
778+ segments : self . arena . alloc_from_iter ( [ hir:: PathSegment {
779+ ident : Ident :: new ( lang_item. name ( ) , span) ,
780+ hir_id : self . next_id ( ) ,
781+ res,
782+ args,
783+ infer_args : false ,
784+ } ] ) ,
785+ } )
786+ }
787+
766788 /// Reuses the span but adds information like the kind of the desugaring and features that are
767789 /// allowed inside this span.
768790 fn mark_span_with_reason (
@@ -1965,18 +1987,24 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19651987 CoroutineKind :: Gen { .. } => ( hir:: ITERATOR_ITEM_NAME , hir:: LangItem :: Iterator ) ,
19661988 } ;
19671989
1968- let future_args = self . arena . alloc ( hir:: GenericArgs {
1990+ let bound_args = self . arena . alloc ( hir:: GenericArgs {
19691991 args : & [ ] ,
19701992 bindings : arena_vec ! [ self ; self . assoc_ty_binding( assoc_ty_name, span, output_ty) ] ,
19711993 parenthesized : hir:: GenericArgsParentheses :: No ,
19721994 span_ext : DUMMY_SP ,
19731995 } ) ;
19741996
1975- hir:: GenericBound :: LangItemTrait (
1976- trait_lang_item,
1977- self . lower_span ( span) ,
1978- self . next_id ( ) ,
1979- future_args,
1997+ let span = self . lower_span ( span) ;
1998+ hir:: GenericBound :: Trait (
1999+ hir:: PolyTraitRef {
2000+ bound_generic_params : & [ ] ,
2001+ trait_ref : hir:: TraitRef {
2002+ path : self . make_lang_item_path ( trait_lang_item, span, Some ( bound_args) ) ,
2003+ hir_ref_id : self . next_id ( ) ,
2004+ } ,
2005+ span,
2006+ } ,
2007+ hir:: TraitBoundModifier :: None ,
19802008 )
19812009 }
19822010
0 commit comments