@@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind, MatchSource};
8
8
use rustc_lint:: { LateContext , LintContext } ;
9
9
use rustc_middle:: ty:: subst:: GenericArgKind ;
10
10
use rustc_middle:: ty:: { Ty , TypeAndMut } ;
11
- use rustc_span:: Span ;
11
+ use rustc_span:: { Span } ;
12
12
13
13
use super :: SIGNIFICANT_DROP_IN_SCRUTINEE ;
14
14
@@ -22,13 +22,11 @@ pub(super) fn check<'tcx>(
22
22
for found in suggestions {
23
23
span_lint_and_then ( cx, SIGNIFICANT_DROP_IN_SCRUTINEE , found. found_span , message, |diag| {
24
24
set_diagnostic ( diag, cx, expr, found) ;
25
+ let s = Span :: new ( expr. span . hi ( ) , expr. span . hi ( ) , expr. span . ctxt ( ) , None ) ;
25
26
diag. span_label (
26
- expr. span ,
27
- "temporaries in a match scrutinee are not dropped until the end of the \
28
- match, so side effects from dropping such temporaries are delayed. \
29
- Deadlocks can occur if a lock guard is created in the scrutinee and a new \
30
- lock guard for the same mutex is created in a match arm. \
31
- For more information, see https://rust-lang.github.io/rust-clippy/master/index.html#significant_drop_in_scrutinee") ;
27
+ s,
28
+ "temporary lives until here. If mutex is locked within block, deadlocks can occur." ,
29
+ ) ;
32
30
} ) ;
33
31
}
34
32
}
@@ -87,9 +85,9 @@ fn has_significant_drop_in_scrutinee<'tcx, 'a>(
87
85
let mut helper = SigDropHelper :: new ( cx) ;
88
86
helper. find_sig_drop ( scrutinee) . map ( |drops| {
89
87
let message = if source == MatchSource :: Normal {
90
- "temporary with significant drop in match scrutinee"
88
+ "temporary with drop impl with side effects in match scrutinee lives to end of block "
91
89
} else {
92
- "temporary with significant drop in for loop"
90
+ "temporary with drop impl with side effects in for loop condition lives to end of block "
93
91
} ;
94
92
( drops, message)
95
93
} )
0 commit comments