@@ -17,11 +17,10 @@ use rustc_errors::{error_code, pluralize, struct_span_err, Applicability};
17
17
use rustc_parse:: validate_attr;
18
18
use rustc_session:: lint:: builtin:: PATTERNS_IN_FNS_WITHOUT_BODY ;
19
19
use rustc_session:: lint:: { BuiltinLintDiagnostics , LintBuffer } ;
20
- use rustc_session:: { DiagnosticMessageId , Session } ;
20
+ use rustc_session:: Session ;
21
21
use rustc_span:: source_map:: Spanned ;
22
22
use rustc_span:: symbol:: { kw, sym, Ident } ;
23
23
use rustc_span:: Span ;
24
- use std:: convert:: TryInto ;
25
24
use std:: mem;
26
25
use std:: ops:: DerefMut ;
27
26
@@ -1177,6 +1176,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1177
1176
let kind = FnKind :: Fn ( FnCtxt :: Free , item. ident , sig, & item. vis , body. as_deref ( ) ) ;
1178
1177
self . visit_fn ( kind, item. span , item. id ) ;
1179
1178
walk_list ! ( self , visit_attribute, & item. attrs) ;
1179
+ return ; // Avoid visiting again.
1180
1180
}
1181
1181
ItemKind :: ForeignMod ( ForeignMod { unsafety, .. } ) => {
1182
1182
let old_item = mem:: replace ( & mut self . extern_mod , Some ( item) ) ;
@@ -1440,19 +1440,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
1440
1440
match bound {
1441
1441
GenericBound :: Trait ( _, TraitBoundModifier :: MaybeConst ) => {
1442
1442
if !self . is_tilde_const_allowed {
1443
- let msg = "`~const` is not allowed here" ;
1444
- let id_span_msg = (
1445
- DiagnosticMessageId :: StabilityId ( 67792 . try_into ( ) . ok ( ) ) ,
1446
- Some ( bound. span ( ) ) ,
1447
- msg. to_owned ( ) ,
1448
- ) ;
1449
- let fresh = self . session . one_time_diagnostics . borrow_mut ( ) . insert ( id_span_msg) ;
1450
- if fresh {
1451
- self . err_handler ( )
1452
- . struct_span_err ( bound. span ( ) , msg)
1453
- . note ( "only allowed on bounds on traits' associated types, const fns, const impls and its associated functions" )
1454
- . emit ( ) ;
1455
- }
1443
+ self . err_handler ( )
1444
+ . struct_span_err ( bound. span ( ) , "`~const` is not allowed here" )
1445
+ . note ( "only allowed on bounds on traits' associated types, const fns, const impls and its associated functions" )
1446
+ . emit ( ) ;
1456
1447
}
1457
1448
}
1458
1449
0 commit comments