Skip to content
Myr

Add ui test for incorrect type of ensure argument

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 5152c1d · Browse files · 2 files+28 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+28 added−0 removed

  • tests:+28 added−0 removed

2 files+28 added−0 removed

added:tests/ui/ensure-nonbool.rs+13 added
1use anyhow::{ensure, Result};23fn main() -> Result<()> {4 ensure!("...");56 struct Struct(bool);7 let mut s = Struct(true);8 match &mut s {9 Struct(cond) => ensure!(cond),10 }1112 Ok(())13}
added:tests/ui/ensure-nonbool.stderr+15 added
1error[E0600]: cannot apply unary operator `!` to type `&'static str`2 --> tests/ui/ensure-nonbool.rs:4:53 |44 | ensure!("...");5 | ^^^^^^^^^^^^^^ cannot apply unary operator `!`6 |7 = note: this error originates in the macro `$crate::__fallback_ensure` which comes from the expansion of the macro `ensure` (in Nightly builds, run with -Z macro-backtrace for more info)89error[E0600]: cannot apply unary operator `!` to type `&mut bool`10 --> tests/ui/ensure-nonbool.rs:9:2511 |129 | Struct(cond) => ensure!(cond),13 | ^^^^^^^^^^^^^ cannot apply unary operator `!`14 |15 = note: this error originates in the macro `$crate::__fallback_ensure` which comes from the expansion of the macro `ensure` (in Nightly builds, run with -Z macro-backtrace for more info)