Use Option::is_some_and
and Result::is_ok_and
in the compiler
This commit is contained in:
parent
70db836922
commit
fb0f74a8c9
87 changed files with 148 additions and 158 deletions
|
@ -72,7 +72,7 @@ fn has_cfg_or_cfg_attr(attrs: &[Attribute]) -> bool {
|
|||
// Therefore, the absence of a literal `cfg` or `cfg_attr` guarantees that
|
||||
// we don't need to do any eager expansion.
|
||||
attrs.iter().any(|attr| {
|
||||
attr.ident().map_or(false, |ident| ident.name == sym::cfg || ident.name == sym::cfg_attr)
|
||||
attr.ident().is_some_and(|ident| ident.name == sym::cfg || ident.name == sym::cfg_attr)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -845,7 +845,7 @@ impl<'a> Parser<'a> {
|
|||
//
|
||||
// `x.foo::<u32>>>(3)`
|
||||
let parsed_angle_bracket_args =
|
||||
segment.args.as_ref().map_or(false, |args| args.is_angle_bracketed());
|
||||
segment.args.as_ref().is_some_and(|args| args.is_angle_bracketed());
|
||||
|
||||
debug!(
|
||||
"check_trailing_angle_brackets: parsed_angle_bracket_args={:?}",
|
||||
|
|
|
@ -1188,7 +1188,7 @@ impl<'a> Parser<'a> {
|
|||
// `token.kind` should not be compared here.
|
||||
// This is because the `snapshot.token.kind` is treated as the same as
|
||||
// that of the open delim in `TokenTreesReader::parse_token_tree`, even if they are different.
|
||||
self.span_to_snippet(close_paren).map_or(false, |snippet| snippet == ")")
|
||||
self.span_to_snippet(close_paren).is_ok_and(|snippet| snippet == ")")
|
||||
{
|
||||
let mut replacement_err = errors::ParenthesesWithStructFields {
|
||||
span,
|
||||
|
@ -2078,7 +2078,7 @@ impl<'a> Parser<'a> {
|
|||
// Therefore, `token.kind` should not be compared here.
|
||||
if snapshot
|
||||
.span_to_snippet(snapshot.token.span)
|
||||
.map_or(false, |snippet| snippet == "]") =>
|
||||
.is_ok_and(|snippet| snippet == "]") =>
|
||||
{
|
||||
return Err(errors::MissingSemicolonBeforeArray {
|
||||
open_delim: open_delim_span,
|
||||
|
@ -2773,7 +2773,7 @@ impl<'a> Parser<'a> {
|
|||
// We might have a `=>` -> `=` or `->` typo (issue #89396).
|
||||
if TokenKind::FatArrow
|
||||
.similar_tokens()
|
||||
.map_or(false, |similar_tokens| similar_tokens.contains(&this.token.kind))
|
||||
.is_some_and(|similar_tokens| similar_tokens.contains(&this.token.kind))
|
||||
{
|
||||
err.span_suggestion(
|
||||
this.token.span,
|
||||
|
@ -3059,7 +3059,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
};
|
||||
|
||||
let is_shorthand = parsed_field.as_ref().map_or(false, |f| f.is_shorthand);
|
||||
let is_shorthand = parsed_field.as_ref().is_some_and(|f| f.is_shorthand);
|
||||
// A shorthand field can be turned into a full field with `:`.
|
||||
// We should point this out.
|
||||
self.check_or_expected(!is_shorthand, TokenType::Token(token::Colon));
|
||||
|
|
|
@ -699,7 +699,7 @@ impl<'a> Parser<'a> {
|
|||
// ```
|
||||
&& self
|
||||
.span_to_snippet(self.prev_token.span)
|
||||
.map_or(false, |snippet| snippet == "}")
|
||||
.is_ok_and(|snippet| snippet == "}")
|
||||
&& self.token.kind == token::Semi;
|
||||
let mut semicolon_span = self.token.span;
|
||||
if !is_unnecessary_semicolon {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue