@@ -3,9 +3,9 @@ use crate::deriving::generic::*;
33use crate :: deriving:: path_std;
44
55use 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 } ;
77use rustc_expand:: base:: { Annotatable , ExtCtxt } ;
8- use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
8+ use rustc_span:: symbol:: { kw, sym, Ident } ;
99use rustc_span:: Span ;
1010
1111pub fn expand_deriving_clone (
@@ -107,36 +107,30 @@ fn cs_clone_shallow(
107107 substr : & Substructure < ' _ > ,
108108 is_union : bool ,
109109) -> 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- }
128110 fn process_variant ( cx : & mut ExtCtxt < ' _ > , stmts : & mut Vec < ast:: Stmt > , variant : & VariantData ) {
129111 for field in variant. fields ( ) {
130112 // 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+ ) ;
132120 }
133121 }
134122
135123 let mut stmts = Vec :: new ( ) ;
136124 if is_union {
137125 // let _: AssertParamIsCopy<Self>;
138126 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+ ) ;
140134 } else {
141135 match * substr. fields {
142136 StaticStruct ( vdata, ..) => {
0 commit comments