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

[WIP] Extend uninit_assumed_init lint to cover more cases #5228

Conversation

krishna-veerareddy
Copy link
Contributor

Currently uninit_assumed_init doesn't lint when assume_init is
invoked on a MaybeUninit<_> variable so extending it to cover that
case.

Fixes #4765

changelog: Extend uninit_assumed_init to cover more cases

Currently `uninit_assumed_init` doesn't lint when `assume_init` is
invoked on a `MaybeUninit<_>` variable so extending it to cover that
case.
@krishna-veerareddy krishna-veerareddy changed the title Extend uninit_assumed_init lint to cover more cases [WIP] Extend uninit_assumed_init lint to cover more cases Feb 26, 2020
let _: (MaybeUninit<usize>, MaybeUninit<bool>) = unsafe { x.assume_init() };

let x: MaybeUninit<(MaybeUninit<usize>, [MaybeUninit<bool>; 2])> = MaybeUninit::uninit();
let _: (MaybeUninit<usize>, [MaybeUninit<bool>; 2]) = unsafe { x.assume_init() };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a false-positive check here, e.g.

let x: MaybeUninit<usize> = MaybeUninit::uninit();
let _ = unsafe {
    x.as_mut_ptr().write(42usize);
    x.assume_init()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked it as WIP as I was just thinking about that. Will need to detect cases where the MaybeUninit variable is initialized before a call to assume_init and ignore that case.

@flip1995 flip1995 added the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Mar 3, 2020
@flip1995
Copy link
Member

Thanks for contributing to Clippy! Sadly this PR was not updated in quite some time. If you waited on input from a reviewer, we're sorry that this fell under the radar. If you want to continue to work on this, just reopen the PR and/or ping a reviewer.

@flip1995 flip1995 closed this May 25, 2020
@flip1995 flip1995 added S-inactive-closed Status: Closed due to inactivity and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive-closed Status: Closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uninit_assumed_init lint does not recognize trivial misuse
3 participants