File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 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 =
518518lint_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
524524lint_non_binding_let_suggestion =
525525 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] = [
104104] ;
105105
106106impl < ' 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 } ) ;
Original file line number Diff line number Diff line change @@ -957,6 +957,8 @@ pub struct BadOptAccessDiag<'a> {
957957pub enum NonBindingLet {
958958 #[ diag( lint_non_binding_let_on_sync_lock) ]
959959 SyncLock {
960+ #[ label]
961+ pat : Span ,
960962 #[ subdiagnostic]
961963 sub : NonBindingLetSub ,
962964 } ,
You can’t perform that action at this time.
0 commit comments