Skip to content

Commit 5902b2f

Browse files
committed
Use fn_span to point to the actual method call
1 parent 2c11c35 commit 5902b2f

11 files changed

+22
-22
lines changed

src/librustc_mir/borrow_check/diagnostics/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
795795
debug!("move_spans: target_temp = {:?}", target_temp);
796796

797797
if let Some(Terminator {
798-
kind: TerminatorKind::Call { func, args, .. },
799-
source_info: term_source_info,
798+
kind: TerminatorKind::Call { func, args, fn_span, .. },
799+
..
800800
}) = &self.body[location.block].terminator
801801
{
802802
let mut method_did = None;
@@ -819,7 +819,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
819819
if let [Operand::Move(self_place), ..] = **args {
820820
if self_place.as_local() == Some(target_temp) {
821821
let is_fn_once = tcx.parent(method_did) == tcx.lang_items().fn_once_trait();
822-
let fn_call_span = term_source_info.span;
822+
let fn_call_span = *fn_span;
823823

824824
let self_arg = tcx.fn_arg_names(method_did)[0];
825825

src/test/ui/codemap_tests/tab_3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `some_vec`
44
LL | let some_vec = vec!["hi"];
55
| -------- move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait
66
LL | some_vec.into_iter();
7-
| -------------------- `some_vec` moved due to this method call
7+
| ----------- `some_vec` moved due to this method call
88
LL | {
99
LL | println!("{:?}", some_vec);
1010
| ^^^^^^^^ value borrowed here after move

src/test/ui/issues/issue-34721.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ LL | pub fn baz<T: Foo>(x: T) -> T {
55
| - move occurs because `x` has type `T`, which does not implement the `Copy` trait
66
LL | if 0 == 1 {
77
LL | bar::bar(x.zero())
8-
| -------- `x` moved due to this method call
8+
| ------ `x` moved due to this method call
99
LL | } else {
1010
LL | x.zero()
11-
| -------- `x` moved due to this method call
11+
| ------ `x` moved due to this method call
1212
LL | };
1313
LL | x.zero()
1414
| ^ value used here after move

src/test/ui/moves/move-fn-self-receiver.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0382]: use of moved value: `val.0`
22
--> $DIR/move-fn-self-receiver.rs:30:5
33
|
44
LL | val.0.into_iter().next();
5-
| ----------------- `val.0` moved due to this method call
5+
| ----------- `val.0` moved due to this method call
66
LL | val.0;
77
| ^^^^^ value used here after move
88
|
@@ -19,7 +19,7 @@ error[E0382]: use of moved value: `foo`
1919
LL | let foo = Foo;
2020
| --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait
2121
LL | foo.use_self();
22-
| -------------- `foo` moved due to this method call
22+
| ---------- `foo` moved due to this method call
2323
LL | foo;
2424
| ^^^ value used here after move
2525
|
@@ -35,7 +35,7 @@ error[E0382]: use of moved value: `second_foo`
3535
LL | let second_foo = Foo;
3636
| ---------- move occurs because `second_foo` has type `Foo`, which does not implement the `Copy` trait
3737
LL | second_foo.use_self();
38-
| --------------------- `second_foo` moved due to this method call
38+
| ---------- `second_foo` moved due to this method call
3939
LL | second_foo;
4040
| ^^^^^^^^^^ value used here after move
4141

@@ -45,7 +45,7 @@ error[E0382]: use of moved value: `boxed_foo`
4545
LL | let boxed_foo = Box::new(Foo);
4646
| --------- move occurs because `boxed_foo` has type `std::boxed::Box<Foo>`, which does not implement the `Copy` trait
4747
LL | boxed_foo.use_box_self();
48-
| ------------------------ `boxed_foo` moved due to this method call
48+
| -------------- `boxed_foo` moved due to this method call
4949
LL | boxed_foo;
5050
| ^^^^^^^^^ value used here after move
5151
|
@@ -61,7 +61,7 @@ error[E0382]: use of moved value: `pin_box_foo`
6161
LL | let pin_box_foo = Box::pin(Foo);
6262
| ----------- move occurs because `pin_box_foo` has type `std::pin::Pin<std::boxed::Box<Foo>>`, which does not implement the `Copy` trait
6363
LL | pin_box_foo.use_pin_box_self();
64-
| ------------------------------ `pin_box_foo` moved due to this method call
64+
| ------------------ `pin_box_foo` moved due to this method call
6565
LL | pin_box_foo;
6666
| ^^^^^^^^^^^ value used here after move
6767
|
@@ -87,7 +87,7 @@ error[E0382]: use of moved value: `rc_foo`
8787
LL | let rc_foo = Rc::new(Foo);
8888
| ------ move occurs because `rc_foo` has type `std::rc::Rc<Foo>`, which does not implement the `Copy` trait
8989
LL | rc_foo.use_rc_self();
90-
| -------------------- `rc_foo` moved due to this method call
90+
| ------------- `rc_foo` moved due to this method call
9191
LL | rc_foo;
9292
| ^^^^^^ value used here after move
9393
|
@@ -132,7 +132,7 @@ error[E0382]: use of moved value: `explicit_into_iter`
132132
LL | let explicit_into_iter = vec![true];
133133
| ------------------ move occurs because `explicit_into_iter` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
134134
LL | for _val in explicit_into_iter.into_iter() {}
135-
| ------------------------------ `explicit_into_iter` moved due to this method call
135+
| ----------- `explicit_into_iter` moved due to this method call
136136
LL | explicit_into_iter;
137137
| ^^^^^^^^^^^^^^^^^^ value used here after move
138138

@@ -142,7 +142,7 @@ error[E0382]: use of moved value: `container`
142142
LL | let container = Container(vec![]);
143143
| --------- move occurs because `container` has type `Container`, which does not implement the `Copy` trait
144144
LL | for _val in container.custom_into_iter() {}
145-
| ---------------------------- `container` moved due to this method call
145+
| ------------------ `container` moved due to this method call
146146
LL | container;
147147
| ^^^^^^^^^ value used here after move
148148
|

src/test/ui/moves/moves-based-on-type-access-to-field.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `x`
44
LL | let x = vec!["hi".to_string()];
55
| - move occurs because `x` has type `std::vec::Vec<std::string::String>`, which does not implement the `Copy` trait
66
LL | consume(x.into_iter().next().unwrap());
7-
| ------------- `x` moved due to this method call
7+
| ----------- `x` moved due to this method call
88
LL | touch(&x[0]);
99
| ^ value borrowed here after move
1010
|

src/test/ui/moves/moves-based-on-type-exprs.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ error[E0382]: borrow of moved value: `x`
104104
LL | let x = vec!["hi".to_string()];
105105
| - move occurs because `x` has type `std::vec::Vec<std::string::String>`, which does not implement the `Copy` trait
106106
LL | let _y = x.into_iter().next().unwrap();
107-
| ------------- `x` moved due to this method call
107+
| ----------- `x` moved due to this method call
108108
LL | touch(&x);
109109
| ^^ value borrowed here after move
110110
|
@@ -120,7 +120,7 @@ error[E0382]: borrow of moved value: `x`
120120
LL | let x = vec!["hi".to_string()];
121121
| - move occurs because `x` has type `std::vec::Vec<std::string::String>`, which does not implement the `Copy` trait
122122
LL | let _y = [x.into_iter().next().unwrap(); 1];
123-
| ------------- `x` moved due to this method call
123+
| ----------- `x` moved due to this method call
124124
LL | touch(&x);
125125
| ^^ value borrowed here after move
126126
|

src/test/ui/unsized-locals/borrow-after-move.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ error[E0382]: borrow of moved value: `y`
3737
LL | let y = *x;
3838
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
3939
LL | y.foo();
40-
| ------- `y` moved due to this method call
40+
| ----- `y` moved due to this method call
4141
...
4242
LL | println!("{}", &y);
4343
| ^^ value borrowed here after move

src/test/ui/unsized-locals/double-move.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ error[E0382]: use of moved value: `y`
3434
LL | let y = *x;
3535
| - move occurs because `y` has type `str`, which does not implement the `Copy` trait
3636
LL | y.foo();
37-
| ------- `y` moved due to this method call
37+
| ----- `y` moved due to this method call
3838
LL | y.foo();
3939
| ^ value used here after move
4040
|

src/test/ui/use/use-after-move-self-based-on-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: use of moved value: `self`
44
LL | pub fn foo(self) -> isize {
55
| ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait
66
LL | self.bar();
7-
| ---------- `self` moved due to this method call
7+
| ----- `self` moved due to this method call
88
LL | return self.x;
99
| ^^^^^^ value used here after move
1010
|

src/test/ui/use/use-after-move-self.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: use of moved value: `self`
44
LL | pub fn foo(self) -> isize {
55
| ---- move occurs because `self` has type `S`, which does not implement the `Copy` trait
66
LL | self.bar();
7-
| ---------- `self` moved due to this method call
7+
| ----- `self` moved due to this method call
88
LL | return *self.x;
99
| ^^^^^^^ value used here after move
1010
|

src/test/ui/walk-struct-literal-with.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0382]: borrow of moved value: `start`
44
LL | let start = Mine{test:"Foo".to_string(), other_val:0};
55
| ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait
66
LL | let end = Mine{other_val:1, ..start.make_string_bar()};
7-
| ----------------------- `start` moved due to this method call
7+
| ----------------- `start` moved due to this method call
88
LL | println!("{}", start.test);
99
| ^^^^^^^^^^ value borrowed here after move
1010
|

0 commit comments

Comments
 (0)