@@ -17,11 +17,10 @@ use rustc_errors::{error_code, pluralize, struct_span_err, Applicability};
1717use rustc_parse:: validate_attr;
1818use rustc_session:: lint:: builtin:: PATTERNS_IN_FNS_WITHOUT_BODY ;
1919use rustc_session:: lint:: { BuiltinLintDiagnostics , LintBuffer } ;
20- use rustc_session:: { DiagnosticMessageId , Session } ;
20+ use rustc_session:: Session ;
2121use rustc_span:: source_map:: Spanned ;
2222use rustc_span:: symbol:: { kw, sym, Ident } ;
2323use rustc_span:: Span ;
24- use std:: convert:: TryInto ;
2524use std:: mem;
2625use std:: ops:: DerefMut ;
2726
@@ -1177,6 +1176,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11771176 let kind = FnKind :: Fn ( FnCtxt :: Free , item. ident , sig, & item. vis , body. as_deref ( ) ) ;
11781177 self . visit_fn ( kind, item. span , item. id ) ;
11791178 walk_list ! ( self , visit_attribute, & item. attrs) ;
1179+ return ; // Avoid visiting again.
11801180 }
11811181 ItemKind :: ForeignMod ( ForeignMod { unsafety, .. } ) => {
11821182 let old_item = mem:: replace ( & mut self . extern_mod , Some ( item) ) ;
@@ -1440,19 +1440,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14401440 match bound {
14411441 GenericBound :: Trait ( _, TraitBoundModifier :: MaybeConst ) => {
14421442 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 ( ) ;
14561447 }
14571448 }
14581449
0 commit comments