1- use crate :: base:: ExtCtxt ;
21use crate :: expand:: { AstFragment , AstFragmentKind } ;
32
43use rustc_ast as ast;
@@ -175,17 +174,12 @@ pub fn placeholder(
175174 }
176175}
177176
178- pub struct PlaceholderExpander < ' a , ' b > {
177+ #[ derive( Default ) ]
178+ pub struct PlaceholderExpander {
179179 expanded_fragments : FxHashMap < ast:: NodeId , AstFragment > ,
180- cx : & ' a mut ExtCtxt < ' b > ,
181- monotonic : bool ,
182180}
183181
184- impl < ' a , ' b > PlaceholderExpander < ' a , ' b > {
185- pub fn new ( cx : & ' a mut ExtCtxt < ' b > , monotonic : bool ) -> Self {
186- PlaceholderExpander { cx, expanded_fragments : FxHashMap :: default ( ) , monotonic }
187- }
188-
182+ impl PlaceholderExpander {
189183 pub fn add ( & mut self , id : ast:: NodeId , mut fragment : AstFragment ) {
190184 fragment. mut_visit_with ( self ) ;
191185 self . expanded_fragments . insert ( id, fragment) ;
@@ -196,7 +190,7 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> {
196190 }
197191}
198192
199- impl < ' a , ' b > MutVisitor for PlaceholderExpander < ' a , ' b > {
193+ impl MutVisitor for PlaceholderExpander {
200194 fn flat_map_arm ( & mut self , arm : ast:: Arm ) -> SmallVec < [ ast:: Arm ; 1 ] > {
201195 if arm. is_placeholder {
202196 self . remove ( arm. id ) . make_arms ( )
@@ -360,15 +354,4 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
360354 _ => noop_visit_ty ( ty, self ) ,
361355 }
362356 }
363-
364- fn visit_block ( & mut self , block : & mut P < ast:: Block > ) {
365- noop_visit_block ( block, self ) ;
366-
367- for stmt in block. stmts . iter_mut ( ) {
368- if self . monotonic {
369- assert_eq ! ( stmt. id, ast:: DUMMY_NODE_ID ) ;
370- stmt. id = self . cx . resolver . next_node_id ( ) ;
371- }
372- }
373- }
374357}
0 commit comments