Overlap checker considers possible downstream impl, but it is insufficient if it may contain fundamental types. May cause ICE.
#![crate_type = "lib"]
#![crate_name = "foo"]
pub trait Trait1<X> {
type Output;
}
pub trait Trait2<X> {}
impl<X, T> Trait1<X> for T where T: Trait2<X> {
type Output = ();
}
impl<X> Trait1<Box<X>> for A {
type Output = i32;
}
pub struct A;
fn f<X, T: Trait1<Box<X>>>() {
println!("k: {}", ::std::mem::size_of::<<T as Trait1<Box<X>>>::Output>());
}
pub fn g<X, T: Trait2<Box<X>>>() {
f::<X, T>();
}
extern crate foo;
use foo::{Trait2, A, g};
struct B;
impl Trait2<Box<B>> for A {}
fn main() {
g::<B, A>();
}
In stable (1.18.0), ICE is triggered when compiling downstream main.
$ rustc --version
rustc 1.18.0 (03fc9d622 2017-06-06)
$ cargo build
Compiling foo v0.1.0 (file:///C:/Users/qnighy/workdir/orphan-test/foo)
Compiling orphan-test v0.1.0 (file:///C:/Users/qnighy/workdir/orphan-test)
error: internal compiler error: src\librustc\infer\mod.rs:715: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <foo::A as foo::Trait1<std::boxed::Box<B>>>, item_name: Output(445) }, _)),depth=1),Ambiguity)]` resolving bounds after type-checking
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:375
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `orphan-test`.
To learn more, run the command again with --verbose.
In nightly, ICE is triggered when compiling even upstream foo. Perhaps this is a different bug.
$ rustc +nightly --version
rustc 1.20.0-nightly (582af6e1a 2017-07-19)
$ cargo +nightly build
Compiling foo v0.1.0 (file:///C:/Users/qnighy/workdir/orphan-test/foo)
error: internal compiler error: src\librustc\infer\mod.rs:573: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as std::marker::Sized>)),depth=1),Unimplemented), FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as Trait2<std::boxed::Box<X>>>)),depth=1),Unimplemented)]` resolving bounds after type-checking
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.20.0-nightly (582af6e1a 2017-07-19) running on x86_64-pc-windows-msvc
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:437:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `foo`.
To learn more, run the command again with --verbose.
Overlap checker considers possible downstream
impl, but it is insufficient if it may contain fundamental types. May cause ICE.In stable (1.18.0), ICE is triggered when compiling downstream main.
In nightly, ICE is triggered when compiling even upstream
foo. Perhaps this is a different bug.