@@ -38,16 +38,18 @@ impl<'a> AstValidator<'a> {
3838 self . err_handler ( ) . span_err ( span, & format ! ( "invalid label name `{}`" , label. name) ) ;
3939 }
4040 if label. name . as_str ( ) == "'_" {
41- self . session . add_lint (
42- lint :: builtin :: LIFETIME_UNDERSCORE , id , span ,
43- format ! ( "invalid label name `{}`" , label . name )
44- ) ;
41+ self . session . add_lint ( lint :: builtin :: LIFETIME_UNDERSCORE ,
42+ id ,
43+ span ,
44+ format ! ( "invalid label name `{}`" , label . name ) ) ;
4545 }
4646 }
4747
4848 fn invalid_visibility ( & self , vis : & Visibility , span : Span , note : Option < & str > ) {
4949 if vis != & Visibility :: Inherited {
50- let mut err = struct_span_err ! ( self . session, span, E0449 ,
50+ let mut err = struct_span_err ! ( self . session,
51+ span,
52+ E0449 ,
5153 "unnecessary visibility qualifier" ) ;
5254 if let Some ( note) = note {
5355 err. span_note ( span, note) ;
@@ -71,20 +73,23 @@ impl<'a> AstValidator<'a> {
7173impl < ' a > Visitor for AstValidator < ' a > {
7274 fn visit_lifetime ( & mut self , lt : & Lifetime ) {
7375 if lt. name . as_str ( ) == "'_" {
74- self . session . add_lint (
75- lint :: builtin :: LIFETIME_UNDERSCORE , lt . id , lt. span ,
76- format ! ( "invalid lifetime name `{}`" , lt. name )
77- ) ;
76+ self . session . add_lint ( lint :: builtin :: LIFETIME_UNDERSCORE ,
77+ lt. id ,
78+ lt. span ,
79+ format ! ( "invalid lifetime name `{}`" , lt . name ) ) ;
7880 }
7981
8082 visit:: walk_lifetime ( self , lt)
8183 }
8284
8385 fn visit_expr ( & mut self , expr : & Expr ) {
8486 match expr. node {
85- ExprKind :: While ( _, _, Some ( ident) ) | ExprKind :: Loop ( _, Some ( ident) ) |
86- ExprKind :: WhileLet ( _, _, _, Some ( ident) ) | ExprKind :: ForLoop ( _, _, _, Some ( ident) ) |
87- ExprKind :: Break ( Some ( ident) ) | ExprKind :: Continue ( Some ( ident) ) => {
87+ ExprKind :: While ( _, _, Some ( ident) ) |
88+ ExprKind :: Loop ( _, Some ( ident) ) |
89+ ExprKind :: WhileLet ( _, _, _, Some ( ident) ) |
90+ ExprKind :: ForLoop ( _, _, _, Some ( ident) ) |
91+ ExprKind :: Break ( Some ( ident) ) |
92+ ExprKind :: Continue ( Some ( ident) ) => {
8893 self . check_label ( ident. node , ident. span , expr. id ) ;
8994 }
9095 _ => { }
@@ -97,10 +102,13 @@ impl<'a> Visitor for AstValidator<'a> {
97102 match ty. node {
98103 TyKind :: BareFn ( ref bfty) => {
99104 self . check_decl_no_pat ( & bfty. decl , |span, _| {
100- let mut err = struct_span_err ! ( self . session, span, E0561 ,
101- "patterns aren't allowed in function pointer types" ) ;
102- err. span_note ( span, "this is a recent error, see \
103- issue #35203 for more details") ;
105+ let mut err = struct_span_err ! ( self . session,
106+ span,
107+ E0561 ,
108+ "patterns aren't allowed in function pointer \
109+ types") ;
110+ err. span_note ( span,
111+ "this is a recent error, see issue #35203 for more details" ) ;
104112 err. emit ( ) ;
105113 } ) ;
106114 }
@@ -114,10 +122,10 @@ impl<'a> Visitor for AstValidator<'a> {
114122 if path. global && path. segments . len ( ) > 0 {
115123 let ident = path. segments [ 0 ] . identifier ;
116124 if token:: Ident ( ident) . is_path_segment_keyword ( ) {
117- self . session . add_lint (
118- lint :: builtin :: SUPER_OR_SELF_IN_GLOBAL_PATH , id , path . span ,
119- format ! ( "global paths cannot start with `{}`" , ident )
120- ) ;
125+ self . session . add_lint ( lint :: builtin :: SUPER_OR_SELF_IN_GLOBAL_PATH ,
126+ id ,
127+ path . span ,
128+ format ! ( "global paths cannot start with `{}`" , ident ) ) ;
121129 }
122130 }
123131
@@ -129,8 +137,8 @@ impl<'a> Visitor for AstValidator<'a> {
129137 ItemKind :: Use ( ref view_path) => {
130138 let path = view_path. node . path ( ) ;
131139 if !path. segments . iter ( ) . all ( |segment| segment. parameters . is_empty ( ) ) {
132- self . err_handler ( ) . span_err ( path . span , "type or lifetime parameters \
133- in import path") ;
140+ self . err_handler ( )
141+ . span_err ( path . span , "type or lifetime parameters in import path") ;
134142 }
135143 }
136144 ItemKind :: Impl ( _, _, _, Some ( ..) , _, ref impl_items) => {
@@ -140,15 +148,18 @@ impl<'a> Visitor for AstValidator<'a> {
140148 }
141149 }
142150 ItemKind :: Impl ( _, _, _, None , _, _) => {
143- self . invalid_visibility ( & item. vis , item. span , Some ( "place qualifiers on individual \
144- impl items instead") ) ;
151+ self . invalid_visibility ( & item. vis ,
152+ item. span ,
153+ Some ( "place qualifiers on individual impl items instead" ) ) ;
145154 }
146155 ItemKind :: DefaultImpl ( ..) => {
147156 self . invalid_visibility ( & item. vis , item. span , None ) ;
148157 }
149158 ItemKind :: ForeignMod ( ..) => {
150- self . invalid_visibility ( & item. vis , item. span , Some ( "place qualifiers on individual \
151- foreign items instead") ) ;
159+ self . invalid_visibility ( & item. vis ,
160+ item. span ,
161+ Some ( "place qualifiers on individual foreign items \
162+ instead") ) ;
152163 }
153164 ItemKind :: Enum ( ref def, _) => {
154165 for variant in & def. variants {
@@ -167,11 +178,14 @@ impl<'a> Visitor for AstValidator<'a> {
167178 match fi. node {
168179 ForeignItemKind :: Fn ( ref decl, _) => {
169180 self . check_decl_no_pat ( decl, |span, is_recent| {
170- let mut err = struct_span_err ! ( self . session, span, E0130 ,
171- "patterns aren't allowed in foreign function declarations" ) ;
181+ let mut err = struct_span_err ! ( self . session,
182+ span,
183+ E0130 ,
184+ "patterns aren't allowed in foreign function \
185+ declarations") ;
172186 if is_recent {
173- err. span_note ( span, "this is a recent error, see \
174- issue #35203 for more details") ;
187+ err. span_note ( span,
188+ "this is a recent error, see issue #35203 for more details") ;
175189 }
176190 err. emit ( ) ;
177191 } ) ;
@@ -182,16 +196,21 @@ impl<'a> Visitor for AstValidator<'a> {
182196 visit:: walk_foreign_item ( self , fi)
183197 }
184198
185- fn visit_variant_data ( & mut self , vdata : & VariantData , _: Ident ,
186- _: & Generics , _: NodeId , span : Span ) {
199+ fn visit_variant_data ( & mut self ,
200+ vdata : & VariantData ,
201+ _: Ident ,
202+ _: & Generics ,
203+ _: NodeId ,
204+ span : Span ) {
187205 if vdata. fields ( ) . is_empty ( ) {
188206 if vdata. is_tuple ( ) {
189- self . err_handler ( ) . struct_span_err ( span, "empty tuple structs and enum variants \
190- are not allowed, use unit structs and \
191- enum variants instead")
192- . span_help ( span, "remove trailing `()` to make a unit \
193- struct or unit enum variant")
194- . emit ( ) ;
207+ self . err_handler ( )
208+ . struct_span_err ( span,
209+ "empty tuple structs and enum variants are not allowed, use \
210+ unit structs and enum variants instead")
211+ . span_help ( span,
212+ "remove trailing `()` to make a unit struct or unit enum variant" )
213+ . emit ( ) ;
195214 }
196215 }
197216
@@ -200,10 +219,10 @@ impl<'a> Visitor for AstValidator<'a> {
200219
201220 fn visit_vis ( & mut self , vis : & Visibility ) {
202221 match * vis {
203- Visibility :: Restricted { ref path, ..} => {
222+ Visibility :: Restricted { ref path, .. } => {
204223 if !path. segments . iter ( ) . all ( |segment| segment. parameters . is_empty ( ) ) {
205- self . err_handler ( ) . span_err ( path . span , "type or lifetime parameters \
206- in visibility path") ;
224+ self . err_handler ( )
225+ . span_err ( path . span , "type or lifetime parameters in visibility path") ;
207226 }
208227 }
209228 _ => { }
0 commit comments