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

Closed
Nemo157 opened this issue Aug 7, 2019 · 8 comments · Fixed by #86763
Closed

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

Nemo157 opened this issue Aug 7, 2019 · 8 comments · Fixed by #86763
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 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
Copy link
Member Author

Nemo157 commented Aug 7, 2019

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

@rustbot rustbot added A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 7, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@chrissimpkins
Copy link
Member

ICE

Source: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=a68dbb4a4b78a06788f6f148c459f4cf

Stack trace

 Compiling playground v0.0.1 (/playground)
error: internal compiler error: errors selecting obligation during MIR typeck: [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { substs: [()], item_def_id: DefId(0:5 ~ playground[fd83]::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:357:17
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: std::panicking::begin_panic
  13: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
  14: core::ptr::drop_in_place
  15: core::ptr::drop_in_place
  16: core::ptr::drop_in_place
  17: rustc_interface::interface::run_compiler_in_existing_thread_pool
  18: scoped_tls::ScopedKey<T>::set
  19: syntax::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.43.0-nightly (07a34df18 2020-02-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground`.

To learn more, run the command again with --verbose.

Cargo bisection

cargo bisect-rustc --start 2019-08-03 --end 2019-08-04 --prompt

regression in nightly-2019-08-04

regression in nightly-2019-08-04
fetching https://static.rust-lang.org/dist/2019-08-04/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2019-08-04: 40 B / 40 B [=====================================================] 100.00 % 279.46 KB/s converted 2019-08-04 to 6e0d27d9368e2982bef8e1c4ac14d622c5ad018e
fetching https://static.rust-lang.org/dist/2019-08-03/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2019-08-03: 40 B / 40 B [=====================================================] 100.00 % 447.32 KB/s converted 2019-08-03 to b0e40bfba44836ad30051ffb077c1cfc5bf4a59f
looking for regression commit between 2019-08-04 and 2019-08-03
fetching commits from b0e40bfba44836ad30051ffb077c1cfc5bf4a59f to 6e0d27d9368e2982bef8e1c4ac14d622c5ad018e
opening existing repository at "rust.git"
refreshing repository
looking up first commit
looking up second commit
checking that commits are by bors and thus have ci artifacts...
finding bors merge commits
found 7 bors merge commits in the specified range
opening existing repository at "rust.git"
refreshing repository
no commits between b0e40bfba44836ad30051ffb077c1cfc5bf4a59f and 6e0d27d9368e2982bef8e1c4ac14d622c5ad018e within last 167 days
git log --oneline --author=bors b0e40bfba44836ad30051ffb077c1cfc5bf4a59f..6e0d27d9368e2982bef8e1c4ac14d622c5ad018e

6e0d27d Auto merge of #63059 - Centril:sound-bind-by-move, r=matthewjasper
452087b Auto merge of #63242 - pietroalbini:move-azure-pipelines, r=Mark-Simulacrum
a457433 Auto merge of #63234 - Centril:rollup-h9t731z, r=Centril
8e917f4 Auto merge of #62946 - RalfJung:miri_type_dispatch_first, r=oli-obk
d727071 Auto merge of #63180 - varkor:trait-alias-impl-trait, r=Centril
d9bd4b2 Auto merge of #63228 - Centril:rollup-x39p5ga, r=Centril

@JohnTitor JohnTitor added the E-needs-test Call for participation: Writing correctness tests. label Oct 7, 2020
@JohnTitor
Copy link
Member

Triage: This is no longer ICE with the latest nightly, marking as E-needs-test.

@Nemo157
Copy link
Member Author

Nemo157 commented Oct 7, 2020

Though the error seems incorrect, in a slightly less opaque playground I don't see where it is getting the obligation <B as Bar>::Foo == A from, nowhere does the code assert that is true.

@JohnTitor JohnTitor removed the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 14, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 18, 2020
Add some more regression tests

This is another round of rust-lang#77741. Tested with `debug-assertions=true` and it passed on my local.
Closes rust-lang#70877
Closes rust-lang#70944
Closes rust-lang#71659
Closes rust-lang#74816
Closes rust-lang#75707
Closes rust-lang#75983
(Skipped rust-lang#63355 because I'm not sure about the error.)
@nikomatsakis
Copy link
Contributor

This example should be disallowed with min_type_alias_impl_trait but is not. I filed #86731 to cover that.

@nikomatsakis
Copy link
Contributor

I agree with @Nemo157 that the behavior here is a bug, I don't think we handle impl Trait appearing in these sorts of contexts very well, at least within the defining module.

@JohnTitor
Copy link
Member

JohnTitor commented Jun 29, 2021

Thanks for triaging, we still should add a regression test to prevent ICE at least, right?

@nikomatsakis
Copy link
Contributor

Yep, that's good

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 17, 2021
Add a regression test for issue-63355

Closes rust-lang#63355
r? `@nikomatsakis`
@bors bors closed this as completed in 76300d5 Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. E-needs-test Call for participation: Writing correctness tests. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

6 participants