Closed jordy25519 closed 4 years ago
Unfortunately I'm not familiar with this or the downstream crate enough to reproduce. Further investigation shows this works fine in v0.1.12 and in v0.1.13 breaks with the logs above. Relevant code:
(
IMPL
$( #[ $attr:meta ] )*
$vis:vis $name:ident => $($value:tt)+
) => (
$crate::paste::item! {
$vis struct [< $name Predicate >];
impl $crate::parser::Predicate<char> for [< $name Predicate >] {
fn eval(c: &char) -> bool {
match *c {
$($value)+ => true,
_ => false
}
}
}
$( #[ $attr ] )*
$vis type $name = $crate::parser::ExpectChar<[< $name Predicate >]>;
}
);
We must have been doing something to trigger a compiler bug before, but I don't know what. Even if you remove paste
that macro by itself produces exactly those same errors.
#[macro_export]
macro_rules! literals {
(
$(
$( #[ $attr:meta ] )*
$vis:vis $name:ident => $($value:expr)+;
)*
) => {
$(
$crate::literals!{
IMPL
$( #[ $attr ] )*
$vis $name => $($value)+
}
)*
};
(
IMPL
$( #[ $attr:meta ] )*
$vis:vis $name:ident => $($value:tt)+
) => {
$vis struct $name;
impl Predicate<char> for $name {
fn eval(c: &char) -> bool {
match *c {
$($value)+ => true,
_ => false
}
}
}
};
}
trait Predicate<T> {
fn eval(c: &T) -> bool;
}
literals! {
pub WhitespaceChar => '\u{0020}' | '\u{000D}' | '\u{000A}' | '\u{0009}';
pub SignChar => '+' | '-';
pub NegativeSignChar => '-';
pub EChar => 'E' | 'e';
pub OneToNineChar => '1' ..= '9';
pub DigitChar => '0' ..= '9';
pub DotChar => '.';
pub HexChar => '0' ..= '9' | 'a' ..= 'f' | 'A' ..= 'F';
pub DoubleQuoteChar => '"';
pub OpenCurlyBracketChar => '{';
pub CloseCurlyBracketChar => '}';
pub CommaChar => ',';
pub OpenSquareBracketChar => '[';
pub CloseSquareBracketChar => ']';
}
Fixed in lite-json
0.1.1 by https://github.com/xlc/lite-json/commit/783adb89a17412184747ed427118c026108448e9.
I don't know if there is anything we can do to intentionally trigger the same compiler bug that was causing it to work before, so I'll go ahead and close this now that the most recent version of lite-json does compile.
Looks like some backwards incompatible changes (semver breaking) were included in recent releases.
Since at least ~v0.1.15~v0.1.13 a down stream crate breaks with the following:
code link: https://github.com/xlc/lite-json/blob/82d863506b652790c49df9b0fa0ceda87f600ee0/parser/src/parser.rs#L237-L256
Update