Don't suggest field method if it's just missing some bounds

This commit is contained in:
Michael Goulet 2022-08-03 06:54:21 +00:00
parent 4df6cbe96f
commit 2a3fd5053f
4 changed files with 5 additions and 17 deletions

View File

@ -1000,7 +1000,11 @@ trait bound{s}",
label_span_not_found(&mut err);
}
self.check_for_field_method(&mut err, source, span, actual, item_name);
// Don't suggest (for example) `expr.field.method()` if `expr.method()`
// doesn't exist due to unsatisfied predicates.
if unsatisfied_predicates.is_empty() {
self.check_for_field_method(&mut err, source, span, actual, item_name);
}
self.check_for_unwrap_self(&mut err, source, span, actual, item_name);

View File

@ -18,10 +18,6 @@ note: the following trait bounds were not satisfied:
|
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
| --------- - ^^^^^^ unsatisfied trait bound introduced here
help: one of the expressions' fields has a method of the same name
|
LL | let filter = map.stream.filterx(|x: &_| true);
| +++++++
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:129:30: 129:37]>`, but its trait bounds were not satisfied
--> $DIR/issue-30786.rs:130:24
@ -43,10 +39,6 @@ note: the following trait bounds were not satisfied:
|
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
| --------- - ^^^^^^ unsatisfied trait bound introduced here
help: one of the expressions' fields has a method of the same name
|
LL | let count = filter.stream.countx();
| +++++++
error: aborting due to 2 previous errors

View File

@ -42,10 +42,6 @@ help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]`
|
LL | #[derive(Clone, Copy)]
|
help: one of the expressions' fields has a method of the same name
|
LL | let w = u.a.clone();
| ++
error: aborting due to 2 previous errors

View File

@ -42,10 +42,6 @@ help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]`
|
LL | #[derive(Clone, Copy)]
|
help: one of the expressions' fields has a method of the same name
|
LL | let w = u.a.clone();
| ++
error: aborting due to 2 previous errors