@@ -82,6 +82,8 @@ struct AstValidator<'a> {
8282 /// Used to ban explicit safety on foreign items when the extern block is not marked as unsafe.
8383 extern_mod_safety : Option < Safety > ,
8484
85+ lint_node_id : NodeId ,
86+
8587 lint_buffer : & ' a mut LintBuffer ,
8688}
8789
@@ -839,6 +841,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
839841 self . has_proc_macro_decls = true ;
840842 }
841843
844+ let previous_lint_node_id = mem:: replace ( & mut self . lint_node_id , item. id ) ;
845+
842846 if let Some ( ident) = item. kind . ident ( )
843847 && attr:: contains_name ( & item. attrs , sym:: no_mangle)
844848 {
@@ -1128,6 +1132,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11281132 }
11291133 _ => visit:: walk_item ( self , item) ,
11301134 }
1135+
1136+ self . lint_node_id = previous_lint_node_id;
11311137 }
11321138
11331139 fn visit_foreign_item ( & mut self , fi : & ' a ForeignItem ) {
@@ -1694,6 +1700,7 @@ pub fn check_crate(
16941700 outer_impl_trait_span : None ,
16951701 disallow_tilde_const : Some ( TildeConstReason :: Item ) ,
16961702 extern_mod_safety : None ,
1703+ lint_node_id : CRATE_NODE_ID ,
16971704 lint_buffer : lints,
16981705 } ;
16991706 visit:: walk_crate ( & mut validator, krate) ;
0 commit comments