Skip to content

fix(or_fun_call): respect MSRV for unwrap_or_default suggestion #14885

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

poglesbyg
Copy link

changelog: [unwrap_or_default]: respect MSRV by not suggesting the method when MSRV is below 1.16

The `unwrap_or_default()` method was introduced in Rust 1.16, but the lint was
suggesting it even when the MSRV was set to 1.15 or lower. This change adds an
MSRV check to ensure we only suggest `unwrap_or_default()` when the MSRV is at
least 1.16.

The fix:
1. Adds MSRV check in `check_unwrap_or_default` using `msrvs::STR_REPEAT` (Rust 1.16)
2. Adds MSRV parameter to the `check` function signature
3. Updates the call site to pass the MSRV parameter

Fixes rust-lang#14876 (unwrap_or_default MSRV issue)
@rustbot
Copy link
Collaborator

rustbot commented May 24, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label May 24, 2025
@rustbot

This comment has been minimized.

The `unwrap_or_default()` method was introduced in Rust 1.16, but the lint was
suggesting it even when the MSRV was set to 1.15 or lower. This change adds an
MSRV check to ensure we only suggest `unwrap_or_default()` when the MSRV is at
least 1.16.

The fix:
1. Adds MSRV check in `check_unwrap_or_default` using `msrvs::STR_REPEAT` (Rust 1.16)
2. Adds MSRV parameter to the `check` function signature
3. Updates the call site to pass the MSRV parameter
4. Adds `#[allow(clippy::too_many_arguments)]` to handle the linter warning

Fixes rust-lang#14876 (unwrap_or_default MSRV issue)
@poglesbyg poglesbyg closed this May 24, 2025
@poglesbyg poglesbyg reopened this May 24, 2025
…lang#14876

Your branch is ahead of 'origin/Result--unwrap_or_default()-suggested-for-MSRV-<-1.16-rust-lang#14876' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
	modified:   clippy_lints/src/methods/or_fun_call.rs
@rustbot

This comment has been minimized.

…lang#14876

Your branch is up to date with 'origin/Result--unwrap_or_default()-suggested-for-MSRV-<-1.16-rust-lang#14876'.

Changes to be committed:
	modified:   clippy_lints/src/methods/or_fun_call.rs
@rustbot
Copy link
Collaborator

rustbot commented May 24, 2025

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please remove them as they will spam the issue with references to the commit.

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.

3 participants