Re-format let-else per rustfmt update
This commit is contained in:
parent
67b0cfc761
commit
cc907f80b9
162 changed files with 1404 additions and 947 deletions
|
@ -1366,7 +1366,7 @@ pub fn parse_macro_name_and_helper_attrs(
|
|||
return None;
|
||||
}
|
||||
let Some(trait_attr) = list[0].meta_item() else {
|
||||
diag.emit_err(errors::NotAMetaItem {span: list[0].span()});
|
||||
diag.emit_err(errors::NotAMetaItem { span: list[0].span() });
|
||||
return None;
|
||||
};
|
||||
let trait_ident = match trait_attr.ident() {
|
||||
|
|
|
@ -313,9 +313,10 @@ impl<'a> StripUnconfigured<'a> {
|
|||
/// the attribute is incorrect.
|
||||
pub(crate) fn expand_cfg_attr(&self, attr: &Attribute, recursive: bool) -> Vec<Attribute> {
|
||||
let Some((cfg_predicate, expanded_attrs)) =
|
||||
rustc_parse::parse_cfg_attr(attr, &self.sess.parse_sess) else {
|
||||
return vec![];
|
||||
};
|
||||
rustc_parse::parse_cfg_attr(attr, &self.sess.parse_sess)
|
||||
else {
|
||||
return vec![];
|
||||
};
|
||||
|
||||
// Lint on zero attributes in source.
|
||||
if expanded_attrs.is_empty() {
|
||||
|
@ -365,7 +366,9 @@ impl<'a> StripUnconfigured<'a> {
|
|||
// Use the `#` in `#[cfg_attr(pred, attr)]` as the `#` token
|
||||
// for `attr` when we expand it to `#[attr]`
|
||||
let mut orig_trees = orig_tokens.into_trees();
|
||||
let TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _) = orig_trees.next().unwrap() else {
|
||||
let TokenTree::Token(pound_token @ Token { kind: TokenKind::Pound, .. }, _) =
|
||||
orig_trees.next().unwrap()
|
||||
else {
|
||||
panic!("Bad tokens for attribute {:?}", attr);
|
||||
};
|
||||
let pound_span = pound_token.span;
|
||||
|
@ -373,7 +376,9 @@ impl<'a> StripUnconfigured<'a> {
|
|||
let mut trees = vec![AttrTokenTree::Token(pound_token, Spacing::Alone)];
|
||||
if attr.style == AttrStyle::Inner {
|
||||
// For inner attributes, we do the same thing for the `!` in `#![some_attr]`
|
||||
let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) = orig_trees.next().unwrap() else {
|
||||
let TokenTree::Token(bang_token @ Token { kind: TokenKind::Not, .. }, _) =
|
||||
orig_trees.next().unwrap()
|
||||
else {
|
||||
panic!("Bad tokens for attribute {:?}", attr);
|
||||
};
|
||||
trees.push(AttrTokenTree::Token(bang_token, Spacing::Alone));
|
||||
|
|
|
@ -651,7 +651,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
ExpandResult::Ready(match invoc.kind {
|
||||
InvocationKind::Bang { mac, .. } => match ext {
|
||||
SyntaxExtensionKind::Bang(expander) => {
|
||||
let Ok(tok_result) = expander.expand(self.cx, span, mac.args.tokens.clone()) else {
|
||||
let Ok(tok_result) = expander.expand(self.cx, span, mac.args.tokens.clone())
|
||||
else {
|
||||
return ExpandResult::Ready(fragment_kind.dummy(span));
|
||||
};
|
||||
self.parse_ast_fragment(tok_result, fragment_kind, &mac.path, span)
|
||||
|
@ -704,7 +705,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
|||
self.cx.emit_err(UnsupportedKeyValue { span });
|
||||
}
|
||||
let inner_tokens = attr_item.args.inner_tokens();
|
||||
let Ok(tok_result) = expander.expand(self.cx, span, inner_tokens, tokens) else {
|
||||
let Ok(tok_result) = expander.expand(self.cx, span, inner_tokens, tokens)
|
||||
else {
|
||||
return ExpandResult::Ready(fragment_kind.dummy(span));
|
||||
};
|
||||
self.parse_ast_fragment(tok_result, fragment_kind, &attr_item.path, span)
|
||||
|
@ -1087,9 +1089,7 @@ impl InvocationCollectorNode for P<ast::Item> {
|
|||
|
||||
// Work around borrow checker not seeing through `P`'s deref.
|
||||
let (ident, span, mut attrs) = (node.ident, node.span, mem::take(&mut node.attrs));
|
||||
let ItemKind::Mod(_, mod_kind) = &mut node.kind else {
|
||||
unreachable!()
|
||||
};
|
||||
let ItemKind::Mod(_, mod_kind) = &mut node.kind else { unreachable!() };
|
||||
|
||||
let ecx = &mut collector.cx;
|
||||
let (file_path, dir_path, dir_ownership) = match mod_kind {
|
||||
|
|
|
@ -42,7 +42,8 @@ pub(super) fn failed_to_match_macro<'cx>(
|
|||
return result;
|
||||
}
|
||||
|
||||
let Some(BestFailure { token, msg: label, remaining_matcher, .. }) = tracker.best_failure else {
|
||||
let Some(BestFailure { token, msg: label, remaining_matcher, .. }) = tracker.best_failure
|
||||
else {
|
||||
return DummyResult::any(sp);
|
||||
};
|
||||
|
||||
|
|
|
@ -104,13 +104,10 @@ fn parse_depth<'sess>(
|
|||
span: Span,
|
||||
) -> PResult<'sess, usize> {
|
||||
let Some(tt) = iter.next() else { return Ok(0) };
|
||||
let TokenTree::Token(token::Token {
|
||||
kind: token::TokenKind::Literal(lit), ..
|
||||
}, _) = tt else {
|
||||
return Err(sess.span_diagnostic.struct_span_err(
|
||||
span,
|
||||
"meta-variable expression depth must be a literal"
|
||||
));
|
||||
let TokenTree::Token(token::Token { kind: token::TokenKind::Literal(lit), .. }, _) = tt else {
|
||||
return Err(sess
|
||||
.span_diagnostic
|
||||
.struct_span_err(span, "meta-variable expression depth must be a literal"));
|
||||
};
|
||||
if let Ok(lit_kind) = LitKind::from_token_lit(*lit)
|
||||
&& let LitKind::Int(n_u128, LitIntType::Unsuffixed) = lit_kind
|
||||
|
|
|
@ -182,9 +182,7 @@ pub(super) fn transcribe<'a>(
|
|||
LockstepIterSize::Constraint(len, _) => {
|
||||
// We do this to avoid an extra clone above. We know that this is a
|
||||
// sequence already.
|
||||
let mbe::TokenTree::Sequence(sp, seq) = seq else {
|
||||
unreachable!()
|
||||
};
|
||||
let mbe::TokenTree::Sequence(sp, seq) = seq else { unreachable!() };
|
||||
|
||||
// Is the repetition empty?
|
||||
if len == 0 {
|
||||
|
@ -399,7 +397,9 @@ fn lockstep_iter_size(
|
|||
}
|
||||
TokenTree::MetaVarExpr(_, expr) => {
|
||||
let default_rslt = LockstepIterSize::Unconstrained;
|
||||
let Some(ident) = expr.ident() else { return default_rslt; };
|
||||
let Some(ident) = expr.ident() else {
|
||||
return default_rslt;
|
||||
};
|
||||
let name = MacroRulesNormalizedIdent::new(ident);
|
||||
match lookup_cur_matched(name, interpolations, repeats) {
|
||||
Some(MatchedSeq(ads)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue