Skip to content
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

In uninit checking, add fallback for polymorphic types #10553

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

Noratrieb
Copy link
Member

After #10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit).

fixes #10551

changelog: [uninit_vec]: fix false positive for polymorphic types
changelog: [uninit_assumed_init]: fix false positive for polymorphic types

@rustbot
Copy link
Collaborator

rustbot commented Mar 26, 2023

r? @xFrednet

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 26, 2023
@Alexendoo Alexendoo linked an issue Mar 29, 2023 that may be closed by this pull request
@Alexendoo
Copy link
Member

Would be good to add a test for #10565 as well

@Alexendoo
Copy link
Member

Thanks for the follow up, looks good to me

@bors r+

@bors
Copy link
Contributor

bors commented Mar 29, 2023

📌 Commit 51b4d2a has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Mar 29, 2023

⌛ Testing commit 51b4d2a with merge c5011e9...

@bors
Copy link
Contributor

bors commented Mar 29, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing c5011e9 to master...

@bors bors merged commit c5011e9 into rust-lang:master Mar 29, 2023
@Noratrieb Noratrieb deleted the better-uninit branch March 29, 2023 19:04
@pickfire
Copy link
Contributor

pickfire commented Apr 8, 2023

I believe this still does not fully fix the issue, monoio still get false positive. https://github.com/bytedance/monoio/actions/runs/4635132256/jobs/8205680770?pr=157

struct Page<T> {
    // continued buffer of fixed size
    slots: Box<[MaybeUninit<Entry<T>>]>,
}

impl<T> Page<T> {
    fn new(size: usize, prev_len: usize) -> Self {
        let mut buffer = Vec::with_capacity(size);
        unsafe { buffer.set_len(size) };
        let slots = buffer.into_boxed_slice();
        Self {
            slots,
        }
    }
}

I am using clippy 0.1.70 (23ee2af 2023-04-07).

@Alexendoo Alexendoo added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 8, 2023
@Alexendoo
Copy link
Member

The fix is not yet available on nightly, it will be in the one after rust-lang/rust#110003 is merged

I'll add a beta-nominated label to ensure it's in the same release as #10520, not sure how that works out timing wise

@flip1995
Copy link
Member

This will get into the same beta/stable version as #10520. No action required AFAICT.

@flip1995 flip1995 removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uninit_vec FP on Vec<MaybeUninit<T>> False positive for uninit lint
8 participants