mirror of
https://gitee.com/openharmony/third_party_rust_proc-macro2
synced 2024-11-23 07:19:41 +00:00
Restore compatibility back to 1.31
This commit is contained in:
parent
87dce0533a
commit
527c9efce0
4
build.rs
4
build.rs
@ -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");
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user