Restore compatibility back to 1.31

This commit is contained in:
David Tolnay 2020-05-30 23:46:29 -07:00
parent 87dce0533a
commit 527c9efce0
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 20 additions and 0 deletions

View File

@ -61,6 +61,10 @@ fn main() {
println!("cargo:rustc-cfg=span_locations");
}
if version.minor < 39 {
println!("cargo:rustc-cfg=no_bind_by_move_pattern_guard");
}
if version.minor >= 45 {
println!("cargo:rustc-cfg=hygiene");
}

View File

@ -53,6 +53,7 @@ impl TokenStream {
fn push_token(&mut self, token: TokenTree) {
// https://github.com/alexcrichton/proc-macro2/issues/235
match token {
#[cfg(not(no_bind_by_move_pattern_guard))]
TokenTree::Literal(crate::Literal {
#[cfg(wrap_proc_macro)]
inner: crate::imp::Literal::Fallback(literal),
@ -62,6 +63,21 @@ impl TokenStream {
}) if literal.text.starts_with('-') => {
push_negative_literal(self, literal);
}
#[cfg(no_bind_by_move_pattern_guard)]
TokenTree::Literal(crate::Literal {
#[cfg(wrap_proc_macro)]
inner: crate::imp::Literal::Fallback(literal),
#[cfg(not(wrap_proc_macro))]
inner: literal,
..
}) => {
if literal.text.starts_with('-') {
push_negative_literal(self, literal);
} else {
self.inner
.push(TokenTree::Literal(crate::Literal::_new_stable(literal)));
}
}
_ => self.inner.push(token),
}