Skip to content

Regression in unwrap_or_default lint around vec! macro #16578

@RalfJung

Description

@RalfJung

rust-lang/rust#148190 caused a regression for the unwrap_or_default lint around the vec! macro. Code like this no longer triggers the lint:

    let with_new = Some(vec![1]);
    with_new.unwrap_or_else(Vec::new);

Curiously, adding a type annotation to the let brings the lint back (see the clippy test diff of that PR).

We weren't able to fully figure out why this happens, but the best lead was that the change in the vec! macro lowering confused expr_type_is_certain, making it no longer consider the type of with_new to be certain, thus silencing the lint.

Metadata

Metadata

Assignees

Labels

I-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions