- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
clippy warns if one tries to use a type like Rc<Vec<T>>, e.g.
Arc<Vec<u8>>
^^^^^^^^^^^^ help: try: `Arc<[u8]>`
This is dangerous as creating a Rc<[T]> causes a memcpy of the whole memory area with all the elements, while creating an Rc<Vec<T>> simply copies over the 3 pointers inside the Vec without copying all the elements.
A better suggestion would probably be Rc<Box<[T]>> as that has the same runtime behaviour, but even independent of that it can be useful to have a Vec inside an Rc / Arc in combination with the make_mut() / get_mut() API.
The lint should probably be at least disabled by default.
The same also applies to Rc<String> vs Rc<str>.
little-dude
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy