-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Resolve $crate at the expansion-local crate #99445
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1722,13 +1722,6 @@ impl<'a> Resolver<'a> { | |
debug!("resolve_crate_root({:?})", ident); | ||
let mut ctxt = ident.span.ctxt(); | ||
let mark = if ident.name == kw::DollarCrate { | ||
// When resolving `$crate` from a `macro_rules!` invoked in a `macro`, | ||
// we don't want to pretend that the `macro_rules!` definition is in the `macro` | ||
// as described in `SyntaxContext::apply_mark`, so we ignore prepended opaque marks. | ||
// FIXME: This is only a guess and it doesn't work correctly for `macro_rules!` | ||
// definitions actually produced by `macro` and `macro` definitions produced by | ||
// `macro_rules!`, but at least such configurations are not stable yet. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may need to test the 3 combinations: macro_rules in macro_rules (existing), macro_rules inside macro, macro inside macro_rules. |
||
ctxt = ctxt.normalize_to_macro_rules(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: I removed this because it didn't change the behavior of any test (in the default compiler mode In general, I'm not certain how much of this arm is still necessary now that we're directly giving |
||
debug!( | ||
"resolve_crate_root: marks={:?}", | ||
ctxt.marks().into_iter().map(|(i, t)| (i.expn_data(), t)).collect::<Vec<_>>() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![feature(macro_metavar_expr)] | ||
|
||
#[macro_export] | ||
macro_rules! define_macro { | ||
($m:ident => $item:ident) => { | ||
macro_rules! $m { | ||
() => { | ||
$$crate::$item | ||
}; | ||
} | ||
}; | ||
} |
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.
Note to self: push the local change you made while testing to use
Span::fresh_expansion
rather thanwith_call_site_ctxt