Skip to content

call to unsafe function is unsafe and requires an unsafe function or block #19557

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
aurexav opened this issue Apr 10, 2025 · 13 comments · Fixed by #19558
Closed

call to unsafe function is unsafe and requires an unsafe function or block #19557

aurexav opened this issue Apr 10, 2025 · 13 comments · Fixed by #19558
Labels
Broken Window Bugs / technical debt to be addressed immediately

Comments

@aurexav
Copy link

aurexav commented Apr 10, 2025

Image

I don't think there is any unsafe code.

This is a serious regression in nightly and it's important to fix it before the next release.

@aurexav aurexav added the Broken Window Bugs / technical debt to be addressed immediately label Apr 10, 2025
@aurexav
Copy link
Author

aurexav commented Apr 10, 2025

A fresh installation resolves this issue, but I'm not certain why.

However, it reappears after a while.

@aurexav aurexav closed this as completed Apr 10, 2025
@aurexav aurexav reopened this Apr 10, 2025
@ChayimFriedman2
Copy link
Contributor

This is probably caused by an outdated version of rust-analyzer you use. See #18842.

@aurexav
Copy link
Author

aurexav commented Apr 10, 2025

This is probably caused by an outdated version of rust-analyzer you use. See #18842.

It's not installed locally. It was installed by the VSC plugin. However, I'm not sure if VSC update the package correctly. I've tried reinstalling the plugin, but the problem persists.

@ChayimFriedman2
Copy link
Contributor

I can't reproduce the problem (with a rust-analyzer prerelease version) on nightly or stable toolchain, so this is probably not a problem in r-a.

@aurexav
Copy link
Author

aurexav commented Apr 10, 2025

A fresh install of vscode-insiders also gets this error. Interesting.

@ChayimFriedman2
Copy link
Contributor

Do you also get the same error on a clean project with a call to vec![]?

@aurexav
Copy link
Author

aurexav commented Apr 10, 2025

Do you also get the same error on a clean project with a call to vec![]?

Image

But empty vec! works.

Image

@aurexav
Copy link
Author

aurexav commented Apr 10, 2025

rustup component add rust-analyzer resolves this issue, preventing the use of the one shipped with VSC extension.

@ChayimFriedman2
Copy link
Contributor

Weird, now I get the same error on rust-analyzer invocations of vec![].

@aurexav
Copy link
Author

aurexav commented Apr 10, 2025

Weird, now I get the same error on rust-analyzer invocations of vec![].

This is similar to the situation here. It seems quite unstable, appearing and disappearing randomly. All the solutions that I provided above are only temporary fixes.

@ChayimFriedman2
Copy link
Contributor

Found that sneaky bug!

@RReverser
Copy link

Thanks! I was very confused when Rust-Analyzer started marking functions like atan2 or asin as unsafe.

@Veykril
Copy link
Member

Veykril commented Apr 10, 2025

That bug probably marked half the standard library as unsafe. There is a new nightly release out with the fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Window Bugs / technical debt to be addressed immediately
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants