rust/src/test/ui/codemap_tests
Ralf Jung 372cb9b69c
Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakis
Explain move errors that occur due to method calls involving `self`

When calling a method that takes `self` (e.g. `vec.into_iter()`), the method receiver is moved out of. If the method receiver is used again, a move error will be emitted::

```rust
fn main() {
    let a = vec![true];
    a.into_iter();
    a;
}
```

emits

```
error[E0382]: use of moved value: `a`
 --> src/main.rs:4:5
  |
2 |     let a = vec![true];
  |         - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
3 |     a.into_iter();
  |     - value moved here
4 |     a;
  |     ^ value used here after move
```

However, the error message doesn't make it clear that the move is caused by the call to `into_iter`.

This PR adds additional messages to move errors when the move is caused by using a value as the receiver of a `self` method::

```
error[E0382]: use of moved value: `a`
   --> vec.rs:4:5
    |
2   |     let a = vec![true];
    |         - move occurs because `a` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
3   |     a.into_iter();
    |     ------------- value moved due to this method call
4   |     a;
    |     ^ value used here after move
    |
note: this function takes `self`, which moves the receiver
   --> /home/aaron/repos/rust/src/libcore/iter/traits/collect.rs:239:5
    |
239 |     fn into_iter(self) -> Self::IntoIter;
```

TODO:

- [x] Add special handling for `FnOnce/FnMut/Fn` - we probably don't want to point at the unstable trait methods
- [x] Consider adding additional context for operations (e.g. `Shr::shr`) when the call was generated using the operator syntax (e.g. `a >> b`)
- [x] Consider pointing to the method parent (impl or trait block) in addition to the method itself.
2020-06-15 09:57:22 +02:00
..
bad-format-args.rs Be accurate on format! parse error expectations 2019-09-01 15:10:30 -07:00
bad-format-args.stderr rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
coherence-overlapping-inherent-impl-trait.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
coherence-overlapping-inherent-impl-trait.stderr Add explanation for E0592 2019-06-14 11:19:21 +09:00
empty_span.rs introduce negative_impls feature gate and document 2020-03-26 06:52:55 -04:00
empty_span.stderr Update tests 2019-03-11 23:10:26 +03:00
huge_multispan_highlight.rs Remove licenses 2018-12-25 21:08:33 -07:00
huge_multispan_highlight.stderr update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
issue-11715.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-11715.stderr update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
issue-28308.rs Remove licenses 2018-12-25 21:08:33 -07:00
issue-28308.stderr rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros. 2020-02-06 21:46:38 +02:00
one_line.rs Remove licenses 2018-12-25 21:08:33 -07:00
one_line.stderr update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
overlapping_inherent_impls.rs Remove licenses 2018-12-25 21:08:33 -07:00
overlapping_inherent_impls.stderr Fix a minor grammar nit, update UI tests 2019-09-19 00:16:16 +02:00
tab.rs Remove licenses 2018-12-25 21:08:33 -07:00
tab.stderr Surround types with backticks in type errors 2019-11-18 11:03:04 -08:00
tab_2.rs Remove licenses 2018-12-25 21:08:33 -07:00
tab_2.stderr Update tests 2019-03-11 23:10:26 +03:00
tab_3.rs update tests for migrate mode by default 2019-04-22 08:40:08 +01:00
tab_3.stderr Use fn_span to point to the actual method call 2020-06-11 18:10:13 -04:00
two_files.rs Remove licenses 2018-12-25 21:08:33 -07:00
two_files.stderr Tweak some suggestions in rustc_resolve 2020-04-26 11:43:43 -07:00
two_files_data.rs Update ui test suite to use dyn 2019-05-29 00:57:31 -04:00
unicode.rs Remove licenses 2018-12-25 21:08:33 -07:00
unicode.stderr [AVR] Add required references for AVR to the parser test suites 2020-06-09 17:35:48 +12:00
unicode_2.rs Remove licenses 2018-12-25 21:08:33 -07:00
unicode_2.stderr Add a test and bless existing test case. 2019-12-26 13:13:01 +08:00
unicode_3.rs Moving more build-pass tests to check-pass 2020-04-23 20:21:38 -07:00
unicode_3.stderr rustc: Add a warning count upon completion 2020-04-11 16:15:24 +02:00