Skip to content

Commit 64f1f52

Browse files
committed
use closure body span to exclude contracts
1 parent 9ec13a6 commit 64f1f52

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
@@ -938,12 +938,8 @@ trait UnusedDelimLint {
938938
Closure(ref closure)
939939
if matches!(closure.fn_decl.output, FnRetTy::Default(_))
940940
// skip `#[core::contracts::requires(...)]` and `#[core::contracts::ensures(...)]` which generate closure
941-
&& !cx
942-
.sess()
943-
.source_map()
944-
.span_to_snippet(closure.fn_decl_span)
945-
.unwrap_or_default()
946-
.contains("core::contracts") =>
941+
// with span that is same as the closure body span
942+
&& e.span != closure.body.span =>
947943
{
948944
(&[closure.body.clone()][..], UnusedDelimsCtx::ClosureBody)
949945
}

0 commit comments

Comments
 (0)