Skip to content

Commit 6cf47a0

Browse files
committed
Reduce size of lint message
1 parent 627e961 commit 6cf47a0

File tree

2 files changed

+170
-245
lines changed

2 files changed

+170
-245
lines changed

clippy_lints/src/matches/significant_drop_in_scrutinee.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_hir::{Expr, ExprKind, MatchSource};
88
use rustc_lint::{LateContext, LintContext};
99
use rustc_middle::ty::subst::GenericArgKind;
1010
use rustc_middle::ty::{Ty, TypeAndMut};
11-
use rustc_span::Span;
11+
use rustc_span::{Span};
1212

1313
use super::SIGNIFICANT_DROP_IN_SCRUTINEE;
1414

@@ -22,13 +22,11 @@ pub(super) fn check<'tcx>(
2222
for found in suggestions {
2323
span_lint_and_then(cx, SIGNIFICANT_DROP_IN_SCRUTINEE, found.found_span, message, |diag| {
2424
set_diagnostic(diag, cx, expr, found);
25+
let s = Span::new(expr.span.hi(), expr.span.hi(), expr.span.ctxt(), None);
2526
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+
);
3230
});
3331
}
3432
}
@@ -87,9 +85,9 @@ fn has_significant_drop_in_scrutinee<'tcx, 'a>(
8785
let mut helper = SigDropHelper::new(cx);
8886
helper.find_sig_drop(scrutinee).map(|drops| {
8987
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"
9189
} 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"
9391
};
9492
(drops, message)
9593
})

0 commit comments

Comments
 (0)