File tree 3 files changed +9
-8
lines changed
3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -518,8 +518,8 @@ lint_non_binding_let_multi_suggestion =
518
518
lint_non_binding_let_on_drop_type =
519
519
non-binding let on a type that implements `Drop`
520
520
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
523
523
524
524
lint_non_binding_let_suggestion =
525
525
consider binding to an unused variable to avoid immediately dropping the value
Original file line number Diff line number Diff line change @@ -104,7 +104,6 @@ const SYNC_GUARD_SYMBOLS: [Symbol; 3] = [
104
104
] ;
105
105
106
106
impl < ' tcx > LateLintPass < ' tcx > for LetUnderscore {
107
- #[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
108
107
fn check_local ( & mut self , cx : & LateContext < ' _ > , local : & hir:: LetStmt < ' _ > ) {
109
108
if matches ! ( local. source, rustc_hir:: LocalSource :: AsyncFn ) {
110
109
return ;
@@ -156,12 +155,12 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
156
155
is_assign_desugar : matches ! ( local. source, rustc_hir:: LocalSource :: AssignDesugar ( _) ) ,
157
156
} ;
158
157
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 } ,
163
163
) ;
164
- cx. emit_span_lint ( LET_UNDERSCORE_LOCK , span, NonBindingLet :: SyncLock { sub } ) ;
165
164
// Only emit let_underscore_drop for top-level `_` patterns.
166
165
} else if can_use_init. is_some ( ) {
167
166
cx. emit_span_lint ( LET_UNDERSCORE_DROP , local. span , NonBindingLet :: DropType { sub } ) ;
Original file line number Diff line number Diff line change @@ -957,6 +957,8 @@ pub struct BadOptAccessDiag<'a> {
957
957
pub enum NonBindingLet {
958
958
#[ diag( lint_non_binding_let_on_sync_lock) ]
959
959
SyncLock {
960
+ #[ label]
961
+ pat : Span ,
960
962
#[ subdiagnostic]
961
963
sub : NonBindingLetSub ,
962
964
} ,
You can’t perform that action at this time.
0 commit comments