File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ allow( warnings) ]
2
+
3
+ // Test that suggestion to add `*` characters applies to implementations of `Deref` as well as
4
+ // references.
5
+
6
+ struct Foo ( i32 ) ;
7
+
8
+ impl std:: ops:: Deref for Foo {
9
+ type Target = i32 ;
10
+ fn deref ( & self ) -> & i32 {
11
+ & self . 0
12
+ }
13
+ }
14
+
15
+ fn main ( ) {
16
+ let x = Foo ( 42 ) ;
17
+ let y: i32 = x; //~ ERROR mismatched types
18
+ let a = & 42 ;
19
+ let b: i32 = a; //~ ERROR mismatched types
20
+ }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/issue-59819.rs:17:18
3
+ |
4
+ LL | let y: i32 = x;
5
+ | ^ expected i32, found struct `Foo`
6
+ |
7
+ = note: expected type `i32`
8
+ found type `Foo`
9
+
10
+ error[E0308]: mismatched types
11
+ --> $DIR/issue-59819.rs:19:18
12
+ |
13
+ LL | let b: i32 = a;
14
+ | ^
15
+ | |
16
+ | expected i32, found &{integer}
17
+ | help: consider dereferencing the borrow: `*a`
18
+ |
19
+ = note: expected type `i32`
20
+ found type `&{integer}`
21
+
22
+ error: aborting due to 2 previous errors
23
+
24
+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments