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 generic associated type #60654

Closed
antonok-edm opened this issue May 9, 2019 · 12 comments · Fixed by #61118
Closed

ICE with generic associated type #60654

antonok-edm opened this issue May 9, 2019 · 12 comments · Fixed by #61118
Assignees
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@antonok-edm
Copy link
Contributor

antonok-edm commented May 9, 2019

The following minimal example causes an internal compiler error.

struct Foo;

impl Iterator for Foo {
    type Item<'b> = &'b Foo;

    fn next(&mut self) -> Option<Self::Item> {
        None
    }
}

fn main() {}

Error in question:

> RUST_BACKTRACE=1 cargo +stable build
   Compiling icetest v0.1.0 (/tmp/icetest)
error[E0658]: generic associated types are unstable (see issue #44265)
 --> src/main.rs:4:5
  |
4 |     type Item<'b> = &'b Foo;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: src/librustc/ty/subst.rs:426: Region parameter out of range when substituting in region 'b (root type=Some(&'b Foo)) (index=0)

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::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_region
  15: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  16: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  17: rustc::traits::project::opt_normalize_projection_type
  18: rustc::traits::project::normalize_projection_type
  19: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  20: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  21: rustc::ty::fold::TypeFoldable::fold_with
  22: rustc::ty::fold::TypeFoldable::fold_with
  23: rustc::ty::fold::TypeFoldable::fold_with
  24: rustc::traits::project::normalize
  25: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  26: <core::iter::adapters::flatten::FlatMap<I, U, F> as core::iter::traits::iterator::Iterator>::next
  27: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter
  28: rustc::ty::wf::trait_obligations
  29: rustc::ty::context::GlobalCtxt::enter_local
  30: rustc_typeck::check::wfcheck::check_item_well_formed
  31: rustc::ty::query::__query_compute::check_item_well_formed
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::check_item_well_formed<'tcx>>::compute
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  35: rustc::hir::Crate::visit_all_item_likes
  36: rustc::util::common::time
  37: rustc_typeck::check_crate
  38: <std::thread::local::LocalKey<T>>::with
  39: rustc::ty::context::TyCtxt::create_and_enter
  40: rustc_driver::driver::compile_input
  41: rustc_driver::run_compiler_with_pool
  42: <scoped_tls::ScopedKey<T>>::set
  43: rustc_driver::run_compiler
  44: syntax::with_globals
  45: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:87
  46: <F as alloc::boxed::FnBox<A>>::call_box
  47: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/fc50f328b0353b285421b8ff5d4100966387a997/src/liballoc/boxed.rs:759
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  48: start_thread
  49: __clone
query stack during panic:
#0 [check_item_well_formed] processing `<Foo as std::iter::Iterator>`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

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.34.1 (fc50f328b 2019-04-24) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `icetest`.

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

rustc version:

> rustc +stable --version --verbose
rustc 1.34.1 (fc50f328b 2019-04-24)
binary: rustc
commit-hash: fc50f328b0353b285421b8ff5d4100966387a997
commit-date: 2019-04-24
host: x86_64-unknown-linux-gnu
release: 1.34.1
LLVM version: 8.0

This error was encountered on stable, but I can confirm that it also occurs on the latest nightly (1.36.0-nightly (cfdc84a00 2019-05-07)).

@estebank estebank added A-associated-items Area: Associated items (types, constants & functions) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels May 9, 2019
@Centril Centril added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-nominated labels May 9, 2019
@hellow554
Copy link
Contributor

it also occurs on the latest nightly

Hasn't the feature gate issue been fixed? :|

@nikomatsakis
Copy link
Contributor

I've removed the nomination and added this to the tracking issue for GATs #44265. The current impl is highly incomplete and ICEs are, sadly, expected. Also, I verified that a feature gate is indeed required.

@nikomatsakis
Copy link
Contributor

triage: P-medium

@hellow554
Copy link
Contributor

Also, I verified that a feature gate is indeed required.

I don't know if I get you wrong, but the example above ICEs on stable, beta and nightly without feature gate

@antonok-edm
Copy link
Contributor Author

@nikomatsakis @hellow554 oops, looks like I accidentally left the feature gate in there when I tried it out, but it produces the same ICE when it is omitted as well.

@hellow554
Copy link
Contributor

hellow554 commented May 9, 2019

looks like I accidentally left the feature gate in there

No, niko edited your question.
ping @nikomatsakis I think you got something wrong there. Can you please clarify that?

@nikomatsakis
Copy link
Contributor

Oh, I guess I was indeed incorreect. I tried it on play but didn't notice that, after the "correct" error, it goes on to print an ICE.

@hellow554
Copy link
Contributor

hellow554 commented May 10, 2019

What about adding the I-nominated tag again?

@pnkfelix
Copy link
Member

pnkfelix commented May 21, 2019

I'm not sure why we would nominate this for discussion. Yes, it is an ICE (and an ICE that occurs without the user adding a feature gate), but the message pretty clearly states that you're using an unstable feature.

It would be great to fix it so that it issues the error diagnostic without ICEing, but I wouldn't re-prioritize that work above P-high P-medium.

@pnkfelix
Copy link
Member

assigning to self since its a clear annoyance

@pnkfelix pnkfelix self-assigned this May 23, 2019
@pnkfelix pnkfelix added the P-medium Medium priority label May 23, 2019
@pnkfelix
Copy link
Member

pnkfelix commented May 23, 2019

triage: P-medium. (dupe of #61064)

pnkfelix added a commit to pnkfelix/rust that referenced this issue May 24, 2019
Centril added a commit to Centril/rust that referenced this issue May 24, 2019
…t, r=varkor

Dont ICE on an attempt to use GAT without feature gate

Fix rust-lang#60654
Centril added a commit to Centril/rust that referenced this issue May 24, 2019
…t, r=varkor

Dont ICE on an attempt to use GAT without feature gate

Fix rust-lang#60654
Centril added a commit to Centril/rust that referenced this issue May 24, 2019
…t, r=varkor

Dont ICE on an attempt to use GAT without feature gate

Fix rust-lang#60654
Centril added a commit to Centril/rust that referenced this issue May 25, 2019
…t, r=varkor

Dont ICE on an attempt to use GAT without feature gate

Fix rust-lang#60654
@pnkfelix
Copy link
Member

pnkfelix commented Jul 9, 2019

(the remaining bug, when the feature gate is enabled, is tracked in issue #62521)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium 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.

7 participants