@@ -16,7 +16,7 @@ use crate::items::{
1616} ;
1717use crate :: macros:: { macro_style, rewrite_macro, rewrite_macro_def, MacroPosition } ;
1818use crate :: modules:: Module ;
19- use crate :: rewrite:: { Rewrite , RewriteContext } ;
19+ use crate :: rewrite:: { Memoize , Rewrite , RewriteContext } ;
2020use crate :: shape:: { Indent , Shape } ;
2121use crate :: skip:: { is_skip_attr, SkipContext } ;
2222use crate :: source_map:: { LineRangeUtils , SpanUtils } ;
@@ -71,6 +71,7 @@ impl SnippetProvider {
7171
7272pub ( crate ) struct FmtVisitor < ' a > {
7373 parent_context : Option < & ' a RewriteContext < ' a > > ,
74+ pub ( crate ) memoize : Rc < RefCell < Memoize > > ,
7475 pub ( crate ) parse_sess : & ' a ParseSess ,
7576 pub ( crate ) buffer : String ,
7677 pub ( crate ) last_pos : BytePos ,
@@ -754,6 +755,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
754755 ctx. config ,
755756 ctx. snippet_provider ,
756757 ctx. report . clone ( ) ,
758+ ctx. memoize . clone ( ) ,
757759 ) ;
758760 visitor. skip_context . update ( ctx. skip_context . clone ( ) ) ;
759761 visitor. set_parent_context ( ctx) ;
@@ -765,10 +767,12 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
765767 config : & ' a Config ,
766768 snippet_provider : & ' a SnippetProvider ,
767769 report : FormatReport ,
770+ memoize : Rc < RefCell < Memoize > > ,
768771 ) -> FmtVisitor < ' a > {
769772 FmtVisitor {
770773 parent_context : None ,
771774 parse_sess : parse_session,
775+ memoize,
772776 buffer : String :: with_capacity ( snippet_provider. big_snippet . len ( ) * 2 ) ,
773777 last_pos : BytePos ( 0 ) ,
774778 block_indent : Indent :: empty ( ) ,
@@ -987,6 +991,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
987991 RewriteContext {
988992 parse_sess : self . parse_sess ,
989993 config : self . config ,
994+ memoize : self . memoize . clone ( ) ,
990995 inside_macro : Rc :: new ( Cell :: new ( false ) ) ,
991996 use_block : Cell :: new ( false ) ,
992997 is_if_else_block : Cell :: new ( false ) ,
0 commit comments