-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enabling the nightly
feature can be a breaking change
#67
Comments
FWIW this is where |
How about |
@kdy1 perhaps yeah, but this sort of largely an issue for the |
I thought If the only difference between them is resolving, I think
fn wrap_in_const<T: Into<TokenStream>>(const_name: &str, item: T) -> proc_macro::TokenStream {
let item = Quote::new(Span::def_site()).quote_with(smart_quote!(
Vars {
item: item.into(),
// CONST_NAME: Ident::new(const_name, call_site()),
},
{
extern crate swc_common;
extern crate std;
item
}
));
item.into()
} This does not work with |
This avoids breakage when deriving `StructOpt` when `proc_macro2`'s nightly feature is enabled. See dtolnay/proc-macro2#67 for details.
This avoids breakage when deriving `StructOpt` when `proc_macro2`'s nightly feature is enabled. See dtolnay/proc-macro2#67 for details.
This avoids breakage when deriving `StructOpt` when `proc_macro2`'s nightly feature is enabled. See dtolnay/proc-macro2#67 for details.
This avoids breakage when deriving `StructOpt` when `proc_macro2`'s nightly feature is enabled. See dtolnay/proc-macro2#67 for details.
This avoids breakage when deriving `StructOpt` when `proc_macro2`'s nightly feature is enabled. See dtolnay/proc-macro2#67 for details.
I can see how defaulting to But I think that hewing as close as possible to macros 1.1 semantics is not the best way to build experience with our vision for macros 2.0. I have found |
I just had this exact issue but it seems not only the spans matter.
These disappear if I switch back to the non-nightly version. I think there are going to be lots of problems like this if anyone publishes a crate with the nightly feature as a dependency. For example if you would publish a new version of the futures-await crate based on the current master branch, it would break several other crates. My suggestion is to remove this feature from this crate and publish it separately, that way some dependencies could use the stable and some the nightly version until every incompatibilities are solved. |
This avoids breakage when deriving `StructOpt` when `proc_macro2`'s nightly feature is enabled. See dtolnay/proc-macro2#67 for details.
@ngg oh dear! Do you think you'd be able to minimize the example to see where the |
I will have some time on the weekend, I'll try to minimize it. |
I could reduce the The minimal dependency-free example looks like: #[proc_macro]
pub fn buggy_macro(_: TokenStream) -> TokenStream {
TokenNode::Literal(Literal::i32(-1)).into()
} Something like this is generated by #[proc_macro]
pub fn buggy_macro(_: TokenStream) -> TokenStream {
let x = -1i32;
quote!(#x).into()
} |
Ok awesome, thanks for the reduction @ngg! I've opened an upstream Rust issue for that, and depending on the outcome I don't mind implementing it. |
The dtolnay/quote#65 workaround fixes both kind of errors in |
I think this'll get fixed as #71 propagates |
I've seen a number of crates now where when the
nightly
feature is enabled the crate's compilation breaks due to procedural macros. This typically happens around resolution in macro expansion and has to do primarily withquote!
I believe.If the
nightly
feature is disabled then everything is unhygienic and I think works with the equivalent ofSpan::call_site()
, meaning that all the tokens produced byquote!
ended up morally being used withSpan::call_site()
. Whennightly
is enabled, however, thequote!
macro is actually under the hood usingSpan::def_site()
everywhere (it was basically just ignored without thenightly
feature).tl;dr; tokens produced by
quote!
useSpan::call_site()
whennightly
is not enabled, andSpan::def_site()
whennightly
is enabled@dtolnay do you have thoughts on this? Do you think we should, while
Span
is unstable, move thequote
crate to usingSpan::call_site()
by default?The text was updated successfully, but these errors were encountered: