@@ -5,7 +5,7 @@ use itertools::Itertools;
5
5
use rustc_hir:: def_id:: LocalDefId ;
6
6
use rustc_hir:: intravisit:: { Visitor , walk_block, walk_expr, walk_stmt} ;
7
7
use rustc_hir:: { BlockCheckMode , Expr , ExprKind , HirId , Stmt , UnsafeSource } ;
8
- use rustc_lint:: { LateContext , LateLintPass } ;
8
+ use rustc_lint:: { LateContext , LateLintPass , Level , LintContext } ;
9
9
use rustc_session:: impl_lint_pass;
10
10
use rustc_span:: { Span , SyntaxContext , sym} ;
11
11
use std:: collections:: BTreeMap ;
@@ -249,6 +249,15 @@ impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
249
249
} )
250
250
. flatten ( )
251
251
. copied ( )
252
+ . inspect ( |& unsafe_block| {
253
+ if let Level :: Expect ( id) = cx. tcx . lint_level_at_node ( MACRO_METAVARS_IN_UNSAFE , unsafe_block) . 0 {
254
+ // Since we're going to deduplicate expanded unsafe blocks by its enclosing macro definition soon,
255
+ // which would lead to unfulfilled `#[expect()]`s in all other unsafe blocks that are filtered out
256
+ // except for the one we emit the warning at, we must manually fulfill the lint
257
+ // for all unsafe blocks here.
258
+ cx. fulfill_expectation ( id) ;
259
+ }
260
+ } )
252
261
. map ( |id| {
253
262
// Remove the syntax context to hide "in this macro invocation" in the diagnostic.
254
263
// The invocation doesn't matter. Also we want to dedupe by the unsafe block and not by anything
0 commit comments