Reduce comment verbosity
This commit is contained in:
@@ -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) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user