-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to custom Not trait instead of '!' operator
- Loading branch information
Showing
5 changed files
with
123 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,91 @@ | ||
error[E0600]: cannot apply unary operator `!` to type `&'static str` | ||
--> tests/ui/ensure-nonbool.rs:16:5 | ||
error[E0277]: the trait bound `&str: __private::not::Bool` is not satisfied | ||
--> tests/ui/ensure-nonbool.rs:25:13 | ||
| | ||
16 | ensure!("..."); | ||
| ^^^^^^^^^^^^^^ cannot apply unary operator `!` | ||
25 | ensure!("..."); | ||
| --------^^^^^- | ||
| | | | ||
| | the trait `__private::not::Bool` is not implemented for `&str` | ||
| required by a bound introduced by this call | ||
| | ||
= 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) | ||
= help: the following other types implement trait `__private::not::Bool`: | ||
&bool | ||
bool | ||
note: required by a bound in `anyhow::__private::not` | ||
--> src/lib.rs | ||
| | ||
| pub fn not(cond: impl Bool) -> bool { | ||
| ^^^^ required by this bound in `not` | ||
|
||
error[E0600]: cannot apply unary operator `!` to type `&mut bool` | ||
--> tests/ui/ensure-nonbool.rs:20:23 | ||
error[E0277]: the trait bound `&mut bool: __private::not::Bool` is not satisfied | ||
--> tests/ui/ensure-nonbool.rs:29:31 | ||
| | ||
29 | Bool(cond) => ensure!(cond), | ||
| --------^^^^- | ||
| | | | ||
| | the trait `__private::not::Bool` is not implemented for `&mut bool` | ||
| required by a bound introduced by this call | ||
| | ||
20 | Bool(cond) => ensure!(cond), | ||
| ^^^^^^^^^^^^^ cannot apply unary operator `!` | ||
= help: the following other types implement trait `__private::not::Bool`: | ||
&bool | ||
bool | ||
= note: `__private::not::Bool` is implemented for `&bool`, but not for `&mut bool` | ||
note: required by a bound in `anyhow::__private::not` | ||
--> src/lib.rs | ||
| | ||
= 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) | ||
| pub fn not(cond: impl Bool) -> bool { | ||
| ^^^^ required by this bound in `not` | ||
|
||
error[E0600]: cannot apply unary operator `!` to type `DerefBool` | ||
--> tests/ui/ensure-nonbool.rs:24:5 | ||
error[E0277]: the trait bound `DerefBool: __private::not::Bool` is not satisfied | ||
--> tests/ui/ensure-nonbool.rs:33:13 | ||
| | ||
24 | ensure!(db); | ||
| ^^^^^^^^^^^ cannot apply unary operator `!` | ||
33 | ensure!(db); | ||
| --------^^- | ||
| | | | ||
| | the trait `__private::not::Bool` is not implemented for `DerefBool` | ||
| required by a bound introduced by this call | ||
| | ||
note: an implementation of `Not` might be missing for `DerefBool` | ||
--> tests/ui/ensure-nonbool.rs:6:1 | ||
= help: the following other types implement trait `__private::not::Bool`: | ||
&bool | ||
bool | ||
note: required by a bound in `anyhow::__private::not` | ||
--> src/lib.rs | ||
| | ||
| pub fn not(cond: impl Bool) -> bool { | ||
| ^^^^ required by this bound in `not` | ||
|
||
error[E0277]: the trait bound `&DerefBool: __private::not::Bool` is not satisfied | ||
--> tests/ui/ensure-nonbool.rs:34:13 | ||
| | ||
6 | struct DerefBool(bool); | ||
| ^^^^^^^^^^^^^^^^ must implement `Not` | ||
note: the trait `Not` must be implemented | ||
--> $RUST/core/src/ops/bit.rs | ||
34 | ensure!(&db); | ||
| --------^^^- | ||
| | | | ||
| | the trait `__private::not::Bool` is not implemented for `&DerefBool` | ||
| required by a bound introduced by this call | ||
| | ||
| pub trait Not { | ||
| ^^^^^^^^^^^^^ | ||
= 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) | ||
note: required by a bound in `anyhow::__private::not` | ||
--> src/lib.rs | ||
| | ||
| pub fn not(cond: impl Bool) -> bool { | ||
| ^^^^ required by this bound in `not` | ||
help: consider dereferencing here | ||
| | ||
34 | ensure!(&*db); | ||
| + | ||
|
||
error[E0600]: cannot apply unary operator `!` to type `&DerefBool` | ||
--> tests/ui/ensure-nonbool.rs:25:5 | ||
error[E0277]: the trait bound `NotBool: __private::not::Bool` is not satisfied | ||
--> tests/ui/ensure-nonbool.rs:37:13 | ||
| | ||
37 | ensure!(nb); | ||
| --------^^- | ||
| | | | ||
| | the trait `__private::not::Bool` is not implemented for `NotBool` | ||
| required by a bound introduced by this call | ||
| | ||
25 | ensure!(&db); | ||
| ^^^^^^^^^^^^ cannot apply unary operator `!` | ||
= help: the following other types implement trait `__private::not::Bool`: | ||
&bool | ||
bool | ||
note: required by a bound in `anyhow::__private::not` | ||
--> src/lib.rs | ||
| | ||
= 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) | ||
| pub fn not(cond: impl Bool) -> bool { | ||
| ^^^^ required by this bound in `not` |