

impl Not for ! by dtolnay · Pull Request #91122 · rust-lang/rust · GitHub
source link: https://github.com/rust-lang/rust/pull/91122
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The lack of this impl caused trouble for me in some degenerate cases of macro-generated code of the form if !$cond {...}
, even without feature(never_type)
on a stable compiler. Namely if $cond
contains a return
or break
or similar diverging expression, which would otherwise be perfectly legal in boolean position, the code previously failed to compile with:
error[E0600]: cannot apply unary operator `!` to type `!` --> library/core/tests/ops.rs:239:8 | 239 | if !return () {} | ^^^^^^^^^^ cannot apply unary operator `!`
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK