-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
cfg_select!: parse unused branches
#149925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
cfg_select!: parse unused branches
#149925
Conversation
This comment has been minimized.
This comment has been minimized.
e00ad06 to
a118b81
Compare
| fn tts_to_mac_result<'cx, 'sess>( | ||
| ecx: &'cx mut ExtCtxt<'sess>, | ||
| site_span: Span, | ||
| tts: TokenStream, | ||
| span: Span, | ||
| ) -> Box<dyn MacResult + 'cx> { | ||
| match ExpandResult::from_tts(ecx, tts, site_span, span, Ident::with_dummy_span(sym::cfg_select)) | ||
| { | ||
| ExpandResult::Ready(x) => x, | ||
| _ => unreachable!("from_tts always returns Ready"), | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works around ParserAnyMacro not being exported from rustc_expand. Maybe it should be exported though?
| } | ||
| } | ||
|
|
||
| impl<'cx, 'sess> MacResult for CfgSelectResult<'cx, 'sess> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the MacResult trait has more methods, supporting macro expansion in more places (e.g. items within an impl or extern block). I've started a discussion at #t-lang > where can `cfg_select!` go to decide what we want to support, but we'll want at least expr/stmt/item.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
tracking issue: #115585
Emit parse errors that are found in the branches that are not selected, like e.g. how
#[cfg(false) { 1 ++ 2 }still emits a parse error even though the expression is never used by the program.