Skip to content

Commit d727fa2

Browse files
authored
using full path in the suggestion of clone_on_ref_ptr (#15561)
Fix: rust-lang/rust-clippy#15258 changelog: suggest full path in [`clone_on_ref_ptr`] to avoid "failed to resolve" error.
2 parents 9bfa95b + cfc9b8f commit d727fa2

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

clippy_lints/src/methods/clone_on_ref_ptr.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ pub(super) fn check(
2424
&& let Some(name) = cx.tcx.get_diagnostic_name(adt.did())
2525
{
2626
let caller_type = match name {
27-
sym::Rc => "Rc",
28-
sym::Arc => "Arc",
29-
sym::RcWeak | sym::ArcWeak => "Weak",
27+
sym::Rc => "std::rc::Rc",
28+
sym::Arc => "std::sync::Arc",
29+
sym::RcWeak => "std::rc::Weak",
30+
sym::ArcWeak => "std::sync::Weak",
3031
_ => return,
3132
};
3233
span_lint_and_then(

tests/ui/unnecessary_clone.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: using `.clone()` on a ref-counted pointer
22
--> tests/ui/unnecessary_clone.rs:23:5
33
|
44
LL | rc.clone();
5-
| ^^^^^^^^^^ help: try: `Rc::<bool>::clone(&rc)`
5+
| ^^^^^^^^^^ help: try: `std::rc::Rc::<bool>::clone(&rc)`
66
|
77
= note: `-D clippy::clone-on-ref-ptr` implied by `-D warnings`
88
= help: to override `-D warnings` add `#[allow(clippy::clone_on_ref_ptr)]`
@@ -11,25 +11,25 @@ error: using `.clone()` on a ref-counted pointer
1111
--> tests/ui/unnecessary_clone.rs:28:5
1212
|
1313
LL | arc.clone();
14-
| ^^^^^^^^^^^ help: try: `Arc::<bool>::clone(&arc)`
14+
| ^^^^^^^^^^^ help: try: `std::sync::Arc::<bool>::clone(&arc)`
1515

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

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

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

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

6161
error: aborting due to 9 previous errors
6262

0 commit comments

Comments
 (0)