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) {
|
use_span = match self.infcx.tcx.parent_hir_node(upvar_hir_id) {
|
||||||
hir::Node::Param(param) => {
|
hir::Node::Param(param) => {
|
||||||
// Instead of pointing at the path where we access the value within a
|
// 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
|
// closure, we point at the type of the outer `fn` argument.
|
||||||
// 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
|
|
||||||
param.ty_span
|
param.ty_span
|
||||||
}
|
}
|
||||||
hir::Node::LetStmt(stmt) => match (stmt.ty, stmt.init) {
|
hir::Node::LetStmt(stmt) => match (stmt.ty, stmt.init) {
|
||||||
// 13 | fn do_stuff(foo: Option<Foo>) {
|
// We point at the type of the outer let-binding.
|
||||||
// 14 | let foo: Option<Foo> = foo;
|
|
||||||
// | --- ----------- move occurs because `foo` has type
|
|
||||||
// | | `Option<Foo>`, which does not implement
|
|
||||||
// | | the `Copy` trait
|
|
||||||
// | captured outer variable
|
|
||||||
(Some(ty), _) => ty.span,
|
(Some(ty), _) => ty.span,
|
||||||
// 13 | fn do_stuff(bar: Option<Foo>) {
|
// We point at the initializer of the outer let-binding, but only if it
|
||||||
// 14 | let foo = bar;
|
// isn't something that spans multiple lines, like a closure, as the
|
||||||
// | --- --- move occurs because `foo` has type
|
// ASCII art gets messy.
|
||||||
// | | `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.
|
|
||||||
(None, Some(init))
|
(None, Some(init))
|
||||||
if !self.infcx.tcx.sess.source_map().is_multiline(init.span) =>
|
if !self.infcx.tcx.sess.source_map().is_multiline(init.span) =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user