@@ -39,6 +39,7 @@ use crate::hir::map::{DefKey, DefPathData, Definitions};
39
39
use crate :: hir:: def_id:: { DefId , DefIndex , CRATE_DEF_INDEX } ;
40
40
use crate :: hir:: def:: { Res , DefKind , PartialRes , PerNS } ;
41
41
use crate :: hir:: { GenericArg , ConstArg } ;
42
+ use crate :: hir:: ptr:: P ;
42
43
use crate :: lint:: builtin:: { self , PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ,
43
44
ELIDED_LIFETIMES_IN_PATHS } ;
44
45
use crate :: middle:: cstore:: CrateStore ;
@@ -61,7 +62,6 @@ use syntax::ast::*;
61
62
use syntax:: errors;
62
63
use syntax:: ext:: hygiene:: { Mark , SyntaxContext } ;
63
64
use syntax:: print:: pprust;
64
- use syntax:: ptr:: P ;
65
65
use syntax:: source_map:: { self , respan, ExpnInfo , CompilerDesugaringKind , Spanned } ;
66
66
use syntax:: source_map:: CompilerDesugaringKind :: IfTemporary ;
67
67
use syntax:: std_inject;
@@ -1111,7 +1111,7 @@ impl<'a> LoweringContext<'a> {
1111
1111
} ,
1112
1112
) ;
1113
1113
1114
- lowered_generics . params = lowered_generics
1114
+ let mut lowered_params : Vec < _ > = lowered_generics
1115
1115
. params
1116
1116
. into_iter ( )
1117
1117
. chain ( in_band_defs)
@@ -1121,14 +1121,16 @@ impl<'a> LoweringContext<'a> {
1121
1121
// unsorted generic parameters at the moment, so we make sure
1122
1122
// that they're ordered correctly here for now. (When we chain
1123
1123
// 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| {
1125
1125
match param. kind {
1126
1126
hir:: GenericParamKind :: Lifetime { .. } => ParamKindOrd :: Lifetime ,
1127
1127
hir:: GenericParamKind :: Type { .. } => ParamKindOrd :: Type ,
1128
1128
hir:: GenericParamKind :: Const { .. } => ParamKindOrd :: Const ,
1129
1129
}
1130
1130
} ) ;
1131
1131
1132
+ lowered_generics. params = lowered_params. into ( ) ;
1133
+
1132
1134
( lowered_generics, res)
1133
1135
}
1134
1136
@@ -1155,13 +1157,13 @@ impl<'a> LoweringContext<'a> {
1155
1157
& mut self ,
1156
1158
capture_clause : CaptureBy ,
1157
1159
closure_node_id : NodeId ,
1158
- ret_ty : Option < & Ty > ,
1160
+ ret_ty : Option < syntax :: ptr :: P < Ty > > ,
1159
1161
span : Span ,
1160
1162
body : impl FnOnce ( & mut LoweringContext < ' _ > ) -> hir:: Expr ,
1161
1163
) -> hir:: ExprKind {
1162
1164
let capture_clause = self . lower_capture_clause ( capture_clause) ;
1163
1165
let output = match ret_ty {
1164
- Some ( ty) => FunctionRetTy :: Ty ( P ( ty . clone ( ) ) ) ,
1166
+ Some ( ty) => FunctionRetTy :: Ty ( ty ) ,
1165
1167
None => FunctionRetTy :: Default ( span) ,
1166
1168
} ;
1167
1169
let ast_decl = FnDecl {
@@ -2725,7 +2727,7 @@ impl<'a> LoweringContext<'a> {
2725
2727
2726
2728
// ::std::future::Future<future_params>
2727
2729
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 ) ) ;
2729
2731
2730
2732
hir:: GenericBound :: Trait (
2731
2733
hir:: PolyTraitRef {
@@ -3094,7 +3096,7 @@ impl<'a> LoweringContext<'a> {
3094
3096
3095
3097
fn lower_trait_ref ( & mut self , p : & TraitRef , itctx : ImplTraitContext < ' _ > ) -> hir:: TraitRef {
3096
3098
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,
3098
3100
qpath => bug ! ( "lower_trait_ref: unexpected QPath `{:?}`" , qpath) ,
3099
3101
} ;
3100
3102
hir:: TraitRef {
@@ -3620,7 +3622,7 @@ impl<'a> LoweringContext<'a> {
3620
3622
hir:: Item {
3621
3623
hir_id : new_id,
3622
3624
ident,
3623
- attrs : attrs. clone ( ) ,
3625
+ attrs : attrs. into_iter ( ) . cloned ( ) . collect ( ) ,
3624
3626
node : item,
3625
3627
vis,
3626
3628
span,
@@ -3705,7 +3707,7 @@ impl<'a> LoweringContext<'a> {
3705
3707
hir:: Item {
3706
3708
hir_id : new_hir_id,
3707
3709
ident,
3708
- attrs : attrs. clone ( ) ,
3710
+ attrs : attrs. into_iter ( ) . cloned ( ) . collect ( ) ,
3709
3711
node : item,
3710
3712
vis,
3711
3713
span : use_tree. span ,
@@ -4567,7 +4569,7 @@ impl<'a> LoweringContext<'a> {
4567
4569
// `|x: u8| future_from_generator(|| -> X { ... })`.
4568
4570
let body_id = this. lower_fn_body ( & outer_decl, |this| {
4569
4571
let async_ret_ty = if let FunctionRetTy :: Ty ( ty) = & decl. output {
4570
- Some ( & * * ty )
4572
+ Some ( ty . clone ( ) )
4571
4573
} else { None } ;
4572
4574
let async_body = this. make_async_expr (
4573
4575
capture_clause, closure_id, async_ret_ty, body. span ,
@@ -5577,7 +5579,7 @@ impl<'a> LoweringContext<'a> {
5577
5579
let principal = hir:: PolyTraitRef {
5578
5580
bound_generic_params : hir:: HirVec :: new ( ) ,
5579
5581
trait_ref : hir:: TraitRef {
5580
- path : path . and_then ( |path| path ) ,
5582
+ path,
5581
5583
hir_ref_id : hir_id,
5582
5584
} ,
5583
5585
span,
0 commit comments