File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -63,4 +63,12 @@ fn main() {
6363 b
6464 //~^ ERROR mismatched types
6565 } ;
66+ let val = if true {
67+ * a
68+ } else if true {
69+ //~^ ERROR incompatible types
70+ b
71+ } else {
72+ & 0
73+ } ;
6674}
Original file line number Diff line number Diff line change @@ -107,6 +107,35 @@ LL | b
107107 | expected `i32`, found `&{integer}`
108108 | help: consider dereferencing the borrow: `*b`
109109
110- error: aborting due to 12 previous errors
110+ error[E0308]: `if` and `else` have incompatible types
111+ --> $DIR/deref-suggestion.rs:68:12
112+ |
113+ LL | let val = if true {
114+ | _______________-
115+ LL | | *a
116+ | | -- expected because of this
117+ LL | | } else if true {
118+ | |____________^
119+ LL | ||
120+ LL | || b
121+ LL | || } else {
122+ LL | || &0
123+ LL | || };
124+ | || ^
125+ | ||_____|
126+ | |______`if` and `else` have incompatible types
127+ | expected `i32`, found `&{integer}`
128+ |
129+ help: consider dereferencing the borrow
130+ |
131+ LL | } else *if true {
132+ LL |
133+ LL | b
134+ LL | } else {
135+ LL | &0
136+ LL | };
137+ |
138+
139+ error: aborting due to 13 previous errors
111140
112141For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments