@@ -39,6 +39,7 @@ use crate::hir::map::{DefKey, DefPathData, Definitions};
3939use crate :: hir:: def_id:: { DefId , DefIndex , CRATE_DEF_INDEX } ;
4040use crate :: hir:: def:: { Res , DefKind , PartialRes , PerNS } ;
4141use crate :: hir:: { GenericArg , ConstArg } ;
42+ use crate :: hir:: ptr:: P ;
4243use crate :: lint:: builtin:: { self , PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ,
4344 ELIDED_LIFETIMES_IN_PATHS } ;
4445use crate :: middle:: cstore:: CrateStore ;
@@ -61,7 +62,6 @@ use syntax::ast::*;
6162use syntax:: errors;
6263use syntax:: ext:: hygiene:: { Mark , SyntaxContext } ;
6364use syntax:: print:: pprust;
64- use syntax:: ptr:: P ;
6565use syntax:: source_map:: { self , respan, ExpnInfo , CompilerDesugaringKind , Spanned } ;
6666use syntax:: source_map:: CompilerDesugaringKind :: IfTemporary ;
6767use syntax:: std_inject;
@@ -1111,7 +1111,7 @@ impl<'a> LoweringContext<'a> {
11111111 } ,
11121112 ) ;
11131113
1114- lowered_generics . params = lowered_generics
1114+ let mut lowered_params : Vec < _ > = lowered_generics
11151115 . params
11161116 . into_iter ( )
11171117 . chain ( in_band_defs)
@@ -1121,14 +1121,16 @@ impl<'a> LoweringContext<'a> {
11211121 // unsorted generic parameters at the moment, so we make sure
11221122 // that they're ordered correctly here for now. (When we chain
11231123 // the `in_band_defs`, we might make the order unsorted.)
1124- lowered_generics . params . sort_by_key ( |param| {
1124+ lowered_params . sort_by_key ( |param| {
11251125 match param. kind {
11261126 hir:: GenericParamKind :: Lifetime { .. } => ParamKindOrd :: Lifetime ,
11271127 hir:: GenericParamKind :: Type { .. } => ParamKindOrd :: Type ,
11281128 hir:: GenericParamKind :: Const { .. } => ParamKindOrd :: Const ,
11291129 }
11301130 } ) ;
11311131
1132+ lowered_generics. params = lowered_params. into ( ) ;
1133+
11321134 ( lowered_generics, res)
11331135 }
11341136
@@ -1155,13 +1157,13 @@ impl<'a> LoweringContext<'a> {
11551157 & mut self ,
11561158 capture_clause : CaptureBy ,
11571159 closure_node_id : NodeId ,
1158- ret_ty : Option < & Ty > ,
1160+ ret_ty : Option < syntax :: ptr :: P < Ty > > ,
11591161 span : Span ,
11601162 body : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: Expr ,
11611163 ) -> hir:: ExprKind {
11621164 let capture_clause = self . lower_capture_clause ( capture_clause) ;
11631165 let output = match ret_ty {
1164- Some ( ty) => FunctionRetTy :: Ty ( P ( ty . clone ( ) ) ) ,
1166+ Some ( ty) => FunctionRetTy :: Ty ( ty ) ,
11651167 None => FunctionRetTy :: Default ( span) ,
11661168 } ;
11671169 let ast_decl = FnDecl {
@@ -2725,7 +2727,7 @@ impl<'a> LoweringContext<'a> {
27252727
27262728 // ::std::future::Future<future_params>
27272729 let future_path =
2728- self . std_path ( span, & [ sym:: future, sym:: Future ] , Some ( future_params) , false ) ;
2730+ P ( self . std_path ( span, & [ sym:: future, sym:: Future ] , Some ( future_params) , false ) ) ;
27292731
27302732 hir:: GenericBound :: Trait (
27312733 hir:: PolyTraitRef {
@@ -3094,7 +3096,7 @@ impl<'a> LoweringContext<'a> {
30943096
30953097 fn lower_trait_ref ( & mut self , p : & TraitRef , itctx : ImplTraitContext < ' _ > ) -> hir:: TraitRef {
30963098 let path = match self . lower_qpath ( p. ref_id , & None , & p. path , ParamMode :: Explicit , itctx) {
3097- hir:: QPath :: Resolved ( None , path) => path. and_then ( |path| path ) ,
3099+ hir:: QPath :: Resolved ( None , path) => path,
30983100 qpath => bug ! ( "lower_trait_ref: unexpected QPath `{:?}`" , qpath) ,
30993101 } ;
31003102 hir:: TraitRef {
@@ -3620,7 +3622,7 @@ impl<'a> LoweringContext<'a> {
36203622 hir:: Item {
36213623 hir_id : new_id,
36223624 ident,
3623- attrs : attrs. clone ( ) ,
3625+ attrs : attrs. into_iter ( ) . cloned ( ) . collect ( ) ,
36243626 node : item,
36253627 vis,
36263628 span,
@@ -3705,7 +3707,7 @@ impl<'a> LoweringContext<'a> {
37053707 hir:: Item {
37063708 hir_id : new_hir_id,
37073709 ident,
3708- attrs : attrs. clone ( ) ,
3710+ attrs : attrs. into_iter ( ) . cloned ( ) . collect ( ) ,
37093711 node : item,
37103712 vis,
37113713 span : use_tree. span ,
@@ -4567,7 +4569,7 @@ impl<'a> LoweringContext<'a> {
45674569 // `|x: u8| future_from_generator(|| -> X { ... })`.
45684570 let body_id = this. lower_fn_body ( & outer_decl, |this| {
45694571 let async_ret_ty = if let FunctionRetTy :: Ty ( ty) = & decl. output {
4570- Some ( & * * ty )
4572+ Some ( ty . clone ( ) )
45714573 } else { None } ;
45724574 let async_body = this. make_async_expr (
45734575 capture_clause, closure_id, async_ret_ty, body. span ,
@@ -5577,7 +5579,7 @@ impl<'a> LoweringContext<'a> {
55775579 let principal = hir:: PolyTraitRef {
55785580 bound_generic_params : hir:: HirVec :: new ( ) ,
55795581 trait_ref : hir:: TraitRef {
5580- path : path . and_then ( |path| path ) ,
5582+ path,
55815583 hir_ref_id : hir_id,
55825584 } ,
55835585 span,
0 commit comments