diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2022-12-27 09:25:00 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2022-12-27 09:25:00 -0800 |
| commit | 0c0685bb68a53636e1347ea93dccfa7ac1e24deb (patch) | |
| tree | 6f46e9393e558745f5c220f1f3d350a2b4457f2b /src | |
| parent | c9381fc334cb8db62fdb5a8f75807ebdff3d6e15 (diff) | |
| download | rust-0c0685bb68a53636e1347ea93dccfa7ac1e24deb.tar.gz rust-0c0685bb68a53636e1347ea93dccfa7ac1e24deb.zip | |
review comments: make suggestion more accurate
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/suggestions/method-access-to-range-literal-typo.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/suggestions/method-access-to-range-literal-typo.stderr | 39 |
2 files changed, 31 insertions, 20 deletions
diff --git a/src/test/ui/suggestions/method-access-to-range-literal-typo.rs b/src/test/ui/suggestions/method-access-to-range-literal-typo.rs index 545f9c597fd..ac662edafe6 100644 --- a/src/test/ui/suggestions/method-access-to-range-literal-typo.rs +++ b/src/test/ui/suggestions/method-access-to-range-literal-typo.rs @@ -4,14 +4,22 @@ fn as_ref() -> Option<Vec<u8>> { struct Type { option: Option<Vec<u8>> } +trait Trait { + fn foo(&self) -> Vec<u8>; +} +impl Trait for Option<Vec<u8>> { + fn foo(&self) -> Vec<u8> { + vec![1, 2, 3] + } +} impl Type { fn method(&self) -> Option<Vec<u8>> { self.option..as_ref().map(|x| x) //~^ ERROR E0308 } - fn method2(&self) -> Option<Vec<u8>> { - self.option..foo().map(|x| x) + fn method2(&self) -> &u8 { + self.option..foo().get(0) //~^ ERROR E0425 //~| ERROR E0308 } diff --git a/src/test/ui/suggestions/method-access-to-range-literal-typo.stderr b/src/test/ui/suggestions/method-access-to-range-literal-typo.stderr index becc825b6cf..02db7f81ebd 100644 --- a/src/test/ui/suggestions/method-access-to-range-literal-typo.stderr +++ b/src/test/ui/suggestions/method-access-to-range-literal-typo.stderr @@ -1,16 +1,17 @@ error[E0425]: cannot find function `foo` in this scope - --> $DIR/method-access-to-range-literal-typo.rs:14:22 + --> $DIR/method-access-to-range-literal-typo.rs:22:22 | -LL | self.option..foo().map(|x| x) +LL | self.option..foo().get(0) | ^^^ not found in this scope | help: you might have meant to write a method call instead of a range | -LL | self.option.foo().map(|x| x) - | ~ +LL - self.option..foo().get(0) +LL + self.option.foo().get(0) + | error[E0308]: mismatched types - --> $DIR/method-access-to-range-literal-typo.rs:10:9 + --> $DIR/method-access-to-range-literal-typo.rs:18:9 | LL | fn method(&self) -> Option<Vec<u8>> { | --------------- expected `Option<Vec<u8>>` because of return type @@ -19,25 +20,27 @@ LL | self.option..as_ref().map(|x| x) | = note: expected enum `Option<_>` found struct `std::ops::Range<Option<_>>` -help: you might have meant to write a method call instead of a range +help: you likely meant to write a method call instead of a range + | +LL - self.option..as_ref().map(|x| x) +LL + self.option.as_ref().map(|x| x) | -LL | self.option.as_ref().map(|x| x) - | ~ error[E0308]: mismatched types - --> $DIR/method-access-to-range-literal-typo.rs:14:9 + --> $DIR/method-access-to-range-literal-typo.rs:22:9 | -LL | fn method2(&self) -> Option<Vec<u8>> { - | --------------- expected `Option<Vec<u8>>` because of return type -LL | self.option..foo().map(|x| x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Option`, found struct `Range` +LL | fn method2(&self) -> &u8 { + | --- expected `&u8` because of return type +LL | self.option..foo().get(0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&u8`, found struct `Range` | - = note: expected enum `Option<_>` - found struct `std::ops::Range<Option<_>>` -help: you might have meant to write a method call instead of a range + = note: expected reference `&u8` + found struct `std::ops::Range<Option<Vec<u8>>>` +help: you likely meant to write a method call instead of a range + | +LL - self.option..foo().get(0) +LL + self.option.foo().get(0) | -LL | self.option.foo().map(|x| x) - | ~ error: aborting due to 3 previous errors |
