Skip to content

Commit aa10aad

Browse files
committed
Factor out a repeated expression in lower_attr_args.
1 parent 8cfc815 commit aa10aad

File tree

1 file changed

+4
-9
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+4
-9
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
948948
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(expr)) => {
949949
// In valid code the value always ends up as a single literal. Otherwise, a dummy
950950
// literal suffices because the error is handled elsewhere.
951-
let lit = if let ExprKind::Lit(token_lit) = expr.kind {
952-
match Lit::from_token_lit(token_lit, expr.span) {
953-
Ok(lit) => lit,
954-
Err(_err) => Lit {
955-
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),
956-
kind: LitKind::Err,
957-
span: DUMMY_SP,
958-
},
959-
}
951+
let lit = if let ExprKind::Lit(token_lit) = expr.kind
952+
&& let Ok(lit) = Lit::from_token_lit(token_lit, expr.span)
953+
{
954+
lit
960955
} else {
961956
Lit {
962957
token_lit: token::Lit::new(token::LitKind::Err, kw::Empty, None),

0 commit comments

Comments
 (0)