Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clippy_lints/src/methods/clone_on_ref_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ pub(super) fn check(
&& let Some(name) = cx.tcx.get_diagnostic_name(adt.did())
{
let caller_type = match name {
sym::Rc => "Rc",
sym::Arc => "Arc",
sym::RcWeak | sym::ArcWeak => "Weak",
sym::Rc => "std::rc::Rc",
sym::Arc => "std::sync::Arc",
sym::RcWeak => "std::rc::Weak",
sym::ArcWeak => "std::sync::Weak",
_ => return,
};
span_lint_and_then(
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/unnecessary_clone.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: using `.clone()` on a ref-counted pointer
--> tests/ui/unnecessary_clone.rs:23:5
|
LL | rc.clone();
| ^^^^^^^^^^ help: try: `Rc::<bool>::clone(&rc)`
| ^^^^^^^^^^ help: try: `std::rc::Rc::<bool>::clone(&rc)`
|
= note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::clone_on_ref_ptr)]`
Expand All @@ -11,25 +11,25 @@ error: using `.clone()` on a ref-counted pointer
--> tests/ui/unnecessary_clone.rs:28:5
|
LL | arc.clone();
| ^^^^^^^^^^^ help: try: `Arc::<bool>::clone(&arc)`
| ^^^^^^^^^^^ help: try: `std::sync::Arc::<bool>::clone(&arc)`

error: using `.clone()` on a ref-counted pointer
--> tests/ui/unnecessary_clone.rs:33:5
|
LL | rcweak.clone();
| ^^^^^^^^^^^^^^ help: try: `Weak::<bool>::clone(&rcweak)`
| ^^^^^^^^^^^^^^ help: try: `std::rc::Weak::<bool>::clone(&rcweak)`

error: using `.clone()` on a ref-counted pointer
--> tests/ui/unnecessary_clone.rs:38:5
|
LL | arc_weak.clone();
| ^^^^^^^^^^^^^^^^ help: try: `Weak::<bool>::clone(&arc_weak)`
| ^^^^^^^^^^^^^^^^ help: try: `std::sync::Weak::<bool>::clone(&arc_weak)`

error: using `.clone()` on a ref-counted pointer
--> tests/ui/unnecessary_clone.rs:44:33
|
LL | let _: Arc<dyn SomeTrait> = x.clone();
| ^^^^^^^^^ help: try: `Arc::<SomeImpl>::clone(&x)`
| ^^^^^^^^^ help: try: `std::sync::Arc::<SomeImpl>::clone(&x)`

error: using `clone` on type `T` which implements the `Copy` trait
--> tests/ui/unnecessary_clone.rs:49:5
Expand All @@ -56,7 +56,7 @@ error: using `.clone()` on a ref-counted pointer
--> tests/ui/unnecessary_clone.rs:108:14
|
LL | Some(try_opt!(Some(rc)).clone())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Rc::<u8>::clone(&try_opt!(Some(rc)))`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::rc::Rc::<u8>::clone(&try_opt!(Some(rc)))`

error: aborting due to 9 previous errors