1
Fork 0
rust/compiler/rustc_expand/src
Aaron Hill d874ecc84f
Use correct edition when parsing :pat matchers
As described in issue #85708, we currently do not properly decode
`SyntaxContext::root()` and `ExpnId::root()` from foreign crates. As a
result, when we decode a span from a foreign crate with
`SyntaxContext::root()`, we end up up considering it to have the edition
of the *current* crate, instead of the foreign crate where it was
originally created.

A full fix for this issue will be a fairly significant undertaking.
Fortunately, it's possible to implement a partial fix, which gives us
the correct edition-dependent behavior for `:pat` matchers when the
macro is loaded from another crate. Since we have the edition of the
macro's defining crate available, we can 'recover' from seeing a
`SyntaxContext::root()` and use the edition of the macro's defining
crate.

Any solution to issue #85708 must reproduce the behavior of this
targeted fix - properly preserving a foreign `SyntaxContext::root()`
means (among other things) preserving its edition, which by definition
is the edition of the foreign crate itself. Therefore, this fix moves us
closer to the correct overall solution, and does not expose any new
incorrect behavior to macros.
2021-05-29 13:09:14 -05:00
..
mbe Use correct edition when parsing :pat matchers 2021-05-29 13:09:14 -05:00
mut_visit ast: Stop using Mod in Crate 2021-02-18 13:07:49 +03:00
parse ast: Keep expansion status for out-of-line module items 2021-02-18 13:07:49 +03:00
tokenstream Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
base.rs Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister 2021-05-12 11:05:56 +00:00
build.rs Remove (lots of) dead code 2021-03-27 22:16:33 -04:00
config.rs Unify rustc and rustdoc parsing of cfg() 2021-05-03 12:49:43 -04:00
expand.rs Use local and remapped paths where appropriate 2021-05-05 15:31:28 +01:00
lib.rs remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
mbe.rs fix few typos 2021-04-19 15:57:08 +03:00
module.rs E0583: Include secondary path in error message 2021-05-06 09:40:05 +08:00
placeholders.rs ast/hir: Rename field-related structures 2021-03-16 11:41:24 +03:00
proc_macro.rs Implement span quoting for proc-macros 2021-05-12 00:51:31 -04:00
proc_macro_server.rs impl FromStr for proc_macro::Literal 2021-05-19 11:38:24 -07:00
tests.rs remove redundant closures (clippy::redundant_closure) 2021-01-03 13:34:24 +01:00