Skip to content

"if let &foo = bar" triggers match_ref_pats #532

Closed
@karyon

Description

@karyon

in servo, if let &DisplayItem::StackingContextClass(ref stacking_context) = kid { triggers match_ref_pats.

complete output:

/servo/components/gfx/paint_task.rs:519:17: 527:18 warning: instead of prefixing all patterns with `&`, you can dereference the expression: `if let ... = *kid {`, #[warn(match_ref_pats)] on by default
/servo/components/gfx/paint_task.rs:519                 if let &DisplayItem::StackingContextClass(ref stacking_context) = kid {
/servo/components/gfx/paint_task.rs:520                     build_from_stacking_context(properties,
/servo/components/gfx/paint_task.rs:521                                                 &stacking_context,
/servo/components/gfx/paint_task.rs:522                                                 &parent_origin,
/servo/components/gfx/paint_task.rs:523                                                 &transform,
/servo/components/gfx/paint_task.rs:524                                                 &perspective,
                                                                 ...
/servo/components/gfx/paint_task.rs:519:17: 527:18 help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#match_ref_pats

also, match-patterns where only one arm does the dereferencing also triggers it:

/servo/components/script/dom/htmlanchorelement.rs:62:9: 65:10 warning: instead of prefixing all patterns with `&`, you can dereference the expression: `match *name { ...`, #[warn(match_ref_pats)] on by default
/servo/components/script/dom/htmlanchorelement.rs:62         match name {
/servo/components/script/dom/htmlanchorelement.rs:63             &atom!("rel") => AttrValue::from_serialized_tokenlist(value),
/servo/components/script/dom/htmlanchorelement.rs:64             _ => self.super_type().unwrap().parse_plain_attribute(name, value),
/servo/components/script/dom/htmlanchorelement.rs:65         }
/servo/components/script/dom/htmlanchorelement.rs:62:9: 65:10 help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#match_ref_pats

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions