diff --git a/src/test/ui/impl-trait/needs_least_region_or_bound.rs b/src/test/ui/impl-trait/needs_least_region_or_bound.rs index 2a5b365559e..8475122cfae 100644 --- a/src/test/ui/impl-trait/needs_least_region_or_bound.rs +++ b/src/test/ui/impl-trait/needs_least_region_or_bound.rs @@ -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) } diff --git a/src/test/ui/impl-trait/needs_least_region_or_bound.stderr b/src/test/ui/impl-trait/needs_least_region_or_bound.stderr deleted file mode 100644 index 9b9196a213d..00000000000 --- a/src/test/ui/impl-trait/needs_least_region_or_bound.stderr +++ /dev/null @@ -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 -