Skip to content

match_as_ref might suggest invalid code #15932

@samueltardieu

Description

@samueltardieu

Summary

Copied from #15928 (review)

    let _: Option<&u32> = match Some(0) {
        //~^ match_as_ref
        None => None,
        Some(ref mut v) => Some(v),
    };

will suggest replacing by

    let _: Option<&u32> = Some(0).as_mut();

which doesn't have the right type (Option<&mut u32> instead of Option<&u32>).

Version


Additional Labels

@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions