remove old error and add an explanation
This commit is contained in:
parent
ec48b4ebe2
commit
cc581bfa0e
@ -1,10 +1,22 @@
|
||||
// run-pass
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
trait MultiRegionTrait<'a, 'b> {}
|
||||
impl<'a, 'b> MultiRegionTrait<'a, 'b> for (&'a u32, &'b u32) {}
|
||||
|
||||
fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
//~^ ERROR ambiguous lifetime bound
|
||||
// Here we have a constraint that:
|
||||
//
|
||||
// (x, y) has type (&'0 u32, &'1 u32)
|
||||
//
|
||||
// where
|
||||
//
|
||||
// 'a: '0
|
||||
//
|
||||
// then we require that `('0 u32, &'1 u32): MultiRegionTrait<'a,
|
||||
// 'b>`, which winds up imposing a requirement that `'0 = 'a` and
|
||||
// `'1 = 'b`.
|
||||
(x, y)
|
||||
}
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
error: impl Trait captures unexpected lifetime
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:55
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ only lifetimes that appear in the impl Trait bounds may be captured
|
||||
|
|
||||
note: hidden type captures the lifetime 'a as defined on the function body at 6:20
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:20
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^
|
||||
note: hidden type would be allowed to capture the lifetime 'a as defined on the function body at 6:20
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:20
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^
|
||||
note: hidden type would be allowed to capture the lifetime 'b as defined on the function body at 6:24
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:24
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^
|
||||
= note: hidden type would be allowed to capture the static lifetime
|
||||
|
||||
error: impl Trait captures unexpected lifetime
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:55
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ only lifetimes that appear in the impl Trait bounds may be captured
|
||||
|
|
||||
note: hidden type captures the lifetime 'b as defined on the function body at 6:24
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:24
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^
|
||||
note: hidden type would be allowed to capture the lifetime 'a as defined on the function body at 6:20
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:20
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^
|
||||
note: hidden type would be allowed to capture the lifetime 'b as defined on the function body at 6:24
|
||||
--> $DIR/needs_least_region_or_bound.rs:6:24
|
||||
|
|
||||
LL | fn no_least_region<'a, 'b>(x: &'a u32, y: &'b u32) -> impl MultiRegionTrait<'a, 'b> {
|
||||
| ^^
|
||||
= note: hidden type would be allowed to capture the static lifetime
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user