The previous Compiler behaviour appears to have been broken, in that it
would return a non-raw string literal, so it was replaced with the
fallback code from quote [1].
[1]: eeabf0d42e/src/runtime.rs (L409-L422)
On 1.31.0:
error[E0277]: the type `std::cell::UnsafeCell<std::option::Option<syntax::tokenstream::TokenStream>>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
--> tests/marker.rs:9:13
|
9 | assert_implemented::<$ty>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<std::option::Option<syntax::tokenstream::TokenStream>>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary
...
74 | / assert_unwind_safe! {
75 | | Delimiter
76 | | Group
77 | | Ident
... |
84 | | TokenTree
85 | | }
| |_____- in this macro invocation
|
= help: within `(syntax::parse::token::Nonterminal, syntax::parse::token::LazyTokenStream)`, the trait `std::panic::RefUnwindSafe` is not implemented for `std::cell::UnsafeCell<std::option::Option<syntax::tokenstream::TokenStream>>`
= note: required because it appears within the type `std::cell::RefCell<std::option::Option<syntax::tokenstream::TokenStream>>`
= note: required because it appears within the type `rustc_data_structures::sync::Lock<std::option::Option<syntax::tokenstream::TokenStream>>`
= note: required because it appears within the type `syntax::parse::token::LazyTokenStream`
= note: required because it appears within the type `(syntax::parse::token::Nonterminal, syntax::parse::token::LazyTokenStream)`
= note: required because of the requirements on the impl of `std::panic::UnwindSafe` for `std::rc::Rc<(syntax::parse::token::Nonterminal, syntax::parse::token::LazyTokenStream)>`
= note: required because it appears within the type `syntax::parse::token::Token`
= note: required because it appears within the type `syntax::tokenstream::TokenTree`
= note: required because it appears within the type `syntax::tokenstream::TokenStreamKind`
= note: required because it appears within the type `syntax::tokenstream::TokenStream`
= note: required because it appears within the type `proc_macro::TokenStream`
= note: required because it appears within the type `proc_macro2:👿:DeferredTokenStream`
= note: required because it appears within the type `proc_macro2:👿:TokenStream`
= note: required because it appears within the type `proc_macro2::TokenStream`
note: required by `unwind_safe::TokenStream::assert_implemented`
--> tests/marker.rs:8:13
|
8 | fn assert_implemented<T: $($marker +)+>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
74 | / assert_unwind_safe! {
75 | | Delimiter
76 | | Group
77 | | Ident
... |
84 | | TokenTree
85 | | }
| |_____- in this macro invocation
On compilers prior to 1.45 where this is not stable, these fall back to
returning the span associated with resolution behavior, since the source
location is only cosmetic. This is a reversal of the previous fallback
implementation, which preserved source location because it does not
track resolution location. The differnce is only observable with
`span_locations` enabled.
These methods were stabilized in Rust in
https://github.com/rust-lang/rust/pull/69041
This message will appear on 1.22 through 1.26. Before 1.22, the build.rs
does not compile. On 1.27 through 1.30 it never runs because editions
are detected as unstable.
Before this commit, enabling procmacro2_semver_exempt would disable
wrap_proc_macro, meaning that real spans would not be preserved by proc
macros. One would also need to enable the "nightly" feature in order to
preserve spans when using procmacro2_semver_exempt.
This commit automatically enables wrap_proc_macro when building with
procmacro2_semver_exempt on a nightly compiler.
procmacro2_semver_exempt is working on rust < 1.29, but
since 1.29, proc_macro2 forward to proc_macro even when
procmacro2_semver_exempt is set, which require a nightly
compiler
Our build script has:
if cfg!(procmacro2_semver_exempt) {
println!("cargo:rustc-cfg=super_unstable");
}
But when proc-macro2 is built as a dependency of another crate in docs.rs, we
are seeing the builder invoke rustc with `--cfg super_unstable` but without
`--cfg procmacro2_semver_exempt`. The super_unstable flag is only set on that
one line, so procmacro2_semver_exempt should have also been set. Hopefully this
change will result in both flags being passed.
We will need to figure out how to set unstable flags only when building our own
docs.rs docs, not when building proc-macro2 as a dependency of a different
crate.
This commit detects the rustc version in the build script of proc-macro2
to determine whether the compiler supports the necessary backend APIs.
This should hopefully allow the crate to compile on stable by default
but have a better implementation on 1.30.0+ compilers.