diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-11-02 22:06:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-02 22:06:26 +0100 |
| commit | 214d6b6836413bbfe9132f7aff3d91ae67bc62ba (patch) | |
| tree | cf6d81f856d3cd4779dffd35eed075402f69238b /src/test/ui/const-generics | |
| parent | edf0182213a9e30982eb34f3925ddc4cf5ed3471 (diff) | |
| parent | 744fa610eb6bd476b875dd2d6f8be5b7b9f1b77c (diff) | |
| download | rust-214d6b6836413bbfe9132f7aff3d91ae67bc62ba.tar.gz rust-214d6b6836413bbfe9132f7aff3d91ae67bc62ba.zip | |
Rollup merge of #99801 - Neo-Zhixing:fix/generic_const_exprs_parent_opaque_predicates, r=oli-obk
fix(generic_const_exprs): Fix predicate inheritance for children of opaque types Fixes #99705 We currently have a special case to perform predicate inheritance when the const item is in the generics. I think we're also going to need this for opaque return types. When evaluating the predicates applied to the associated item, it'll inherit from its parent, the opaque type, which will never have predicates applied. This PR bypass the opaque typed parent and inherit predicates directly from the function itself.
Diffstat (limited to 'src/test/ui/const-generics')
| -rw-r--r-- | src/test/ui/const-generics/generic_const_exprs/issue-99705.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs b/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs new file mode 100644 index 00000000000..75b57b621bb --- /dev/null +++ b/src/test/ui/const-generics/generic_const_exprs/issue-99705.rs @@ -0,0 +1,33 @@ +// check-pass +#![crate_type = "lib"] +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] +pub trait MyIterator { + type Output; +} + +pub trait Foo { + const ABC: usize; +} + +pub struct IteratorStruct<const N: usize>{ + +} + +pub struct Bar<const N: usize> { + pub data: [usize; N] +} + +impl<const N: usize> MyIterator for IteratorStruct<N> { + type Output = Bar<N>; +} + +pub fn test1<T: Foo>() -> impl MyIterator<Output = Bar<{T::ABC}>> where [(); T::ABC]: Sized { + IteratorStruct::<{T::ABC}>{} +} + +pub trait Baz<const N: usize>{} +impl<const N: usize> Baz<N> for Bar<N> {} +pub fn test2<T: Foo>() -> impl MyIterator<Output = impl Baz<{ T::ABC }>> where [(); T::ABC]: Sized { + IteratorStruct::<{T::ABC}>{} +} |
