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)) => {
|
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(expr)) => {
|
||||||
// In valid code the value always ends up as a single literal. Otherwise, a dummy
|
// In valid code the value always ends up as a single literal. Otherwise, a dummy
|
||||||
// literal suffices because the error is handled elsewhere.
|
// literal suffices because the error is handled elsewhere.
|
||||||
let lit = if let ExprKind::Lit(token_lit) = expr.kind {
|
let lit = if let ExprKind::Lit(token_lit) = expr.kind
|
||||||
match Lit::from_token_lit(token_lit, expr.span) {
|
&& let Ok(lit) = Lit::from_token_lit(token_lit, expr.span)
|
||||||
Ok(lit) => lit,
|
{
|
||||||
Err(_err) => Lit {
|
lit
|
||||||
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
|
|
||||||
kind: LitKind::Err,
|
|
||||||
span: DUMMY_SP,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Lit {
|
Lit {
|
||||||
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
|
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue