Skip to content

Commit 91788da

Browse files
committed
add ui-suggestion-test
1 parent 892c674 commit 91788da

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use rustc_trait_selection::traits::{
4343
FulfillmentError, Obligation, ObligationCauseCode, supertraits,
4444
};
4545
use tracing::{debug, info, instrument};
46+
4647
use super::probe::{AutorefOrPtrAdjustment, IsSuggestion, Mode, ProbeScope};
4748
use super::{CandidateSource, MethodError, NoMatchData};
4849
use crate::errors::{self, CandidateTraitNote, NoAssociatedItem};
@@ -3314,7 +3315,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33143315
let trait_def_id = trait_pred.def_id();
33153316
let adt_def_id = adt.did();
33163317

3317-
let has_impl = self.tcx.trait_impls_of(trait_def_id)
3318+
let has_impl = self
3319+
.tcx
3320+
.trait_impls_of(trait_def_id)
33183321
.non_blanket_impls()
33193322
.values()
33203323
.flatten()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// issue: https://github.com/rust-lang/rust/issues/146515
2+
3+
use std::rc::Rc;
4+
5+
#[derive(Clone)]
6+
struct ContainsRc<T> {
7+
value: Rc<T>,
8+
}
9+
10+
fn clone_me<T>(x: &ContainsRc<T>) -> ContainsRc<T> {
11+
x.clone()
12+
//~^ ERROR mismatched types
13+
}
14+
15+
fn main() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/derive-clone-already-present-issue-146515.rs:11:5
3+
|
4+
LL | fn clone_me<T>(x: &ContainsRc<T>) -> ContainsRc<T> {
5+
| ------------- expected `ContainsRc<T>` because of return type
6+
LL | x.clone()
7+
| ^^^^^^^^^ expected `ContainsRc<T>`, found `&ContainsRc<T>`
8+
|
9+
= note: expected struct `ContainsRc<_>`
10+
found reference `&ContainsRc<_>`
11+
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+
|
14+
LL | x.clone()
15+
| ^
16+
= help: `Clone` is not implemented because the trait bound `T: Clone` is not satisfied
17+
note: the trait `Clone` must be implemented
18+
--> $SRC_DIR/core/src/clone.rs:LL:COL
19+
20+
error: aborting due to 1 previous error
21+
22+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)