mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 12:36:35 +03:00
Add regression test for assert desugaring change
Using the MCVE reported in RUST-145770.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
//! Regression test for #145770.
|
||||
//!
|
||||
//! Changing the `assert!` desugaring from an `if !cond {}` to `match` expression is
|
||||
//! backwards-incompatible, and may need to be done over an edition boundary or limit editions for
|
||||
//! which the desguaring change impacts.
|
||||
|
||||
#[derive(Debug)]
|
||||
struct F {
|
||||
data: bool
|
||||
}
|
||||
|
||||
impl std::ops::Not for F {
|
||||
type Output = bool;
|
||||
fn not(self) -> Self::Output { !self.data }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let f = F { data: true };
|
||||
|
||||
assert!(f);
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/assert-desugaring-145770.rs:20:11
|
||||
|
|
||||
LL | assert!(f);
|
||||
| ^ expected `bool`, found `F`
|
||||
|
|
||||
help: you might have meant to use field `data` whose type is `bool`
|
||||
|
|
||||
LL | assert!(f.data);
|
||||
| +++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
Reference in New Issue
Block a user