Factor out a repeated expression in lower_attr_args
.
This commit is contained in:
parent
8cfc8153da
commit
aa10aad1ac
1 changed files with 4 additions and 9 deletions
|
@ -948,15 +948,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(expr)) => {
|
||||
// In valid code the value always ends up as a single literal. Otherwise, a dummy
|
||||
// literal suffices because the error is handled elsewhere.
|
||||
let lit = if let ExprKind::Lit(token_lit) = expr.kind {
|
||||
match Lit::from_token_lit(token_lit, expr.span) {
|
||||
Ok(lit) => lit,
|
||||
Err(_err) => Lit {
|
||||
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
|
||||
kind: LitKind::Err,
|
||||
span: DUMMY_SP,
|
||||
},
|
||||
}
|
||||
let lit = if let ExprKind::Lit(token_lit) = expr.kind
|
||||
&& let Ok(lit) = Lit::from_token_lit(token_lit, expr.span)
|
||||
{
|
||||
lit
|
||||
} else {
|
||||
Lit {
|
||||
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue