Skip to content

Result::unwrap_or_default() suggested for MSRV < 1.16 #14876

Open
@samueltardieu

Description

@samueltardieu

Summary

Result::unwrap_or_default() should not be suggested if the MSRV is not at least 1.16.

Reproducer

I tried this code:

#[clippy::msrv = "1.15"]
fn f(foo: Result<Vec<u32>, &'static str>) -> Vec<u32> {
    foo.unwrap_or(vec![])
}

fn main() {
}

I expected to see this happen: no suggestion of Result::unwrap_or_default()

Instead, this happened:

5 |     foo.unwrap_or(vec![])
  |         ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()`

Version

rustc 1.89.0-nightly (2eef47813 2025-05-22)
binary: rustc
commit-hash: 2eef47813f25df637026ce3288880e5c587abd92
commit-date: 2025-05-22
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Additional Labels

@rustbot label +I-suggestion-causes-error "+good first issue"

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions