Fix a bug in MBE expansion that arose from incorrect fixing of an older bug in MBE

Specifically, #18744 was the PR that was supposed to fix the old bug, but it fixed it incorrectly (and didn't add a test!) The underlying reason was that we marked metavariables in expansions as joint if they were joint in the macro call, which is incorrect.

This wrong fix causes other bug, #19497, which this PR fixes by removing the old (incorrect) fix.
This commit is contained in:
Chayim Refael Friedman 2025-04-01 19:21:01 +03:00
parent df0174e988
commit 3953b604ce
7 changed files with 107 additions and 11 deletions

View file

@ -1979,3 +1979,51 @@ fn f() {
"#]],
);
}
#[test]
fn semicolon_does_not_glue() {
check(
r#"
macro_rules! bug {
($id: expr) => {
true
};
($id: expr; $($attr: ident),*) => {
true
};
($id: expr; $($attr: ident),*; $norm: expr) => {
true
};
($id: expr; $($attr: ident),*;; $print: expr) => {
true
};
($id: expr; $($attr: ident),*; $norm: expr; $print: expr) => {
true
};
}
let _ = bug!(a;;;test);
"#,
expect![[r#"
macro_rules! bug {
($id: expr) => {
true
};
($id: expr; $($attr: ident),*) => {
true
};
($id: expr; $($attr: ident),*; $norm: expr) => {
true
};
($id: expr; $($attr: ident),*;; $print: expr) => {
true
};
($id: expr; $($attr: ident),*; $norm: expr; $print: expr) => {
true
};
}
let _ = true;
"#]],
);
}

View file

@ -582,8 +582,8 @@ macro_rules! arbitrary {
}
impl <A: Arbitrary> $crate::arbitrary::Arbitrary for Vec<A> {
type Parameters = RangedParams1<A::Parameters>;
type Strategy = VecStrategy<A::Strategy>;
type Parameters = RangedParams1<A::Parameters> ;
type Strategy = VecStrategy<A::Strategy> ;
fn arbitrary_with(args: Self::Parameters) -> Self::Strategy { {
let product_unpack![range, a] = args;
vec(any_with::<A>(a), range)