@@ -1219,13 +1219,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12191219 let bound = this. lower_poly_trait_ref (
12201220 & PolyTraitRef {
12211221 bound_generic_params : ThinVec :: new ( ) ,
1222+ modifiers : TraitBoundModifiers :: NONE ,
12221223 trait_ref : TraitRef { path : path. clone ( ) , ref_id : t. id } ,
12231224 span : t. span ,
12241225 } ,
12251226 itctx,
1226- TraitBoundModifiers :: NONE ,
12271227 ) ;
1228- let bound = ( bound, hir:: TraitBoundModifier :: None ) ;
12291228 let bounds = this. arena . alloc_from_iter ( [ bound] ) ;
12301229 let lifetime_bound = this. elided_dyn_bound ( t. span ) ;
12311230 ( bounds, lifetime_bound)
@@ -1326,10 +1325,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13261325 // We can safely ignore constness here since AST validation
13271326 // takes care of rejecting invalid modifier combinations and
13281327 // const trait bounds in trait object types.
1329- GenericBound :: Trait ( ty, modifiers) => {
1330- let trait_ref = this. lower_poly_trait_ref ( ty, itctx, * modifiers) ;
1331- let polarity = this. lower_trait_bound_modifiers ( * modifiers) ;
1332- Some ( ( trait_ref, polarity) )
1328+ GenericBound :: Trait ( ty) => {
1329+ let trait_ref = this. lower_poly_trait_ref ( ty, itctx) ;
1330+ Some ( trait_ref)
13331331 }
13341332 GenericBound :: Outlives ( lifetime) => {
13351333 if lifetime_bound. is_none ( ) {
@@ -1958,21 +1956,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19581956 span_ext : DUMMY_SP ,
19591957 } ) ;
19601958
1961- hir:: GenericBound :: Trait (
1962- hir:: PolyTraitRef {
1963- bound_generic_params : & [ ] ,
1964- trait_ref : hir:: TraitRef {
1965- path : self . make_lang_item_path (
1966- trait_lang_item,
1967- opaque_ty_span,
1968- Some ( bound_args) ,
1969- ) ,
1970- hir_ref_id : self . next_id ( ) ,
1971- } ,
1972- span : opaque_ty_span,
1959+ hir:: GenericBound :: Trait ( hir:: PolyTraitRef {
1960+ bound_generic_params : & [ ] ,
1961+ modifiers : hir:: TraitBoundModifier :: None ,
1962+ trait_ref : hir:: TraitRef {
1963+ path : self . make_lang_item_path ( trait_lang_item, opaque_ty_span, Some ( bound_args) ) ,
1964+ hir_ref_id : self . next_id ( ) ,
19731965 } ,
1974- hir :: TraitBoundModifier :: None ,
1975- )
1966+ span : opaque_ty_span ,
1967+ } )
19761968 }
19771969
19781970 #[ instrument( level = "trace" , skip( self ) ) ]
@@ -1982,10 +1974,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19821974 itctx : ImplTraitContext ,
19831975 ) -> hir:: GenericBound < ' hir > {
19841976 match tpb {
1985- GenericBound :: Trait ( p, modifiers) => hir:: GenericBound :: Trait (
1986- self . lower_poly_trait_ref ( p, itctx, * modifiers) ,
1987- self . lower_trait_bound_modifiers ( * modifiers) ,
1988- ) ,
1977+ GenericBound :: Trait ( p) => hir:: GenericBound :: Trait ( self . lower_poly_trait_ref ( p, itctx) ) ,
19891978 GenericBound :: Outlives ( lifetime) => {
19901979 hir:: GenericBound :: Outlives ( self . lower_lifetime ( lifetime) )
19911980 }
@@ -2189,12 +2178,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21892178 & mut self ,
21902179 p : & PolyTraitRef ,
21912180 itctx : ImplTraitContext ,
2192- modifiers : ast:: TraitBoundModifiers ,
21932181 ) -> hir:: PolyTraitRef < ' hir > {
21942182 let bound_generic_params =
21952183 self . lower_lifetime_binder ( p. trait_ref . ref_id , & p. bound_generic_params ) ;
2196- let trait_ref = self . lower_trait_ref ( modifiers, & p. trait_ref , itctx) ;
2197- hir:: PolyTraitRef { bound_generic_params, trait_ref, span : self . lower_span ( p. span ) }
2184+ let trait_ref = self . lower_trait_ref ( p. modifiers , & p. trait_ref , itctx) ;
2185+ let modifiers = self . lower_trait_bound_modifiers ( p. modifiers ) ;
2186+ hir:: PolyTraitRef {
2187+ bound_generic_params,
2188+ modifiers,
2189+ trait_ref,
2190+ span : self . lower_span ( p. span ) ,
2191+ }
21982192 }
21992193
22002194 fn lower_mt ( & mut self , mt : & MutTy , itctx : ImplTraitContext ) -> hir:: MutTy < ' hir > {
@@ -2634,10 +2628,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
26342628 Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , _) => {
26352629 let principal = hir:: PolyTraitRef {
26362630 bound_generic_params : & [ ] ,
2631+ modifiers : hir:: TraitBoundModifier :: None ,
26372632 trait_ref : hir:: TraitRef { path, hir_ref_id : hir_id } ,
26382633 span : self . lower_span ( span) ,
26392634 } ;
2640- let principal = ( principal, hir:: TraitBoundModifier :: None ) ;
26412635
26422636 // The original ID is taken by the `PolyTraitRef`,
26432637 // so the `Ty` itself needs a different one.
0 commit comments