about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/structured_errors.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-05-11 17:43:06 -0700
committerGitHub <noreply@github.com>2023-05-11 17:43:06 -0700
commit341d6dfba585979e5909403567638e34b206fffa (patch)
treea03f988869c931f1b06e7578f3ce18cd9bb91660 /compiler/rustc_hir_analysis/src/structured_errors.rs
parent2a8221dbdfd180a2d56d4b0089f4f3952d8c2bcd (diff)
parentd548747c8531f2f0dfd3921b85aafb09ded27d49 (diff)
downloadrust-341d6dfba585979e5909403567638e34b206fffa.tar.gz
rust-341d6dfba585979e5909403567638e34b206fffa.zip
Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnr
use implied bounds when checking opaque types

During opaque type inference, we check for the well-formedness of the hidden type in the opaque type's own environment, not the one of the defining site, which are different in the case of TAIT.

However in the case of associated-type-impl-trait, we don't use implied bounds from the impl header. This caused us to reject the following:
```rust
trait Service<Req> {
    type Output;
    fn call(req: Req) -> Self::Output;
}

impl<'a, Req> Service<&'a Req> for u8 {
    type Output= impl Sized; // we can't prove WF of hidden type  `WF(&'a Req)` although it's implied by the impl
    //~^ ERROR type parameter Req doesn't live long enough
    fn call(req: &'a Req) -> Self::Output {
        req
    }
}
```

although adding an explicit bound would make it pass:
```diff
- impl<'a, Req> Service<&'a Req> for u8 {
+ impl<'a, Req> Service<&'a Req> for u8  where Req: 'a, {
```

I believe it should pass as we already allow the concrete type to be used:
```diff
impl<'a, Req> Service<&'a Req> for u8 {
-    type Output= impl Sized;
+    type Output= &'a Req;
```

Fixes #95922

Builds on #105982

cc ``@lcnr`` (because implied bounds)

r? ``@oli-obk``
Diffstat (limited to 'compiler/rustc_hir_analysis/src/structured_errors.rs')
0 files changed, 0 insertions, 0 deletions