Skip to content

Incorrect report of: call to unsafe function #18850

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
dream-dasher opened this issue Jan 6, 2025 · 1 comment
Closed

Incorrect report of: call to unsafe function #18850

dream-dasher opened this issue Jan 6, 2025 · 1 comment
Labels
C-bug Category: bug

Comments

@dream-dasher
Copy link

The attached code incorrectly (?) reports a call to an unsafe function.
This is only shown in-IDE (Zed or Helix). It is not shown with cargo check or cargo clippy.
The code in question is just a call to produce a new array, with populated values.
(There is no visible issue at runtime.)

I was able to get the code down to what looks like any vec of arrays.

In-IDE error:

rust-analyzer: call to unsafe function is unsafe and requires an unsafe function or block

Minimal-Example-Helix:
Image
Helix:
Image
Zed:
Image

with Zed or Helix:

rust-analyzer 1.86.0-nightly (b3b368a1 2025-01-05)
rustc 1.86.0-nightly (b3b368a18 2025-01-05)
Zed 0.167.1 – /Applications/Zed.app
helix 25.1 (dabfb6ce)

fn main() {
        let an_array: [bool; 3] = [false; 3];
        let vec_of_arrays = vec![an_array];
        print!("{:?}", vec_of_arrays);
}

Here's the minimal example as a cargo-script: dbg_incorrect-unsafe-error-minimal.rs
And (probably not needed) here's the orignating non-minimal example as a cargo-script: dbg_incorrect-unsafe-error.rs
(I realize that rust-analyzer doesn't yet work with cargo-script at the time of posting. But hopefully soon! Figured it would still be best practice. :)

@dream-dasher dream-dasher added the C-bug Category: bug label Jan 6, 2025
@Veykril
Copy link
Member

Veykril commented Jan 6, 2025

Duplicate of #18842

@Veykril Veykril marked this as a duplicate of #18842 Jan 6, 2025
@Veykril Veykril closed this as completed Jan 6, 2025
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