@@ -10,8 +10,9 @@ use rustc_ast::attr;
1010use rustc_ast:: ptr:: P ;
1111use rustc_ast:: token:: { self , BinOpToken , CommentKind , DelimToken , Nonterminal , Token , TokenKind } ;
1212use rustc_ast:: tokenstream:: { TokenStream , TokenTree } ;
13+ use rustc_ast:: util:: classify;
14+ use rustc_ast:: util:: comments:: { gather_comments, Comment , CommentStyle } ;
1315use rustc_ast:: util:: parser:: { self , AssocOp , Fixity } ;
14- use rustc_ast:: util:: { classify, comments} ;
1516use rustc_span:: edition:: Edition ;
1617use rustc_span:: source_map:: { SourceMap , Spanned } ;
1718use rustc_span:: symbol:: { kw, sym, Ident , IdentPrinter , Symbol } ;
@@ -50,27 +51,27 @@ impl PpAnn for NoAnn {}
5051
5152pub struct Comments < ' a > {
5253 sm : & ' a SourceMap ,
53- comments : Vec < comments :: Comment > ,
54+ comments : Vec < Comment > ,
5455 current : usize ,
5556}
5657
5758impl < ' a > Comments < ' a > {
5859 pub fn new ( sm : & ' a SourceMap , filename : FileName , input : String ) -> Comments < ' a > {
59- let comments = comments :: gather_comments ( sm, filename, input) ;
60+ let comments = gather_comments ( sm, filename, input) ;
6061 Comments { sm, comments, current : 0 }
6162 }
6263
63- pub fn next ( & self ) -> Option < comments :: Comment > {
64+ pub fn next ( & self ) -> Option < Comment > {
6465 self . comments . get ( self . current ) . cloned ( )
6566 }
6667
6768 pub fn trailing_comment (
6869 & mut self ,
6970 span : rustc_span:: Span ,
7071 next_pos : Option < BytePos > ,
71- ) -> Option < comments :: Comment > {
72+ ) -> Option < Comment > {
7273 if let Some ( cmnt) = self . next ( ) {
73- if cmnt. style != comments :: Trailing {
74+ if cmnt. style != CommentStyle :: Trailing {
7475 return None ;
7576 }
7677 let span_line = self . sm . lookup_char_pos ( span. hi ( ) ) ;
@@ -462,9 +463,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
462463 }
463464 }
464465
465- fn print_comment ( & mut self , cmnt : & comments :: Comment ) {
466+ fn print_comment ( & mut self , cmnt : & Comment ) {
466467 match cmnt. style {
467- comments :: Mixed => {
468+ CommentStyle :: Mixed => {
468469 if !self . is_beginning_of_line ( ) {
469470 self . zerobreak ( ) ;
470471 }
@@ -483,7 +484,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
483484 }
484485 self . zerobreak ( )
485486 }
486- comments :: Isolated => {
487+ CommentStyle :: Isolated => {
487488 self . hardbreak_if_not_bol ( ) ;
488489 for line in & cmnt. lines {
489490 // Don't print empty lines because they will end up as trailing
@@ -494,7 +495,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
494495 self . hardbreak ( ) ;
495496 }
496497 }
497- comments :: Trailing => {
498+ CommentStyle :: Trailing => {
498499 if !self . is_beginning_of_line ( ) {
499500 self . word ( " " ) ;
500501 }
@@ -512,7 +513,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
512513 self . end ( ) ;
513514 }
514515 }
515- comments :: BlankLine => {
516+ CommentStyle :: BlankLine => {
516517 // We need to do at least one, possibly two hardbreaks.
517518 let twice = match self . last_token ( ) {
518519 pp:: Token :: String ( s) => ";" == s,
@@ -531,7 +532,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
531532 }
532533 }
533534
534- fn next_comment ( & mut self ) -> Option < comments :: Comment > {
535+ fn next_comment ( & mut self ) -> Option < Comment > {
535536 self . comments ( ) . as_mut ( ) . and_then ( |c| c. next ( ) )
536537 }
537538
0 commit comments