@@ -52,22 +52,36 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
52
52
}
53
53
let res = str_to_ident ( & res_str) ;
54
54
55
- let e = P ( ast:: Expr {
56
- id : ast:: DUMMY_NODE_ID ,
57
- node : ast:: ExprKind :: Path ( None ,
58
- ast:: Path {
59
- span : sp,
60
- global : false ,
61
- segments : vec ! (
62
- ast:: PathSegment {
63
- identifier: res,
64
- parameters: ast:: PathParameters :: none( ) ,
65
- }
66
- )
67
- }
68
- ) ,
69
- span : sp,
70
- attrs : None ,
71
- } ) ;
72
- MacEager :: expr ( e)
55
+ struct Result { ident : ast:: Ident , span : Span } ;
56
+
57
+ impl Result {
58
+ fn path ( & self ) -> ast:: Path {
59
+ let segment = ast:: PathSegment {
60
+ identifier : self . ident ,
61
+ parameters : ast:: PathParameters :: none ( )
62
+ } ;
63
+ ast:: Path { span : self . span , global : false , segments : vec ! [ segment] }
64
+ }
65
+ }
66
+
67
+ impl base:: MacResult for Result {
68
+ fn make_expr ( self : Box < Self > ) -> Option < P < ast:: Expr > > {
69
+ Some ( P ( ast:: Expr {
70
+ id : ast:: DUMMY_NODE_ID ,
71
+ node : ast:: ExprKind :: Path ( None , self . path ( ) ) ,
72
+ span : self . span ,
73
+ attrs : None ,
74
+ } ) )
75
+ }
76
+
77
+ fn make_ty ( self : Box < Self > ) -> Option < P < ast:: Ty > > {
78
+ Some ( P ( ast:: Ty {
79
+ id : ast:: DUMMY_NODE_ID ,
80
+ node : ast:: TyKind :: Path ( None , self . path ( ) ) ,
81
+ span : self . span ,
82
+ } ) )
83
+ }
84
+ }
85
+
86
+ Box :: new ( Result { ident : res, span : sp } )
73
87
}
0 commit comments