diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/regions/regions-outlives-projection-container-hrtb.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/regions/regions-outlives-projection-container-hrtb.rs')
-rw-r--r-- | src/test/ui/regions/regions-outlives-projection-container-hrtb.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs new file mode 100644 index 000000000..152eed5ac --- /dev/null +++ b/src/test/ui/regions/regions-outlives-projection-container-hrtb.rs @@ -0,0 +1,52 @@ +// Test that structs with higher-ranked where clauses don't generate +// "outlives" requirements. Issue #22246. + +#![allow(dead_code)] + +pub trait TheTrait<'b> { + type TheAssocType; +} + +pub struct TheType<'b> { + m: [fn(&'b()); 0] +} + +impl<'a,'b> TheTrait<'a> for TheType<'b> { + type TheAssocType = &'b (); +} + +pub struct WithHrAssoc<T> + where for<'a> T : TheTrait<'a> +{ + m: [T; 0] +} + +fn with_assoc<'a,'b>() { + // We get an error because 'b:'a does not hold: + + let _: &'a WithHrAssoc<TheType<'b>> = loop { }; + //~^ ERROR lifetime may not live long enough +} + +pub trait TheSubTrait : for<'a> TheTrait<'a> { +} + +impl<'b> TheSubTrait for TheType<'b> { } + +pub struct WithHrAssocSub<T> + where T : TheSubTrait +{ + m: [T; 0] +} + +fn with_assoc_sub<'a,'b>() { + // The error here is just because `'b:'a` must hold for the type + // below to be well-formed, it is not related to the HR relation. + + let _: &'a WithHrAssocSub<TheType<'b>> = loop { }; + //~^ ERROR lifetime may not live long enough +} + + +fn main() { +} |