mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Test macros doing edition dependent parsing
This commit is contained in:
parent
2c32ee7cfa
commit
546eb6b530
8 changed files with 92 additions and 62 deletions
|
@ -348,7 +348,7 @@ fn parse_macro_expansion(
|
|||
) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)> {
|
||||
let _p = tracing::info_span!("parse_macro_expansion").entered();
|
||||
let loc = db.lookup_intern_macro_call(macro_file.macro_call_id);
|
||||
let edition = loc.def.edition;
|
||||
let def_edition = loc.def.edition;
|
||||
let expand_to = loc.expand_to();
|
||||
let mbe::ValueResult { value: (tt, matched_arm), err } =
|
||||
macro_expand(db, macro_file.macro_call_id, loc);
|
||||
|
@ -359,7 +359,7 @@ fn parse_macro_expansion(
|
|||
CowArc::Owned(it) => it,
|
||||
},
|
||||
expand_to,
|
||||
edition,
|
||||
def_edition,
|
||||
);
|
||||
rev_token_map.matched_arm = matched_arm;
|
||||
|
||||
|
|
|
@ -129,20 +129,7 @@ impl DeclarativeMacroExpander {
|
|||
_ => None,
|
||||
}
|
||||
};
|
||||
let toolchain = db.toolchain(def_crate);
|
||||
let new_meta_vars = toolchain.as_ref().map_or(false, |version| {
|
||||
REQUIREMENT.get_or_init(|| VersionReq::parse(">=1.76").unwrap()).matches(
|
||||
&base_db::Version {
|
||||
pre: base_db::Prerelease::EMPTY,
|
||||
build: base_db::BuildMetadata::EMPTY,
|
||||
major: version.major,
|
||||
minor: version.minor,
|
||||
patch: version.patch,
|
||||
},
|
||||
)
|
||||
});
|
||||
|
||||
let edition = |ctx: SyntaxContextId| {
|
||||
let ctx_edition = |ctx: SyntaxContextId| {
|
||||
let crate_graph = db.crate_graph();
|
||||
if ctx.is_root() {
|
||||
crate_graph[def_crate].edition
|
||||
|
@ -165,7 +152,7 @@ impl DeclarativeMacroExpander {
|
|||
DocCommentDesugarMode::Mbe,
|
||||
);
|
||||
|
||||
mbe::DeclarativeMacro::parse_macro_rules(&tt, edition, new_meta_vars)
|
||||
mbe::DeclarativeMacro::parse_macro_rules(&tt, ctx_edition)
|
||||
}
|
||||
None => mbe::DeclarativeMacro::from_err(mbe::ParseError::Expected(
|
||||
"expected a token tree".into(),
|
||||
|
@ -193,12 +180,7 @@ impl DeclarativeMacroExpander {
|
|||
DocCommentDesugarMode::Mbe,
|
||||
);
|
||||
|
||||
mbe::DeclarativeMacro::parse_macro2(
|
||||
args.as_ref(),
|
||||
&body,
|
||||
edition,
|
||||
new_meta_vars,
|
||||
)
|
||||
mbe::DeclarativeMacro::parse_macro2(args.as_ref(), &body, ctx_edition)
|
||||
}
|
||||
None => mbe::DeclarativeMacro::from_err(mbe::ParseError::Expected(
|
||||
"expected a token tree".into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue