about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-07-21 16:23:13 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-07-21 16:23:13 +0000
commitdafc9f9b534c8d1a50ba87f776eb1d6dfb1a7c94 (patch)
tree9bd41bdff70172a5fc35ac1184769ec70f964183
parent8df93e6966e71da8a249a0022680b83eff105f42 (diff)
downloadrust-dafc9f9b534c8d1a50ba87f776eb1d6dfb1a7c94.tar.gz
rust-dafc9f9b534c8d1a50ba87f776eb1d6dfb1a7c94.zip
Reduce comment verbosity
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/move_errors.rs38
1 files changed, 5 insertions, 33 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
index 40361906e04..67dce7615c0 100644
--- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs
@@ -629,43 +629,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
                     use_span = match self.infcx.tcx.parent_hir_node(upvar_hir_id) {
                         hir::Node::Param(param) => {
                             // Instead of pointing at the path where we access the value within a
-                            // closure, we point at the type on the parameter from the definition
-                            // of the outer function:
-                            //
-                            // error[E0507]: cannot move out of `foo`, a captured
-                            //               variable in an `Fn` closure
-                            //   --> file.rs:14:25
-                            //    |
-                            // 13 | fn do_stuff(foo: Option<Foo>) {
-                            //    |             ---  ----------- move occurs because `foo` has type
-                            //    |             |                `Option<Foo>`, which does not
-                            //    |             |                implement the `Copy` trait
-                            //    |             captured outer variable
-                            // 14 |     require_fn_trait(|| async {
-                            //    |                      -- ^^^^^ `foo` is moved here
-                            //    |                      |
-                            //    |                      captured by this `Fn` closure
-                            // 15 |         if foo.map_or(false, |f| f.foo()) {
-                            //    |            --- variable moved due to use in coroutine
+                            // closure, we point at the type of the outer `fn` argument.
                             param.ty_span
                         }
                         hir::Node::LetStmt(stmt) => match (stmt.ty, stmt.init) {
-                            // 13 | fn do_stuff(foo: Option<Foo>) {
-                            // 14 |    let foo: Option<Foo> = foo;
-                            //    |        ---  ----------- move occurs because `foo` has type
-                            //    |        |                `Option<Foo>`, which does not implement
-                            //    |        |                the `Copy` trait
-                            //    |        captured outer variable
+                            // We point at the type of the outer let-binding.
                             (Some(ty), _) => ty.span,
-                            // 13 | fn do_stuff(bar: Option<Foo>) {
-                            // 14 |    let foo = bar;
-                            //    |        ---   --- move occurs because `foo` has type
-                            //    |        |         `Option<Foo>`, which does not implement the
-                            //    |        |         `Copy` trait
-                            //    |        captured outer variable
-                            //
-                            // We don't want the case where the initializer is something that spans
-                            // multiple lines, like a closure, as the ASCII art gets messy.
+                            // We point at the initializer of the outer let-binding, but only if it
+                            // isn't something that spans multiple lines, like a closure, as the
+                            // ASCII art gets messy.
                             (None, Some(init))
                                 if !self.infcx.tcx.sess.source_map().is_multiline(init.span) =>
                             {