about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/counters.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-11-04 00:39:21 +0000
committerbors <bors@rust-lang.org>2021-11-04 00:39:21 +0000
commite60e19bc6553ba02b8677ab7e397af738c076c8e (patch)
treeda08a858037b6a1563eb8b11e61867199f74d116 /compiler/rustc_mir_transform/src/coverage/counters.rs
parent4ff90232a0c0c6adb9d2052da2206b26c3c723e4 (diff)
parent4b9e4606cb5c184a142ed34acf6f5baefd2b27f5 (diff)
downloadrust-e60e19bc6553ba02b8677ab7e397af738c076c8e.tar.gz
rust-e60e19bc6553ba02b8677ab7e397af738c076c8e.zip
Auto merge of #90179 - Nilstrieb:lifetime-elision-mismatch-hint, r=estebank
Add beginner friendly lifetime elision hint to E0623

Address #90170

Suggest adding a new lifetime parameter when two elided lifetimes should match up but don't.

Example:

```
error[E0623]: lifetime mismatch
  --> $DIR/issue-90170-elision-mismatch.rs:2:35
   |
LL | fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
   |                 ---------           --------- these two types are declared with different lifetimes...
LL |     core::mem::swap(&mut slice_a, &mut slice_b);
   |                                   ^^^^^^^^^^^^ ...but data from `slice_b` flows into `slice_a` here
   |
   = note: each elided lifetime in input position becomes a distinct lifetime
help: explicitly declare a lifetime and assign it to both
   |
LL | fn foo<'a>(slice_a: &'a mut [u8], slice_b: &'a mut [u8]) {
   |       ++++           ++                     ++

```

for

```rust
fn foo(slice_a: &mut [u8], slice_b: &mut [u8]) {
    core::mem::swap(&mut slice_a, &mut slice_b);
}
```
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/counters.rs')
0 files changed, 0 insertions, 0 deletions