From 5902b2f6e5922068d01af2b7438044dbaee5ace6 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 11 Jun 2020 18:10:13 -0400 Subject: [PATCH] Use `fn_span` to point to the actual method call --- src/librustc_mir/borrow_check/diagnostics/mod.rs | 6 +++--- src/test/ui/codemap_tests/tab_3.stderr | 2 +- src/test/ui/issues/issue-34721.stderr | 4 ++-- src/test/ui/moves/move-fn-self-receiver.stderr | 16 ++++++++-------- .../moves-based-on-type-access-to-field.stderr | 2 +- .../ui/moves/moves-based-on-type-exprs.stderr | 4 ++-- .../ui/unsized-locals/borrow-after-move.stderr | 2 +- src/test/ui/unsized-locals/double-move.stderr | 2 +- .../use/use-after-move-self-based-on-type.stderr | 2 +- src/test/ui/use/use-after-move-self.stderr | 2 +- src/test/ui/walk-struct-literal-with.stderr | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index 2e49b2b58e85..ca8c77bcd69f 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -795,8 +795,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { debug!("move_spans: target_temp = {:?}", target_temp); if let Some(Terminator { - kind: TerminatorKind::Call { func, args, .. }, - source_info: term_source_info, + kind: TerminatorKind::Call { func, args, fn_span, .. }, + .. }) = &self.body[location.block].terminator { let mut method_did = None; @@ -819,7 +819,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if let [Operand::Move(self_place), ..] = **args { if self_place.as_local() == Some(target_temp) { let is_fn_once = tcx.parent(method_did) == tcx.lang_items().fn_once_trait(); - let fn_call_span = term_source_info.span; + let fn_call_span = *fn_span; let self_arg = tcx.fn_arg_names(method_did)[0]; diff --git a/src/test/ui/codemap_tests/tab_3.stderr b/src/test/ui/codemap_tests/tab_3.stderr index b8abee670ef0..614e69e89f6e 100644 --- a/src/test/ui/codemap_tests/tab_3.stderr +++ b/src/test/ui/codemap_tests/tab_3.stderr @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `some_vec` LL | let some_vec = vec!["hi"]; | -------- move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait LL | some_vec.into_iter(); - | -------------------- `some_vec` moved due to this method call + | ----------- `some_vec` moved due to this method call LL | { LL | println!("{:?}", some_vec); | ^^^^^^^^ value borrowed here after move diff --git a/src/test/ui/issues/issue-34721.stderr b/src/test/ui/issues/issue-34721.stderr index 2ce0786e8315..b4cc1a0aa7eb 100644 --- a/src/test/ui/issues/issue-34721.stderr +++ b/src/test/ui/issues/issue-34721.stderr @@ -5,10 +5,10 @@ LL | pub fn baz(x: T) -> T { | - move occurs because `x` has type `T`, which does not implement the `Copy` trait LL | if 0 == 1 { LL | bar::bar(x.zero()) - | -------- `x` moved due to this method call + | ------ `x` moved due to this method call LL | } else { LL | x.zero() - | -------- `x` moved due to this method call + | ------ `x` moved due to this method call LL | }; LL | x.zero() | ^ value used here after move diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/src/test/ui/moves/move-fn-self-receiver.stderr index def4f3244833..4333e8a23e86 100644 --- a/src/test/ui/moves/move-fn-self-receiver.stderr +++ b/src/test/ui/moves/move-fn-self-receiver.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `val.0` --> $DIR/move-fn-self-receiver.rs:30:5 | LL | val.0.into_iter().next(); - | ----------------- `val.0` moved due to this method call + | ----------- `val.0` moved due to this method call LL | val.0; | ^^^^^ value used here after move | @@ -19,7 +19,7 @@ error[E0382]: use of moved value: `foo` LL | let foo = Foo; | --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait LL | foo.use_self(); - | -------------- `foo` moved due to this method call + | ---------- `foo` moved due to this method call LL | foo; | ^^^ value used here after move | @@ -35,7 +35,7 @@ error[E0382]: use of moved value: `second_foo` LL | let second_foo = Foo; | ---------- move occurs because `second_foo` has type `Foo`, which does not implement the `Copy` trait LL | second_foo.use_self(); - | --------------------- `second_foo` moved due to this method call + | ---------- `second_foo` moved due to this method call LL | second_foo; | ^^^^^^^^^^ value used here after move @@ -45,7 +45,7 @@ error[E0382]: use of moved value: `boxed_foo` LL | let boxed_foo = Box::new(Foo); | --------- move occurs because `boxed_foo` has type `std::boxed::Box`, which does not implement the `Copy` trait LL | boxed_foo.use_box_self(); - | ------------------------ `boxed_foo` moved due to this method call + | -------------- `boxed_foo` moved due to this method call LL | boxed_foo; | ^^^^^^^^^ value used here after move | @@ -61,7 +61,7 @@ error[E0382]: use of moved value: `pin_box_foo` LL | let pin_box_foo = Box::pin(Foo); | ----------- move occurs because `pin_box_foo` has type `std::pin::Pin>`, which does not implement the `Copy` trait LL | pin_box_foo.use_pin_box_self(); - | ------------------------------ `pin_box_foo` moved due to this method call + | ------------------ `pin_box_foo` moved due to this method call LL | pin_box_foo; | ^^^^^^^^^^^ value used here after move | @@ -87,7 +87,7 @@ error[E0382]: use of moved value: `rc_foo` LL | let rc_foo = Rc::new(Foo); | ------ move occurs because `rc_foo` has type `std::rc::Rc`, which does not implement the `Copy` trait LL | rc_foo.use_rc_self(); - | -------------------- `rc_foo` moved due to this method call + | ------------- `rc_foo` moved due to this method call LL | rc_foo; | ^^^^^^ value used here after move | @@ -132,7 +132,7 @@ error[E0382]: use of moved value: `explicit_into_iter` LL | let explicit_into_iter = vec![true]; | ------------------ move occurs because `explicit_into_iter` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | for _val in explicit_into_iter.into_iter() {} - | ------------------------------ `explicit_into_iter` moved due to this method call + | ----------- `explicit_into_iter` moved due to this method call LL | explicit_into_iter; | ^^^^^^^^^^^^^^^^^^ value used here after move @@ -142,7 +142,7 @@ error[E0382]: use of moved value: `container` LL | let container = Container(vec![]); | --------- move occurs because `container` has type `Container`, which does not implement the `Copy` trait LL | for _val in container.custom_into_iter() {} - | ---------------------------- `container` moved due to this method call + | ------------------ `container` moved due to this method call LL | container; | ^^^^^^^^^ value used here after move | diff --git a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr index f76b7a6f68f9..142feb280d15 100644 --- a/src/test/ui/moves/moves-based-on-type-access-to-field.stderr +++ b/src/test/ui/moves/moves-based-on-type-access-to-field.stderr @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `x` LL | let x = vec!["hi".to_string()]; | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | consume(x.into_iter().next().unwrap()); - | ------------- `x` moved due to this method call + | ----------- `x` moved due to this method call LL | touch(&x[0]); | ^ value borrowed here after move | diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/src/test/ui/moves/moves-based-on-type-exprs.stderr index f55854ccf090..ff98aab50c9f 100644 --- a/src/test/ui/moves/moves-based-on-type-exprs.stderr +++ b/src/test/ui/moves/moves-based-on-type-exprs.stderr @@ -104,7 +104,7 @@ error[E0382]: borrow of moved value: `x` LL | let x = vec!["hi".to_string()]; | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let _y = x.into_iter().next().unwrap(); - | ------------- `x` moved due to this method call + | ----------- `x` moved due to this method call LL | touch(&x); | ^^ value borrowed here after move | @@ -120,7 +120,7 @@ error[E0382]: borrow of moved value: `x` LL | let x = vec!["hi".to_string()]; | - move occurs because `x` has type `std::vec::Vec`, which does not implement the `Copy` trait LL | let _y = [x.into_iter().next().unwrap(); 1]; - | ------------- `x` moved due to this method call + | ----------- `x` moved due to this method call LL | touch(&x); | ^^ value borrowed here after move | diff --git a/src/test/ui/unsized-locals/borrow-after-move.stderr b/src/test/ui/unsized-locals/borrow-after-move.stderr index d3f59db04368..906b543e4212 100644 --- a/src/test/ui/unsized-locals/borrow-after-move.stderr +++ b/src/test/ui/unsized-locals/borrow-after-move.stderr @@ -37,7 +37,7 @@ error[E0382]: borrow of moved value: `y` LL | let y = *x; | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | y.foo(); - | ------- `y` moved due to this method call + | ----- `y` moved due to this method call ... LL | println!("{}", &y); | ^^ value borrowed here after move diff --git a/src/test/ui/unsized-locals/double-move.stderr b/src/test/ui/unsized-locals/double-move.stderr index 01a08ba9944e..49b2031c6b9d 100644 --- a/src/test/ui/unsized-locals/double-move.stderr +++ b/src/test/ui/unsized-locals/double-move.stderr @@ -34,7 +34,7 @@ error[E0382]: use of moved value: `y` LL | let y = *x; | - move occurs because `y` has type `str`, which does not implement the `Copy` trait LL | y.foo(); - | ------- `y` moved due to this method call + | ----- `y` moved due to this method call LL | y.foo(); | ^ value used here after move | diff --git a/src/test/ui/use/use-after-move-self-based-on-type.stderr b/src/test/ui/use/use-after-move-self-based-on-type.stderr index 0b3ee040d357..b9440f4de07a 100644 --- a/src/test/ui/use/use-after-move-self-based-on-type.stderr +++ b/src/test/ui/use/use-after-move-self-based-on-type.stderr @@ -4,7 +4,7 @@ error[E0382]: use of moved value: `self` LL | pub fn foo(self) -> isize { | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait LL | self.bar(); - | ---------- `self` moved due to this method call + | ----- `self` moved due to this method call LL | return self.x; | ^^^^^^ value used here after move | diff --git a/src/test/ui/use/use-after-move-self.stderr b/src/test/ui/use/use-after-move-self.stderr index e156a3f699b7..3da53b024db4 100644 --- a/src/test/ui/use/use-after-move-self.stderr +++ b/src/test/ui/use/use-after-move-self.stderr @@ -4,7 +4,7 @@ error[E0382]: use of moved value: `self` LL | pub fn foo(self) -> isize { | ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait LL | self.bar(); - | ---------- `self` moved due to this method call + | ----- `self` moved due to this method call LL | return *self.x; | ^^^^^^^ value used here after move | diff --git a/src/test/ui/walk-struct-literal-with.stderr b/src/test/ui/walk-struct-literal-with.stderr index 2534c29c18d0..ece63a2b8194 100644 --- a/src/test/ui/walk-struct-literal-with.stderr +++ b/src/test/ui/walk-struct-literal-with.stderr @@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `start` LL | let start = Mine{test:"Foo".to_string(), other_val:0}; | ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait LL | let end = Mine{other_val:1, ..start.make_string_bar()}; - | ----------------------- `start` moved due to this method call + | ----------------- `start` moved due to this method call LL | println!("{}", start.test); | ^^^^^^^^^^ value borrowed here after move |