diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-03-12 17:21:15 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-03-13 23:05:17 +0000 |
| commit | 0953608debfa9d3df955f976e7bc857584ba1ed0 (patch) | |
| tree | 9110f04cb2be71fc4e9139449ee314adf86661dd /compiler/rustc_borrowck/src/diagnostics | |
| parent | b367c25367117a4ada5c9a1c807b74f0efcf6d51 (diff) | |
| download | rust-0953608debfa9d3df955f976e7bc857584ba1ed0.tar.gz rust-0953608debfa9d3df955f976e7bc857584ba1ed0.zip | |
Account for UnOps in borrowck message
Diffstat (limited to 'compiler/rustc_borrowck/src/diagnostics')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mod.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 4ebbe592628..914f68a38b4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1050,7 +1050,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { ); err.subdiagnostic(self.dcx(), CaptureReasonNote::FnOnceMoveInCall { var_span }); } - CallKind::Operator { self_arg, .. } => { + CallKind::Operator { self_arg, trait_id, .. } => { let self_arg = self_arg.unwrap(); err.subdiagnostic( self.dcx(), @@ -1062,9 +1062,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { }, ); if self.fn_self_span_reported.insert(fn_span) { + let lang = self.infcx.tcx.lang_items(); err.subdiagnostic( self.dcx(), - CaptureReasonNote::LhsMoveByOperator { span: self_arg.span }, + if [lang.not_trait(), lang.deref_trait(), lang.neg_trait()] + .contains(&Some(trait_id)) + { + CaptureReasonNote::UnOpMoveByOperator { span: self_arg.span } + } else { + CaptureReasonNote::LhsMoveByOperator { span: self_arg.span } + }, ); } } |
