-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
-ZpolymorphizeUnstable option: Polymorphization.Unstable option: Polymorphization.
Description
rustc will not currently bootstrap with -Zsymbol-mangling-version=v0 and -Zpolymorphization=on due to the following issue:
Consider the following example:
// 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();
}..which produces the following error:
error: symbol `_RNCNvXCs4fqI2P2rA04_19impl_param_manglingINtB4_3FooppENtNtNtNtCsfnEnqCNU58Z_4core4iter6traits8iterator8Iterator4next0B4_` is already defined
--> src/test/ui/polymorphization/impl-param-mangling.rs:13:19
|
13 | self.find(|_| true)
| ^^^^^^^^
error: aborting due to previous error
(unmangled: <impl_param_mangling::Foo<_, _> as core::iter::traits::iterator::Iterator>::next::{closure#0})
Polymorphisation correctly determines that I and E are unused and that T is used in the closure (T is used by the argument). Therefore, multiple copies of this closure can be generated by polymorphization for each instantiation of T - however, this is not encoded in the mangling for the closure, which triggers assert_symbols_are_distinct.
Metadata
Metadata
Assignees
Labels
-ZpolymorphizeUnstable option: Polymorphization.Unstable option: Polymorphization.