-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #99801 - Neo-Zhixing:fix/generic_const_exprs_parent_o…
…paque_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.
- Loading branch information
Showing
2 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/ui/const-generics/generic_const_exprs/issue-99705.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}>{} | ||
} |