Skip to content

Commit dafc9f9

Browse files
committed
Reduce comment verbosity
1 parent 8df93e6 commit dafc9f9

File tree

1 file changed

+5
-33
lines changed

1 file changed

+5
-33
lines changed

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -629,43 +629,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
629629
use_span = match self.infcx.tcx.parent_hir_node(upvar_hir_id) {
630630
hir::Node::Param(param) => {
631631
// Instead of pointing at the path where we access the value within a
632-
// closure, we point at the type on the parameter from the definition
633-
// of the outer function:
634-
//
635-
// error[E0507]: cannot move out of `foo`, a captured
636-
// variable in an `Fn` closure
637-
// --> file.rs:14:25
638-
// |
639-
// 13 | fn do_stuff(foo: Option<Foo>) {
640-
// | --- ----------- move occurs because `foo` has type
641-
// | | `Option<Foo>`, which does not
642-
// | | implement the `Copy` trait
643-
// | captured outer variable
644-
// 14 | require_fn_trait(|| async {
645-
// | -- ^^^^^ `foo` is moved here
646-
// | |
647-
// | captured by this `Fn` closure
648-
// 15 | if foo.map_or(false, |f| f.foo()) {
649-
// | --- variable moved due to use in coroutine
632+
// closure, we point at the type of the outer `fn` argument.
650633
param.ty_span
651634
}
652635
hir::Node::LetStmt(stmt) => match (stmt.ty, stmt.init) {
653-
// 13 | fn do_stuff(foo: Option<Foo>) {
654-
// 14 | let foo: Option<Foo> = foo;
655-
// | --- ----------- move occurs because `foo` has type
656-
// | | `Option<Foo>`, which does not implement
657-
// | | the `Copy` trait
658-
// | captured outer variable
636+
// We point at the type of the outer let-binding.
659637
(Some(ty), _) => ty.span,
660-
// 13 | fn do_stuff(bar: Option<Foo>) {
661-
// 14 | let foo = bar;
662-
// | --- --- move occurs because `foo` has type
663-
// | | `Option<Foo>`, which does not implement the
664-
// | | `Copy` trait
665-
// | captured outer variable
666-
//
667-
// We don't want the case where the initializer is something that spans
668-
// multiple lines, like a closure, as the ASCII art gets messy.
638+
// We point at the initializer of the outer let-binding, but only if it
639+
// isn't something that spans multiple lines, like a closure, as the
640+
// ASCII art gets messy.
669641
(None, Some(init))
670642
if !self.infcx.tcx.sess.source_map().is_multiline(init.span) =>
671643
{

0 commit comments

Comments
 (0)