-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
Rc<str>
is a fat pointer because str
is an unsized type, so to turn it into a thin pointer either Rc<Box<str>>
or Rc<String>
has to be used. Clippy seems to be perfectly fine with the latter, but the former triggers a false positive.
Lint Name
redundant_allocation
Reproducer
The following code:
use std::rc::Rc;
struct S {
s: Rc<Box<str>>,
}
Produces this warning:
warning: usage of `Rc<Box<str>>`
--> src/lib.rs:4:8
|
4 | s: Rc<Box<str>>,
| ^^^^^^^^^^^^
|
= note: `#[warn(clippy::redundant_allocation)]` on by default
= note: `Box<str>` is already on the heap, `Rc<Box<str>>` makes an extra allocation
= help: consider using just `Rc<str>` or `Box<str>`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_allocation
Version
rustc 1.61.0-nightly (5f4e06771 2022-03-10)
binary: rustc
commit-hash: 5f4e0677190b82e61dc507e3e72caf89da8e5e28
commit-date: 2022-03-10
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have