@@ -3,9 +3,9 @@ use crate::deriving::generic::*;
3
3
use crate :: deriving:: path_std;
4
4
5
5
use rustc_ast:: ptr:: P ;
6
- use rustc_ast:: { self as ast, Expr , GenericArg , Generics , ItemKind , MetaItem , VariantData } ;
6
+ use rustc_ast:: { self as ast, Expr , Generics , ItemKind , MetaItem , VariantData } ;
7
7
use rustc_expand:: base:: { Annotatable , ExtCtxt } ;
8
- use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
8
+ use rustc_span:: symbol:: { kw, sym, Ident } ;
9
9
use rustc_span:: Span ;
10
10
11
11
pub fn expand_deriving_clone (
@@ -107,36 +107,30 @@ fn cs_clone_shallow(
107
107
substr : & Substructure < ' _ > ,
108
108
is_union : bool ,
109
109
) -> P < Expr > {
110
- fn assert_ty_bounds (
111
- cx : & mut ExtCtxt < ' _ > ,
112
- stmts : & mut Vec < ast:: Stmt > ,
113
- ty : P < ast:: Ty > ,
114
- span : Span ,
115
- helper_name : & str ,
116
- ) {
117
- // Generate statement `let _: helper_name<ty>;`,
118
- // set the expn ID so we can use the unstable struct.
119
- let span = cx. with_def_site_ctxt ( span) ;
120
- let assert_path = cx. path_all (
121
- span,
122
- true ,
123
- cx. std_path ( & [ sym:: clone, Symbol :: intern ( helper_name) ] ) ,
124
- vec ! [ GenericArg :: Type ( ty) ] ,
125
- ) ;
126
- stmts. push ( cx. stmt_let_type_only ( span, cx. ty_path ( assert_path) ) ) ;
127
- }
128
110
fn process_variant ( cx : & mut ExtCtxt < ' _ > , stmts : & mut Vec < ast:: Stmt > , variant : & VariantData ) {
129
111
for field in variant. fields ( ) {
130
112
// let _: AssertParamIsClone<FieldTy>;
131
- assert_ty_bounds ( cx, stmts, field. ty . clone ( ) , field. span , "AssertParamIsClone" ) ;
113
+ super :: assert_ty_bounds (
114
+ cx,
115
+ stmts,
116
+ field. ty . clone ( ) ,
117
+ field. span ,
118
+ & [ sym:: clone, sym:: AssertParamIsClone ] ,
119
+ ) ;
132
120
}
133
121
}
134
122
135
123
let mut stmts = Vec :: new ( ) ;
136
124
if is_union {
137
125
// let _: AssertParamIsCopy<Self>;
138
126
let self_ty = cx. ty_path ( cx. path_ident ( trait_span, Ident :: with_dummy_span ( kw:: SelfUpper ) ) ) ;
139
- assert_ty_bounds ( cx, & mut stmts, self_ty, trait_span, "AssertParamIsCopy" ) ;
127
+ super :: assert_ty_bounds (
128
+ cx,
129
+ & mut stmts,
130
+ self_ty,
131
+ trait_span,
132
+ & [ sym:: clone, sym:: AssertParamIsCopy ] ,
133
+ ) ;
140
134
} else {
141
135
match * substr. fields {
142
136
StaticStruct ( vdata, ..) => {
0 commit comments