File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Regression test for #72616, it used to emit incorrect diagnostics, like:
2
+ // error[E0283]: type annotations needed for `String`
3
+ // --> src/main.rs:8:30
4
+ // |
5
+ // 5 | let _: String = "".to_owned().try_into().unwrap();
6
+ // | - consider giving this pattern a type
7
+ // ...
8
+ // 8 | if String::from("a") == "a".try_into().unwrap() {}
9
+ // | ^^ cannot infer type for struct `String`
10
+ // |
11
+ // = note: cannot satisfy `String: PartialEq<_>`
12
+
13
+ use std:: convert:: TryInto ;
14
+
15
+ pub fn main ( ) {
16
+ {
17
+ let _: String = "" . to_owned ( ) . try_into ( ) . unwrap ( ) ;
18
+ }
19
+ {
20
+ if String :: from ( "a" ) == "a" . try_into ( ) . unwrap ( ) { }
21
+ //~^ ERROR: type annotations needed
22
+ }
23
+ {
24
+ let _: String = match "_" . try_into ( ) {
25
+ Ok ( a) => a,
26
+ Err ( _) => "" . into ( ) ,
27
+ } ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ error[E0283]: type annotations needed
2
+ --> $DIR/issue-72616.rs:20:30
3
+ |
4
+ LL | if String::from("a") == "a".try_into().unwrap() {}
5
+ | ^^ -------------- this method call resolves to `std::result::Result<T, <Self as TryInto<T>>::Error>`
6
+ | |
7
+ | cannot infer type
8
+ |
9
+ = note: cannot satisfy `String: PartialEq<_>`
10
+
11
+ error: aborting due to previous error
12
+
13
+ For more information about this error, try `rustc --explain E0283`.
You can’t perform that action at this time.
0 commit comments