Skip to content

clippy::for_loop_over_option triggers on quote! macro expansion #3696

Closed
@elinorbgr

Description

@elinorbgr

Using cargo clippy from stable: clippy 0.0.212 (b2601be 2018-11-27)

The lint apparently triggers on the result of expansion of quote!(..):

error: for loop over `$ single`, which is an `Option`. This is more readably written as an `if let` statement.
   --> wayland-scanner/src/common_gen.rs:794:21
    |
794 |       let prototype = quote! {
    |  _____________________^
795 | |         pub fn #fn_name#(<#generics>)*(&self, #(#args),*) -> #return_type #where_bounds
796 | |     };
    | |_____^
    |
    = note: #[deny(clippy::for_loop_over_option)] on by default
    = help: consider replacing `for $ first in $ single` with `if let Some($ first) = $ single`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#for_loop_over_option
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

The relevant code invoking quote!() is here: https://github.com/Smithay/wayland-rs/blob/5600194a6b614413194bfda09fc438fc5c45a792/wayland-scanner/src/common_gen.rs#L794-L796

I suppose this is a bug, given I don't expect clippy to trigger on the expansion of macros from my dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingT-macrosType: Issues with macros and macro expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions