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

Fix false-positive manual_unwrap_or inside const fn #6917

Merged
merged 3 commits into from
Mar 17, 2021

Conversation

MysteryJump
Copy link
Contributor

Fixes #6898

changelog: Fix false-positive for manual_unwrap_or in const fn.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 16, 2021
lint_manual_unwrap_or(cx, expr);
if_chain! {
if let FnKind::ItemFn(_, _, header, _) = kind;
if !header.is_const();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to use in_constant in this case:

pub fn in_constant(cx: &LateContext<'_>, id: HirId) -> bool {

@Manishearth
Copy link
Member

Manishearth commented Mar 16, 2021

gonna r? @giraffate unless you want me to review this :) It looks okay at a glance!

@Manishearth
Copy link
Member

@bors delegate+

@bors
Copy link
Contributor

bors commented Mar 16, 2021

✌️ @MysteryJump can now approve this pull request

Copy link
Contributor

@giraffate giraffate left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks!

@Manishearth
Copy link
Member

@bors delegate=giraffate r=giraffate

oops, forgot delegate doesn't work that way, sorry @giraffate

@bors
Copy link
Contributor

bors commented Mar 17, 2021

✌️ @giraffate can now approve this pull request

@bors
Copy link
Contributor

bors commented Mar 17, 2021

📌 Commit 02ceeb5 has been approved by giraffate

@bors
Copy link
Contributor

bors commented Mar 17, 2021

⌛ Testing commit 02ceeb5 with merge 56161b2...

@bors
Copy link
Contributor

bors commented Mar 17, 2021

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: giraffate
Pushing 56161b2 to master...

@bors bors merged commit 56161b2 into rust-lang:master Mar 17, 2021
mgacek8 pushed a commit to mgacek8/rust-clippy that referenced this pull request Mar 17, 2021
…-fn, r=giraffate

Fix false-positive `manual_unwrap_or` inside const fn

Fixes rust-lang#6898

changelog:  Fix false-positive for manual_unwrap_or in const fn.
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.

manual_unwrap_or should not trigger inside const fn
5 participants