Skip to content

Commit bc105d3

Browse files
authored
Unrolled build for rust-lang#128369
Rollup merge of rust-lang#128369 - GrigorenkoPV:let-underscore-translatable, r=davidtwco rustc_lint: make `let-underscore-lock` translatable
2 parents 60d1465 + c9346a1 commit bc105d3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

compiler/rustc_lint/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ lint_non_binding_let_multi_suggestion =
518518
lint_non_binding_let_on_drop_type =
519519
non-binding let on a type that implements `Drop`
520520
521-
lint_non_binding_let_on_sync_lock =
522-
non-binding let on a synchronization lock
521+
lint_non_binding_let_on_sync_lock = non-binding let on a synchronization lock
522+
.label = this lock is not assigned to a binding and is immediately dropped
523523
524524
lint_non_binding_let_suggestion =
525525
consider binding to an unused variable to avoid immediately dropping the value

compiler/rustc_lint/src/let_underscore.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ const SYNC_GUARD_SYMBOLS: [Symbol; 3] = [
104104
];
105105

106106
impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
107-
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
108107
fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::LetStmt<'_>) {
109108
if matches!(local.source, rustc_hir::LocalSource::AsyncFn) {
110109
return;
@@ -156,12 +155,12 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
156155
is_assign_desugar: matches!(local.source, rustc_hir::LocalSource::AssignDesugar(_)),
157156
};
158157
if is_sync_lock {
159-
let mut span = MultiSpan::from_span(pat.span);
160-
span.push_span_label(
161-
pat.span,
162-
"this lock is not assigned to a binding and is immediately dropped".to_string(),
158+
let span = MultiSpan::from_span(pat.span);
159+
cx.emit_span_lint(
160+
LET_UNDERSCORE_LOCK,
161+
span,
162+
NonBindingLet::SyncLock { sub, pat: pat.span },
163163
);
164-
cx.emit_span_lint(LET_UNDERSCORE_LOCK, span, NonBindingLet::SyncLock { sub });
165164
// Only emit let_underscore_drop for top-level `_` patterns.
166165
} else if can_use_init.is_some() {
167166
cx.emit_span_lint(LET_UNDERSCORE_DROP, local.span, NonBindingLet::DropType { sub });

compiler/rustc_lint/src/lints.rs

+2
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,8 @@ pub struct BadOptAccessDiag<'a> {
957957
pub enum NonBindingLet {
958958
#[diag(lint_non_binding_let_on_sync_lock)]
959959
SyncLock {
960+
#[label]
961+
pat: Span,
960962
#[subdiagnostic]
961963
sub: NonBindingLetSub,
962964
},

0 commit comments

Comments
 (0)