Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE with type_alias_impl_trait: errors selecting obligation during MIR typeck #63355

Open
Nemo157 opened this issue Aug 7, 2019 · 1 comment

Comments

@Nemo157
Copy link
Contributor

commented Aug 7, 2019

#![feature(type_alias_impl_trait)]

pub trait Foo {}

pub trait Bar {
    type Foo: Foo;

    fn foo() -> Self::Foo;
}

pub trait Baz {
    type Foo: Foo;
    type Bar: Bar<Foo = Self::Foo>;

    fn foo() -> Self::Foo;
    fn bar() -> Self::Bar;
}

impl Foo for () {}

impl Bar for () {
    type Foo = FooImpl;

    fn foo() -> Self::Foo {
        ()
    }
}

pub type FooImpl = impl Foo;
pub type BarImpl = impl Bar<Foo = FooImpl>;

impl Baz for () {
    type Foo = FooImpl;
    type Bar = BarImpl;

    fn foo() -> Self::Foo {
        ()
    }

    fn bar() -> Self::Bar {
        ()
    }
}

(playground)

error: internal compiler error: errors selecting obligation during MIR typeck: [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [()], item_def_id: DefId(0:14 ~ playground[6e48]::Bar[0]::Foo[0]) }, ())), depth=0),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: FooImpl, found: () })))]

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:361:17
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:47
   3: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:36
   4: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:200
   5: std::panicking::default_hook
             at src/libstd/panicking.rs:214
   6: rustc::util::common::panic_hook
   7: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:481
   8: std::panicking::begin_panic
   9: <rustc_errors::Handler as core::ops::drop::Drop>::drop
  10: core::ptr::real_drop_in_place
  11: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  12: core::ptr::real_drop_in_place
  13: rustc_interface::interface::run_compiler_in_existing_thread_pool
  14: std::thread::local::LocalKey<T>::with
  15: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack

changing type Foo = FooImpl; into type Foo = (); inside impl Bar for () will successfully compile

@Nemo157

This comment has been minimized.

Copy link
Contributor Author

commented Aug 7, 2019

@rustbot modify labels: A-impl-trait, F-type_alias_impl_trait, C-bug, I-ICE, T-compiler, requires-nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.