Use Option::map_or instead of .map(..).unwrap_or(..)
This commit is contained in:
parent
d03fe84169
commit
a56bffb4f9
50 changed files with 67 additions and 79 deletions
|
@ -423,7 +423,7 @@ impl<'a> StripUnconfigured<'a> {
|
|||
|
||||
/// If attributes are not allowed on expressions, emit an error for `attr`
|
||||
pub fn maybe_emit_expr_attr_err(&self, attr: &Attribute) {
|
||||
if !self.features.map(|features| features.stmt_expr_attributes).unwrap_or(true) {
|
||||
if !self.features.map_or(true, |features| features.stmt_expr_attributes) {
|
||||
let mut err = feature_err(
|
||||
&self.sess.parse_sess,
|
||||
sym::stmt_expr_attributes,
|
||||
|
|
|
@ -500,7 +500,7 @@ fn inner_parse_loop<'root, 'tt>(
|
|||
if idx == len && item.sep.is_some() {
|
||||
// We have a separator, and it is the current token. We can advance past the
|
||||
// separator token.
|
||||
if item.sep.as_ref().map(|sep| token_name_eq(token, sep)).unwrap_or(false) {
|
||||
if item.sep.as_ref().map_or(false, |sep| token_name_eq(token, sep)) {
|
||||
item.idx += 1;
|
||||
next_items.push(item);
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ fn macro_rules_dummy_expander<'cx>(
|
|||
}
|
||||
|
||||
fn trace_macros_note(cx_expansions: &mut FxHashMap<Span, Vec<String>>, sp: Span, message: String) {
|
||||
let sp = sp.macro_backtrace().last().map(|trace| trace.call_site).unwrap_or(sp);
|
||||
let sp = sp.macro_backtrace().last().map_or(sp, |trace| trace.call_site);
|
||||
cx_expansions.entry(sp).or_default().push(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,10 @@ pub(super) fn parse(
|
|||
}
|
||||
_ => token.span,
|
||||
},
|
||||
tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span),
|
||||
tree => tree.as_ref().map_or(span, tokenstream::TokenTree::span),
|
||||
}
|
||||
}
|
||||
tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp),
|
||||
tree => tree.as_ref().map_or(start_sp, tokenstream::TokenTree::span),
|
||||
};
|
||||
if node_id != DUMMY_NODE_ID {
|
||||
// Macros loaded from other crates have dummy node ids.
|
||||
|
@ -250,7 +250,7 @@ fn parse_kleene_op(
|
|||
Some(op) => Ok(Ok((op, token.span))),
|
||||
None => Ok(Err(token)),
|
||||
},
|
||||
tree => Err(tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span)),
|
||||
tree => Err(tree.as_ref().map_or(span, tokenstream::TokenTree::span)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue