-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
"extern blocks must be unsafe" for 2024 edition #4218
Comments
My first impression is that this is actually a Rustc bug. I will get back to this as soon as I know more. While familiarizing myself with the 2024 editions, I also noticed that the attributes |
After some investigation, I don't believe there is anything that rustc can do to avoid this. It uses hygiene data of the spans to determine which edition something is from, and because of the behavior with @daxpedda Would you be willing to try to find some way to adjust One option is to avoid calling Another option, and I'm not certain this is correct, is to use diff --git a/crates/backend/src/codegen.rs b/crates/backend/src/codegen.rs
index e5f3cfb9..d5d14743 100644
--- a/crates/backend/src/codegen.rs
+++ b/crates/backend/src/codegen.rs
@@ -1894,9 +1894,9 @@ fn respan(input: TokenStream, span: &dyn ToTokens) -> TokenStream {
for (i, token) in spans.into_iter().enumerate() {
if i == 0 {
- first_span = token.span();
+ first_span = Span::call_site().located_at(token.span());
}
- last_span = token.span();
+ last_span = Span::call_site().located_at(token.span());
}
let mut new_tokens = Vec::new(); I'm not familiar with wasm-bindgen, so I don't know how to test that this still gives the kinds of error messages that you want. |
Thank you for looking this deeply into it and even suggesting a solution @ehuss. I'm going to take the lazy route here and simply add |
Ah! I was going to suggest this, but I saw |
Indeed you are right, I was reading the reference from v1.57 and assumed that it supports
|
Does #4259 actually do what it says it does? I tried out the PR and I still get the same error, and there is no mention of |
No, I changed the OP in #4259 to reflect the actual change. It applies the diff from #4218 (comment).
How did you try it? It works for me locally. |
Okay, while trying to build a minimal example, the error disappeared, and then it disappeared in the larger project aswell. Sorry, I was trying to use the patch in a larger project and had to work with a lot of patches to dependencies and tooling. But I must have missed something, and with the discrepancy in the PR description and my lack of proc macro knowledge, I was a little too eager to jump to conclusions. Sorry for the inconvenience. |
Describe the Bug
wasm_bindgen
attribute doesn't work for extern blocks in 2024 edition.Steps to Reproduce
rustc 1.84.0-nightly
and configure project to use 2024 edition.Expected Behavior
The example should compile.
Actual Behavior
Note: Adding the unsafe keyword to the extern block doesn't help, same error.
The text was updated successfully, but these errors were encountered: