Skip to content

lint for unwrap_or gives half expanded macro code #1628

Closed
@TeXitoi

Description

@TeXitoi
fn main() {
    let _: Vec<i32> = None.unwrap_or(vec![]);
}

gives

warning: use of `unwrap_or` followed by a function call
 --> src/main.rs:2:23
  |
2 |     let _: Vec<i32> = None.unwrap_or(vec![]);
  |                       ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(or_fun_call)] on by default
help: try this
  |     let _: Vec<i32> = None.unwrap_or_else(|| < [ _ ] > :: into_vec ( box [ $ ( $ x ) , * ] ));
  = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call

The suggestion looks like half expanded macro. It does not compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-macrosType: Issues with macros and macro expansionT-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions