-
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.
polymorphize:
I
used if T
used in I: Foo<T>
This commit adjusts polymorphization's handling of predicates so that after ensuring that `T` is used in `I: Foo<T>` if `I` is used, it now ensures that `I` is used if `T` is used in `I: Foo<T>`. This is necessary to mark generic parameters that only exist in impl parameters as used - thereby avoiding symbol clashes when using the new mangling scheme. Signed-off-by: David Wood <[email protected]>
- Loading branch information
Showing
3 changed files
with
189 additions
and
31 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
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
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,22 @@ | ||
// build-pass | ||
// compile-flags: -Zpolymorphize=on -Zsymbol-mangling-version=v0 | ||
|
||
pub(crate) struct Foo<'a, I, E>(I, &'a E); | ||
|
||
impl<'a, I, T: 'a, E> Iterator for Foo<'a, I, E> | ||
where | ||
I: Iterator<Item = &'a (T, E)>, | ||
{ | ||
type Item = T; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
self.find(|_| true) | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut a = Foo([(1u32, 1u16)].iter(), &1u16); | ||
let mut b = Foo([(1u16, 1u32)].iter(), &1u32); | ||
let _ = a.next(); | ||
let _ = b.next(); | ||
} |