@@ -10,8 +10,9 @@ use rustc_ast::attr;
10
10
use rustc_ast:: ptr:: P ;
11
11
use rustc_ast:: token:: { self , BinOpToken , CommentKind , DelimToken , Nonterminal , Token , TokenKind } ;
12
12
use rustc_ast:: tokenstream:: { TokenStream , TokenTree } ;
13
+ use rustc_ast:: util:: classify;
14
+ use rustc_ast:: util:: comments:: { gather_comments, Comment , CommentStyle } ;
13
15
use rustc_ast:: util:: parser:: { self , AssocOp , Fixity } ;
14
- use rustc_ast:: util:: { classify, comments} ;
15
16
use rustc_span:: edition:: Edition ;
16
17
use rustc_span:: source_map:: { SourceMap , Spanned } ;
17
18
use rustc_span:: symbol:: { kw, sym, Ident , IdentPrinter , Symbol } ;
@@ -50,27 +51,27 @@ impl PpAnn for NoAnn {}
50
51
51
52
pub struct Comments < ' a > {
52
53
sm : & ' a SourceMap ,
53
- comments : Vec < comments :: Comment > ,
54
+ comments : Vec < Comment > ,
54
55
current : usize ,
55
56
}
56
57
57
58
impl < ' a > Comments < ' a > {
58
59
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) ;
60
61
Comments { sm, comments, current : 0 }
61
62
}
62
63
63
- pub fn next ( & self ) -> Option < comments :: Comment > {
64
+ pub fn next ( & self ) -> Option < Comment > {
64
65
self . comments . get ( self . current ) . cloned ( )
65
66
}
66
67
67
68
pub fn trailing_comment (
68
69
& mut self ,
69
70
span : rustc_span:: Span ,
70
71
next_pos : Option < BytePos > ,
71
- ) -> Option < comments :: Comment > {
72
+ ) -> Option < Comment > {
72
73
if let Some ( cmnt) = self . next ( ) {
73
- if cmnt. style != comments :: Trailing {
74
+ if cmnt. style != CommentStyle :: Trailing {
74
75
return None ;
75
76
}
76
77
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
462
463
}
463
464
}
464
465
465
- fn print_comment ( & mut self , cmnt : & comments :: Comment ) {
466
+ fn print_comment ( & mut self , cmnt : & Comment ) {
466
467
match cmnt. style {
467
- comments :: Mixed => {
468
+ CommentStyle :: Mixed => {
468
469
if !self . is_beginning_of_line ( ) {
469
470
self . zerobreak ( ) ;
470
471
}
@@ -483,7 +484,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
483
484
}
484
485
self . zerobreak ( )
485
486
}
486
- comments :: Isolated => {
487
+ CommentStyle :: Isolated => {
487
488
self . hardbreak_if_not_bol ( ) ;
488
489
for line in & cmnt. lines {
489
490
// 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
494
495
self . hardbreak ( ) ;
495
496
}
496
497
}
497
- comments :: Trailing => {
498
+ CommentStyle :: Trailing => {
498
499
if !self . is_beginning_of_line ( ) {
499
500
self . word ( " " ) ;
500
501
}
@@ -512,7 +513,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
512
513
self . end ( ) ;
513
514
}
514
515
}
515
- comments :: BlankLine => {
516
+ CommentStyle :: BlankLine => {
516
517
// We need to do at least one, possibly two hardbreaks.
517
518
let twice = match self . last_token ( ) {
518
519
pp:: Token :: String ( s) => ";" == s,
@@ -531,7 +532,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
531
532
}
532
533
}
533
534
534
- fn next_comment ( & mut self ) -> Option < comments :: Comment > {
535
+ fn next_comment ( & mut self ) -> Option < Comment > {
535
536
self . comments ( ) . as_mut ( ) . and_then ( |c| c. next ( ) )
536
537
}
537
538
0 commit comments