Skip to content

Commit 0887944

Browse files
Add additional test
Co-authored-by: Camelid <[email protected]>
1 parent e603f99 commit 0887944

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/test/ui/deref-suggestion.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

src/test/ui/deref-suggestion.stderr

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff 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

112141
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)