Skip to content

False possitive "this operation is unsafe" with web_sys #15642

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

Closed
konnorandrews opened this issue Sep 20, 2023 · 3 comments
Closed

False possitive "this operation is unsafe" with web_sys #15642

konnorandrews opened this issue Sep 20, 2023 · 3 comments
Labels
C-bug Category: bug

Comments

@konnorandrews
Copy link

konnorandrews commented Sep 20, 2023

The false positive was found for https://github.com/rustwasm/wasm-bindgen/blob/main/examples/console_log/src/lib.rs#L62.

Image showing the false positive error as reported in neovim.
image

To reproduce clone wasm-bindgen (or just download the console_log folder see following comment) and open the console_log crate in an editor. The false positive has been observed in both neovim and vscode for both the latest stable and nightly (0.3.1665 and 0.4.1667).

This is likely related to #14766, but I am not sure.

rust-analyzer version: 0.3.1665 and 0.4.1667

rustc version: rustc 1.72.1 (d5c2e9c34 2023-09-13)

relevant settings: Everything was default.

@konnorandrews konnorandrews added the C-bug Category: bug label Sep 20, 2023
@konnorandrews
Copy link
Author

konnorandrews commented Sep 21, 2023

After some more testing, it appears the issue only happens when the full wasm-bindgen git repo exists. If you extract the console_log crate to it's own folder outside of the wasm-bindgen workspace then the false positive doesn't appear. Additionally, the false positive happens both when the wasm-bindgen folder and the console_log folder (while in the wasm-bindgen folder) are opened as the root folder in vscode.

As such it appears the false positive is somehow related to cargo workspaces.

@konnorandrews
Copy link
Author

I have also not found any version of rust-analyzer (while using rustc 1.72.1) where this false positive doesn't appear.

@Veykril
Copy link
Member

Veykril commented Sep 21, 2023

This is caused by cyclic dependencies causing us to be unable to resolve the macros in web-sys properly.

[ERROR project_model::workspace] cyclic deps: wasm_bindgen_macro(Idx::<CrateData>(320)) -> wasm_bindgen(Idx::<CrateData>(299)), alternative path: wasm_bindgen(Idx::<CrateData>(299)) -> wasm_bindgen_macro(Idx::<CrateData>(320))
[ERROR project_model::workspace] cyclic deps: wasm_bindgen_macro(Idx::<CrateData>(320)) -> wasm_bindgen_futures(Idx::<CrateData>(318)), alternative path: wasm_bindgen_futures(Idx::<CrateData>(318)) -> js_sys(Idx::<CrateData>(139)) -> wasm_bindgen(Idx::<CrateData>(299)) -> wasm_bindgen_macro(Idx::<CrateData>(320))
[ERROR project_model::workspace] cyclic deps: wasm_bindgen_test_macro(Idx::<CrateData>(331)) -> wasm_bindgen_test(Idx::<CrateData>(328)), alternative path: wasm_bindgen_test(Idx::<CrateData>(328)) -> wasm_bindgen_test_macro(Idx::<CrateData>(331))
[ERROR project_model::workspace] cyclic deps: web_sys(Idx::<CrateData>(352)) -> js_sys(Idx::<CrateData>(139)), alternative path: js_sys(Idx::<CrateData>(139)) -> wasm_bindgen(Idx::<CrateData>(299)) -> wasm_bindgen_macro(Idx::<CrateData>(320)) -> web_sys(Idx::<CrateData>(352))
[ERROR project_model::workspace] cyclic deps: web_sys(Idx::<CrateData>(352)) -> wasm_bindgen(Idx::<CrateData>(299)), alternative path: wasm_bindgen(Idx::<CrateData>(299)) -> wasm_bindgen_macro(Idx::<CrateData>(320)) -> web_sys(Idx::<CrateData>(352))

#14167

@Veykril Veykril closed this as completed Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants