This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
compiler/rustc_ast/src/attr Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -618,9 +618,12 @@ impl MetaItemKind {
618618 } ) => MetaItemKind :: list_from_tokens ( tokens. clone ( ) ) ,
619619 AttrArgs :: Delimited ( ..) => None ,
620620 AttrArgs :: Eq ( _, AttrArgsEq :: Ast ( expr) ) => match expr. kind {
621- ast:: ExprKind :: Lit ( token_lit) => Some ( MetaItemKind :: NameValue (
622- Lit :: from_token_lit ( token_lit, expr. span ) . expect ( "token_lit in from_attr_args" ) ,
623- ) ) ,
621+ ast:: ExprKind :: Lit ( token_lit) => {
622+ // Turn failures to `None`, we'll get parse errors elsewhere.
623+ Lit :: from_token_lit ( token_lit, expr. span )
624+ . ok ( )
625+ . map ( |lit| MetaItemKind :: NameValue ( lit) )
626+ }
624627 _ => None ,
625628 } ,
626629 AttrArgs :: Eq ( _, AttrArgsEq :: Hir ( lit) ) => Some ( MetaItemKind :: NameValue ( lit. clone ( ) ) ) ,
Original file line number Diff line number Diff line change 1+ #![ feature( rustc_attrs) ]
2+
3+ #![ rustc_dummy=5 z] //~ ERROR unexpected expression: `5z`
4+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: unexpected expression: `5z`
2+ --> $DIR/issue-104620.rs:3:16
3+ |
4+ LL | #![rustc_dummy=5z]
5+ | ^^
6+
7+ error: aborting due to previous error
8+
You can’t perform that action at this time.
0 commit comments