fix #105788, Remove unreasonable help message for auto trait
This commit is contained in:
parent
58f5a0180c
commit
90753de099
@ -943,6 +943,9 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
});
|
||||
} else {
|
||||
debug_assert!(self.tcx.is_trait(trait_def_id));
|
||||
if self.tcx.trait_is_auto(trait_def_id) {
|
||||
return;
|
||||
}
|
||||
for item in self.impl_or_trait_item(trait_def_id) {
|
||||
// Check whether `trait_def_id` defines a method with suitable name.
|
||||
if !self.has_applicable_self(&item) {
|
||||
|
@ -2306,6 +2306,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
_ => false,
|
||||
}
|
||||
}) && (type_is_local || info.def_id.is_local())
|
||||
&& !self.tcx.trait_is_auto(info.def_id)
|
||||
&& self
|
||||
.associated_value(info.def_id, item_name)
|
||||
.filter(|item| {
|
||||
|
@ -6,7 +6,8 @@ auto trait Foo {
|
||||
|
||||
trait Bar {
|
||||
fn f(&self) {
|
||||
self.g(); //~ ERROR the method `g` exists for reference `&Self`, but its trait bounds were not satisfied
|
||||
// issue #105788
|
||||
self.g(); //~ ERROR no method named `g` found for reference `&Self` in the current scope
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,21 +6,11 @@ LL | auto trait Foo {
|
||||
LL | fn g(&self);
|
||||
| ---^-------- help: remove these associated items
|
||||
|
||||
error[E0599]: the method `g` exists for reference `&Self`, but its trait bounds were not satisfied
|
||||
--> $DIR/issue-105732.rs:9:14
|
||||
error[E0599]: no method named `g` found for reference `&Self` in the current scope
|
||||
--> $DIR/issue-105732.rs:10:14
|
||||
|
|
||||
LL | self.g();
|
||||
| ^
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`Self: Foo`
|
||||
which is required by `&Self: Foo`
|
||||
`&Self: Foo`
|
||||
= help: items from traits can only be used if the type parameter is bounded by the trait
|
||||
help: the following trait defines an item `g`, perhaps you need to add a supertrait for it:
|
||||
|
|
||||
LL | trait Bar: Foo {
|
||||
| +++++
|
||||
| ^ help: there is a method with a similar name: `f`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user