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 when using nalgebra type in impl Trait type alias. #74244

Closed
connerebbinghaus opened this issue Jul 11, 2020 · 2 comments · Fixed by #77388
Closed

ICE when using nalgebra type in impl Trait type alias. #74244

connerebbinghaus opened this issue Jul 11, 2020 · 2 comments · Fixed by #77388
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@connerebbinghaus
Copy link

Code

src/lib.rs

#![feature(type_alias_impl_trait)]
use nalgebra::Vector3;

pub type A = impl Fn(Vector3<f64>);

pub fn foo() -> A {
    |_| ()
}

Cargo.toml

[package]
name = "bug"
version = "0.1.0"
edition = "2018"

[dependencies]
nalgebra = "0.21"

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (daecab3a7 2020-07-10)
binary: rustc
commit-hash: daecab3a784f28082df90cebb204998051f3557d
commit-date: 2020-07-10
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: src/librustc_mir/borrow_check/type_check/free_region_relations.rs:324:33: failed to compute implied bounds impl std::ops::Fn<(nalgebra::Matrix<f64, nalgebra::U3, nalgebra::U1, <nalgebra::DefaultAllocator as nalgebra::allocator::Allocator<f64, nalgebra::U3>>::Buffer>,)>

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:916:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.46.0-nightly (daecab3a7 2020-07-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

error: aborting due to previous error

error: could not compile `bug`.

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

error: internal compiler error: src/librustc_mir/borrow_check/type_check/free_region_relations.rs:324:33: failed to compute implied bounds impl std::ops::Fn<(nalgebra::Matrix<f64, nalgebra::U3, nalgebra::U1, <nalgebra::DefaultAllocator as nalgebra::allocator::Allocator<f64, nalgebra::U3>>::Buffer>,)>

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:916:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   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:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   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:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:217
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:530
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_mir::borrow_check::type_check::free_region_relations::UniversalRegionRelationsBuilder::add_implied_bounds::{{closure}}
  21: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  22: <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::traits::iterator::Iterator>::next
  23: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter
  24: rustc_mir::borrow_check::type_check::free_region_relations::create
  25: rustc_mir::borrow_check::type_check::type_check
  26: rustc_mir::borrow_check::nll::compute_regions
  27: rustc_mir::borrow_check::do_mir_borrowck
  28: rustc_infer::infer::InferCtxtBuilder::enter
  29: rustc_mir::borrow_check::mir_borrowck
  30: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  31: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  32: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  33: rustc_data_structures::stack::ensure_sufficient_stack
  34: rustc_query_system::query::plumbing::get_query_impl
  35: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
  36: rustc_hir::intravisit::Visitor::visit_nested_item
  37: rustc_typeck::collect::type_of::type_of
  38: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::type_of>::compute
  39: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  40: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  41: rustc_data_structures::stack::ensure_sufficient_stack
  42: rustc_query_system::query::plumbing::get_query_impl
  43: rustc_query_system::query::plumbing::ensure_query_impl
  44: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  45: rustc_middle::hir::map::Map::visit_item_likes_in_module
  46: rustc_typeck::collect::collect_mod_item_types
  47: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_mod_item_types>::compute
  48: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  49: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  50: rustc_data_structures::stack::ensure_sufficient_stack
  51: rustc_query_system::query::plumbing::get_query_impl
  52: rustc_query_system::query::plumbing::ensure_query_impl
  53: rustc_session::session::Session::track_errors
  54: rustc_typeck::check_crate
  55: rustc_interface::passes::analysis
  56: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  57: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  58: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  59: rustc_query_system::query::plumbing::get_query_impl
  60: rustc_middle::ty::context::tls::enter_global
  61: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  62: rustc_span::with_source_map
  63: rustc_interface::interface::run_compiler_in_existing_thread_pool
  64: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.46.0-nightly (daecab3a7 2020-07-10) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `foo`
#1 [type_of] computing type of `A::{{opaque}}#0`
#2 [collect_mod_item_types] collecting item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `bug`.

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

Bisection

searched nightlies: from nightly-2019-10-03 to nightly-2020-07-05
regressed nightly: nightly-2020-02-16
searched commits: from 433aae9 to 61d9231
regressed commit: 19288dd

bisected with cargo-bisect-rustc v0.5.1

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2019-10-03 --end 2020-07-05 --with-cargo --prompt -- check 
@connerebbinghaus connerebbinghaus added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 11, 2020
@jonas-schievink jonas-schievink added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 11, 2020
@connorskees
Copy link
Contributor

connorskees commented Jul 12, 2020

Minified,

trait Allocator {
    type Buffer;
}

struct DefaultAllocator;

impl<T> Allocator for DefaultAllocator {
    type Buffer = ();
}

type A = impl Fn(<DefaultAllocator as Allocator>::Buffer);

fn foo() -> A {
    |_| ()
}

playground

It seems possible to ICE on stable, though I'm not sure if it counts?

Stable error
rustc --version --verbose
rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-unknown-linux-gnu
release: 1.44.1
LLVM version: 9.0
error[E0658]: `impl Trait` in type aliases is unstable
  --> src/lib.rs:15:10
   |
15 | type A = impl Fn(Matrix<<DefaultAllocator as Allocator<()>>::Buffer>);
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information

error: internal compiler error: src/librustc_mir/borrow_check/type_check/free_region_relations.rs:318: failed to compute implied bounds A

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:904:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.44.1 (c7087fe00 2020-06-17) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

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

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `ice`.

@JohnTitor JohnTitor removed the requires-nightly This issue requires a nightly compiler in some way. label Jul 14, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 14, 2020
@JohnTitor
Copy link
Member

The ICE is fixed in the latest nightly, marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Sep 29, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 3, 2020
Add some regression tests

Closes rust-lang#66501
Closes rust-lang#68951
Closes rust-lang#72565
Closes rust-lang#74244
Closes rust-lang#75299

The first issue is fixed in 1.43.0, other issues are fixed in the recent nightly.
@bors bors closed this as completed in f09c962 Oct 4, 2020
@oli-obk oli-obk moved this from Todo to Done in type alias impl trait stabilization Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.

5 participants