about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/source-script.js
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-07-16 11:36:19 +0000
committerbors <bors@rust-lang.org>2022-07-16 11:36:19 +0000
commitd695a497bbf4b20d2580b75075faa80230d41667 (patch)
tree03672505bf97758e06289b0544aa029499bd79f9 /src/librustdoc/html/static/js/source-script.js
parente6c43cf8b98e4837bbee1cab225621001a3f2230 (diff)
parent2f15dfab0b444e757dcb32d935a716a5785b2155 (diff)
downloadrust-d695a497bbf4b20d2580b75075faa80230d41667.tar.gz
rust-d695a497bbf4b20d2580b75075faa80230d41667.zip
Auto merge of #96482 - willcrichton:fix-trait-suggestion-for-binops, r=estebank
Add Output = expected type trait obligation for known binary operators

This PR is a follow-on to #94034 that addresses #96442. That is, after replacing the trait-suggestion logic in `op.rs` with a more generic path that analyzes a general set of `Obligation`s, then we lost some specificity in the suggestions where the bounds on the associated type `Output=` would not get suggested.

This PR fixes this issue by changing `FnCtxt::construct_obligation_for_trait` to include a new `ProjectionPredicate` obligation for binary operators that obliges that `Output` is the same as the expected type of the expression. Additionally, to get the expected type of the expression, this PR threads the `Expectation<'tcx>` structure throughout several functions.

See src/test/ui/generic-associated-types/missing-bounds.stderr for an example of how this works.

One side effect of this change is it causes type-check failures with binops to include additional information. Specifically, many now say

```
error: type mismatch resolving `<Lhs as TheBinop>::Output == ExpectedTy`
```

It's up for discussion whether this added context is worth it to the user.

r? `@estebank`
Diffstat (limited to 'src/librustdoc/html/static/js/source-script.js')
0 files changed, 0 insertions, 0 deletions