diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs')
-rw-r--r-- | tests/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs b/tests/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs new file mode 100644 index 000000000..fd3b967d9 --- /dev/null +++ b/tests/ui/generic-associated-types/issue-78113-lifetime-mismatch-dyn-trait-box.rs @@ -0,0 +1,38 @@ +// Test for diagnostics when we have mismatched lifetime due to implicit 'static lifetime in GATs + +// check-fail + +pub trait A {} +impl A for &dyn A {} +impl A for Box<dyn A> {} + +pub trait B { + type T<'a>: A; +} + +impl B for () { + // `'a` doesn't match implicit `'static`: suggest `'_` + type T<'a> = Box<dyn A + 'a>; //~ incompatible lifetime on type +} + +trait C {} +impl C for Box<dyn A + 'static> {} +pub trait D { + type T<'a>: C; +} +impl D for () { + // `'a` doesn't match explicit `'static`: we *should* suggest removing `'static` + type T<'a> = Box<dyn A + 'a>; //~ incompatible lifetime on type +} + +trait E {} +impl E for (Box<dyn A>, Box<dyn A>) {} +pub trait F { + type T<'a>: E; +} +impl F for () { + // `'a` doesn't match explicit `'static`: suggest `'_` + type T<'a> = (Box<dyn A + 'a>, Box<dyn A + 'a>); //~ incompatible lifetime on type +} + +fn main() {} |