# Implied region bounds do no satisfy explicit bounds

**URL:** https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575
**Category:** language design
**Created:** [May 4, 2022, 5:36am UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575 "2022-05-04T05:36:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![chrefr](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chrefr](https://internals.rust-lang.org/u/chrefr)
#### Post date: [May 4, 2022, 5:36am UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575/1 "2022-05-04T05:36:10Z")

</div>

For example ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e7ec61791b0eb37a763e22ad145cc876)):

```rust
trait Trait {
    fn bar<'a, 'b: 'a>(v: &'b &'a str);
}

impl Trait for () {
    fn bar<'a, 'b>(_v: &'b &'a str) {}
}

```

The `&'b &'a str` type is WF only if `'b: 'a`, and so the fn body has an implied bound for that, but it still does not satisfy the trait:

```rust
error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration
 --> src/lib.rs:6:11
  |
2 | fn bar<'a, 'b: 'a>(v: &'b &'a str);
  | ------------ lifetimes in impl do not match this method in trait
...
6 | fn bar<'a, 'b>(_v: &'b &'a str) {}
  | ^^^^^^^^ lifetimes do not match method in trait

```

If we write it explicitly, it works ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=54472aef73b2db38728799d90e3cbf24)):

```rust
impl Trait for () {
    fn bar<'a, 'b>(_v: &'b &'a str)
    where
        &'b &'a str:,
    {
    }
}

```

Is this a bug? Deliberate design decision? Not decided?

---

<div class="post-metadata">

### Author: ![tema2](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/tema2/32/6498_2.png) [@tema2](https://internals.rust-lang.org/u/tema2)
#### Post date: [May 4, 2022, 11:25am UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575/2 "2022-05-04T11:25:48Z")

</div>

> [@chrefr](#):
>
> The `&'b &'a str` type is WF only if `'b: 'a`

Excuse me if I'm wrong, but isn't it kind of reverse? Like, `&'b &'a str` is only valid when `'a: 'b`, so it works as intended.

---

<div class="post-metadata">

### Author: ![SkiFire13](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/skifire13/32/7579_2.png) [@SkiFire13](https://internals.rust-lang.org/u/SkiFire13)
#### Post date: [May 4, 2022, 7:30pm UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575/3 "2022-05-04T19:30:15Z")

</div>

Surprisingly though changing the bound to `'a: 'b` still gives an error [Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9398f5b4be3a197d4fc0107d137ed3e4)

---

<div class="post-metadata">

### Author: ![chrefr](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chrefr](https://internals.rust-lang.org/u/chrefr)
#### Post date: [May 4, 2022, 11:18pm UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575/4 "2022-05-04T23:18:16Z")

</div>

Well it looks like you're right but then it's even more strange because if I specify `where &'b 'a str:` it works in both cases even though it should only imply `'a: 'b`.

---

<div class="post-metadata">

### Author: ![chrefr](https://avatars.discourse-cdn.com/v4/letter/c/e480ec/32.png) [@chrefr](https://internals.rust-lang.org/u/chrefr)
#### Post date: [May 4, 2022, 11:34pm UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575/5 "2022-05-04T23:34:12Z")

</div>

Well I don't understand why we don't show an error in the second case of my original post, so maybe I'm somewhere wrong with my reasoning, but I still can reproduce with `'a: 'b` so the question stands.

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)
#### Post date: [August 2, 2022, 11:35pm UTC](https://internals.rust-lang.org/t/implied-region-bounds-do-no-satisfy-explicit-bounds/16575/6 "2022-08-02T23:35:02Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
