Skip to content

Commit 92dbf20

Browse files
jieyouxusimp4t7
authored andcommitted
Add regression test for assert desugaring change
Using the MCVE reported in RUST-145770.
1 parent 6b49f2e commit 92dbf20

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Regression test for #145770.
2+
//!
3+
//! Changing the `assert!` desugaring from an `if !cond {}` to `match` expression is
4+
//! backwards-incompatible, and may need to be done over an edition boundary or limit editions for
5+
//! which the desguaring change impacts.
6+
7+
#[derive(Debug)]
8+
struct F {
9+
data: bool
10+
}
11+
12+
impl std::ops::Not for F {
13+
type Output = bool;
14+
fn not(self) -> Self::Output { !self.data }
15+
}
16+
17+
fn main() {
18+
let f = F { data: true };
19+
20+
assert!(f);
21+
//~^ ERROR mismatched types
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/assert-desugaring-145770.rs:20:11
3+
|
4+
LL | assert!(f);
5+
| ^ expected `bool`, found `F`
6+
|
7+
help: you might have meant to use field `data` whose type is `bool`
8+
|
9+
LL | assert!(f.data);
10+
| +++++
11+
12+
error: aborting due to 1 previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)