Point at method call when type annotations are needed
This commit is contained in:
parent
7dbfb0a8ca
commit
12af2561e9
13 changed files with 108 additions and 44 deletions
|
|
@ -1,18 +1,23 @@
|
|||
error[E0284]: type annotations needed: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/associated-types-overridden-binding.rs:4:1
|
||||
|
|
||||
LL | trait Foo: Iterator<Item = i32> {}
|
||||
| ------------------------------- required by `Foo`
|
||||
LL | trait Bar: Foo<Item = u32> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `Self`
|
||||
|
|
||||
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/associated-types-overridden-binding.rs:7:1
|
||||
|
|
||||
LL | trait I32Iterator = Iterator<Item = i32>;
|
||||
| ----------------------------------------- required by `I32Iterator`
|
||||
LL | trait U32Iterator = I32Iterator<Item = u32>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `Self`
|
||||
|
|
||||
= note: cannot resolve `<Self as std::iter::Iterator>::Item == i32`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0284.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
||||
For more information about this error, try `rustc --explain E0284`.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0284]: type annotations needed: cannot resolve `<_ as Foo>::A == _`
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/associated-types-unconstrained.rs:14:20
|
||||
|
|
||||
LL | let x: isize = Foo::bar();
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ cannot infer type
|
||||
|
|
||||
= note: cannot resolve `<_ as Foo>::A == _`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
error[E0284]: type annotations needed: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S`
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/issue-12028.rs:27:14
|
||||
|
|
||||
LL | self.input_stream(&mut stream);
|
||||
| ^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^ cannot infer type for `H`
|
||||
|
|
||||
= note: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/issue-65611.rs:59:20
|
||||
|
|
||||
LL | let x = buffer.last().unwrap().0.clone();
|
||||
| ^^^^ cannot infer type for `T`
|
||||
| ^^^^
|
||||
| |
|
||||
| cannot infer type for `T`
|
||||
| help: consider specifying the type argument in the method call: `last::<_>`
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ fn f(x: &i32) -> Result<i32, ()> {
|
|||
|
||||
fn g() -> Result<Vec<i32>, ()> {
|
||||
let l = [1, 2, 3, 4];
|
||||
l.iter().map(f).collect()? //~ ERROR type annotations needed: cannot resolve
|
||||
l.iter().map(f).collect()? //~ ERROR type annotations needed
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
error[E0284]: type annotations needed: cannot resolve `<_ as std::ops::Try>::Ok == _`
|
||||
--> $DIR/question-mark-type-infer.rs:12:5
|
||||
error[E0284]: type annotations needed
|
||||
--> $DIR/question-mark-type-infer.rs:12:21
|
||||
|
|
||||
LL | l.iter().map(f).collect()?
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^
|
||||
| |
|
||||
| cannot infer type
|
||||
| help: consider specifying the type argument in the method call: `collect::<_>`
|
||||
|
|
||||
= note: cannot resolve `<_ as std::ops::Try>::Ok == _`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ fn shines_a_beacon_through_the_darkness() {
|
|||
}
|
||||
|
||||
fn courier_to_des_moines_and_points_west(data: &[u32]) -> String {
|
||||
data.iter() //~ ERROR type annotations needed
|
||||
.sum::<_>()
|
||||
data.iter()
|
||||
.sum::<_>() //~ ERROR type annotations needed
|
||||
.to_string()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,10 @@ LL | x.unwrap().method_that_could_exist_on_some_type();
|
|||
= note: type must be known at this point
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-42234-unknown-receiver-type.rs:12:5
|
||||
--> $DIR/issue-42234-unknown-receiver-type.rs:13:10
|
||||
|
|
||||
LL | / data.iter()
|
||||
LL | | .sum::<_>()
|
||||
| |___________________^ cannot infer type
|
||||
LL | .sum::<_>()
|
||||
| ^^^ cannot infer type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ error[E0282]: type annotations needed
|
|||
--> $DIR/type-annotations-needed-expr.rs:2:39
|
||||
|
|
||||
LL | let _ = (vec![1,2,3]).into_iter().sum() as f64;
|
||||
| ^^^ cannot infer type for `S`
|
||||
| ^^^
|
||||
| |
|
||||
| cannot infer type for `S`
|
||||
| help: consider specifying the type argument in the method call: `sum::<_>`
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue