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 on higher-trait bounds #60218

Closed
agalakhov opened this issue Apr 24, 2019 · 6 comments · Fixed by #64706
Closed

ICE on higher-trait bounds #60218

agalakhov opened this issue Apr 24, 2019 · 6 comments · Fixed by #64706
Assignees
Labels
A-trait-system Area: Trait system 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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@agalakhov
Copy link

The following code:

use std::iter::Map;

trait Foo { }

impl<T> Foo for &'_ T where T: Foo { }
impl<T> Foo for Option<T> where T: Foo { }

impl Foo for u32 { }

fn trigger_error<I, F>(iterable: I, functor: F)
where
    for<'t> &'t I: IntoIterator,
    for<'t> Map<<&'t I as IntoIterator>::IntoIter, F>: Iterator,
    for<'t> <Map<<&'t I as IntoIterator>::IntoIter, F> as Iterator>::Item: Foo,
{
    
}

fn main() {
    trigger_error(Vec::<u32>::new(), |x: &u32| Some(x))
}

results in an ICE

error: internal compiler error: src/librustc/infer/lexical_region_resolve/mod.rs:632: collect_error_for_expanding_node() could not find error for var '_#2r in universe U11, lower_bounds=[
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:14), 't) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:20:5: 20:18, body_id: HirId { owner: DefIndex(0:9), local_id: 24 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<std::iter::Map<<&'t _ as std::iter::IntoIterator>::IntoIter, _> as std::iter::Iterator>), parent_code: ItemObligation(DefId(0/0:8 ~ playground[b1a9]::trigger_error[0])) }) }))),
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:14), 't) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:20:5: 20:18, body_id: HirId { owner: DefIndex(0:9), local_id: 24 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<std::iter::Map<<&'t _ as std::iter::IntoIterator>::IntoIter, _> as std::iter::Iterator>), parent_code: ItemObligation(DefId(0/0:8 ~ playground[b1a9]::trigger_error[0])) }) })))
], upper_bounds=[
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:14), 't) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:20:5: 20:18, body_id: HirId { owner: DefIndex(0:9), local_id: 24 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<std::iter::Map<<&'t _ as std::iter::IntoIterator>::IntoIter, _> as std::iter::Iterator>), parent_code: ItemObligation(DefId(0/0:8 ~ playground[b1a9]::trigger_error[0])) }) }))),
    RegionAndOrigin(RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:14), 't) }),Subtype(TypeTrace(ObligationCause { span: src/main.rs:20:5: 20:18, body_id: HirId { owner: DefIndex(0:9), local_id: 24 }, code: ImplDerivedObligation(DerivedObligationCause { parent_trait_ref: Binder(<std::iter::Map<<&'t _ as std::iter::IntoIterator>::IntoIter, _> as std::iter::Iterator>), parent_code: ItemObligation(DefId(0/0:8 ~ playground[b1a9]::trigger_error[0])) }) })))
]

Tested this on stable and nightly. May be somehow related to #60070.

@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-trait-system Area: Trait system labels Apr 24, 2019
@hellow554
Copy link
Contributor

Backtrace:

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:558:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: rustc::infer::lexical_region_resolve::resolve
  15: rustc::infer::InferCtxt::resolve_regions_and_report_errors
  16: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_fn
  17: rustc::ty::context::GlobalCtxt::enter_local
  18: rustc_typeck::check::typeck_tables_of
  19: rustc::ty::query::__query_compute::typeck_tables_of
  20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_tables_of<'tcx>>::compute
  21: rustc::dep_graph::graph::DepGraph::with_task_impl
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  23: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
  24: rustc_typeck::check::typeck_item_bodies
  25: rustc::ty::query::__query_compute::typeck_item_bodies
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::typeck_item_bodies<'tcx>>::compute
  27: rustc::dep_graph::graph::DepGraph::with_task_impl
  28: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  29: rustc::util::common::time
  30: rustc_typeck::check_crate
  31: <std::thread::local::LocalKey<T>>::with
  32: rustc::ty::context::TyCtxt::create_and_enter
  33: rustc_driver::driver::compile_input
  34: rustc_driver::run_compiler_with_pool
  35: <scoped_tls::ScopedKey<T>>::set
  36: rustc_driver::run_compiler
  37: syntax::with_globals
  38: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  39: <F as alloc::boxed::FnBox<A>>::call_box
  40: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/91856ed52c58aa5ba66a015354d1cc69e9779bdf/src/liballoc/boxed.rs:759
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  41: start_thread
  42: __clone
query stack during panic:
#0 [typeck_tables_of] processing `main`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 2 previous errors

Happens on stable, beta, nightly

@hellow554
Copy link
Contributor

Litte bit simplified:

use std::iter::Map;

pub trait Foo {}

pub fn trigger_error<I, F>(iterable: I, functor: F)
where
    for<'t> &'t I: IntoIterator,
    for<'t> Map<<&'t I as IntoIterator>::IntoIter, F>: Iterator,
    for<'t> <Map<<&'t I as IntoIterator>::IntoIter, F> as Iterator>::Item: Foo,
{
}

fn main() {
    trigger_error(vec![], |x: &u32| x)
}

@hellow554
Copy link
Contributor

Bisection show ICE was introduced in c0bbc39, but I'm not sure how related that is, because it's a very very big PR.
CC #55517 @nikomatsakis

@nikomatsakis nikomatsakis self-assigned this Apr 25, 2019
@nikomatsakis nikomatsakis added P-high High priority and removed I-nominated labels Apr 25, 2019
@nikomatsakis
Copy link
Contributor

I will investigate.

@pnkfelix
Copy link
Member

ping @nikomatsakis , any progress here?

@nikomatsakis
Copy link
Contributor

I did some investigation. This bugs turns out to have been fixed -- well, more likely it was worked around by #58592. I'm going to land a test for it so that when I get around to reversing #58592, I can fix it then.

@nikomatsakis nikomatsakis 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 20, 2019
nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Oct 3, 2019
Centril added a commit to Centril/rust that referenced this issue Oct 3, 2019
Centril added a commit to Centril/rust that referenced this issue Oct 3, 2019
tmandry added a commit to tmandry/rust that referenced this issue Oct 3, 2019
bors added a commit that referenced this issue Oct 3, 2019
Rollup of 11 pull requests

Successful merges:

 - #61879 (Stabilize todo macro)
 - #64675 (Deprecate `#![plugin]` & `#[plugin_registrar]`)
 - #64690 (proc_macro API: Expose `macro_rules` hygiene)
 - #64706 (add regression test for #60218)
 - #64741 (Prevent rustdoc feature doctests)
 - #64842 (Disallow Self in type param defaults of ADTs)
 - #65004 (Replace mentions of IRC with Discord)
 - #65018 (Set RUST_BACKTRACE=0 in tests that include a backtrace in stderr)
 - #65055 (Add long error explanation for E0556)
 - #65056 (Make visit projection iterative)
 - #65057 (typo: fix typo in E0392)

Failed merges:

r? @ghost
@bors bors closed this as completed in c6999a5 Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system 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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants