Skip to content

Commit 5c0c317

Browse files
committed
use closure body span to exclude contracts
1 parent 2a91e96 commit 5c0c317

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

compiler/rustc_lint/src/unused.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -914,12 +914,8 @@ trait UnusedDelimLint {
914914
Closure(ref closure)
915915
if matches!(closure.fn_decl.output, FnRetTy::Default(_))
916916
// skip `#[core::contracts::requires(...)]` and `#[core::contracts::ensures(...)]` which generate closure
917-
&& !cx
918-
.sess()
919-
.source_map()
920-
.span_to_snippet(closure.fn_decl_span)
921-
.unwrap_or_default()
922-
.contains("core::contracts") =>
917+
// with span that is same as the closure body span
918+
&& e.span != closure.body.span =>
923919
{
924920
(&[closure.body.clone()][..], UnusedDelimsCtx::ClosureBody)
925921
}

0 commit comments

Comments
 (0)