Skip to content

Commit ed85443

Browse files
committed
Update compiler/rustc_hir_typeck/src/method/suggest.rs
1 parent 49bd163 commit ed85443

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3316,7 +3316,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33163316
self.tcx
33173317
.non_blanket_impls_for_ty(trait_pred.def_id(), trait_pred.self_ty())
33183318
.any(|impl_def_id| {
3319-
self.tcx.type_of(impl_def_id)
3319+
self.tcx
3320+
.type_of(impl_def_id)
33203321
.instantiate_identity()
33213322
.ty_adt_def()
33223323
.is_some_and(|def| def.did() == adt.did())

tests/ui/suggestions/derive-clone-already-present-issue-146515.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ struct ContainsRc<T> {
88
}
99

1010
fn clone_me<T>(x: &ContainsRc<T>) -> ContainsRc<T> {
11+
//~^ NOTE expected `ContainsRc<T>` because of return type
1112
x.clone()
1213
//~^ ERROR mismatched types
14+
//~| NOTE expected `ContainsRc<T>`, found `&ContainsRc<T>`
15+
//~| NOTE expected struct `ContainsRc<_>`
16+
//~| NOTE `ContainsRc<T>` does not implement `Clone`, so `&ContainsRc<T>` was cloned instead
17+
//~| NOTE the trait `Clone` must be implemented
1318
}
1419

1520
fn main() {}

tests/ui/suggestions/derive-clone-already-present-issue-146515.stderr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
error[E0308]: mismatched types
2-
--> $DIR/derive-clone-already-present-issue-146515.rs:11:5
2+
--> $DIR/derive-clone-already-present-issue-146515.rs:12:5
33
|
44
LL | fn clone_me<T>(x: &ContainsRc<T>) -> ContainsRc<T> {
55
| ------------- expected `ContainsRc<T>` because of return type
6+
LL |
67
LL | x.clone()
78
| ^^^^^^^^^ expected `ContainsRc<T>`, found `&ContainsRc<T>`
89
|
910
= note: expected struct `ContainsRc<_>`
1011
found reference `&ContainsRc<_>`
1112
note: `ContainsRc<T>` does not implement `Clone`, so `&ContainsRc<T>` was cloned instead
12-
--> $DIR/derive-clone-already-present-issue-146515.rs:11:5
13+
--> $DIR/derive-clone-already-present-issue-146515.rs:12:5
1314
|
1415
LL | x.clone()
1516
| ^

0 commit comments

Comments
 (0)