Skip to content

The "rc_buffer" lint is probably wrong for inner Vec types which implement Clone or Copy #6359

Open
@Fishrock123

Description

@Fishrock123

I previously landed a clarification that this lint is not always correct, depending on the use-case: #6090

Today I discovered that Rc::make_mut() and Arc::make_mut() exist for Rc<T: Clone> and Arc<T: Clone> respectively.

The rc_buffer lint says that you can only get a mutable reference if there are no mutable references or else panic, which is not true due to these functions. Copy-on-write is perfectly reasonable for types which are Clone. See also http-rs/tide#747.

I'm willing to make a change to only have this lint apply when T is not Clone if someone can point me in the direction of how to do that. It looks like there are 4 lint sites, two of which are for slices. The lint should also be updated to mention make_mut, which could be done either in the same PR or separately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions