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

Small program causes internal compiler error on rustc 1.45.0 #74918

Closed
jesperdj opened this issue Jul 29, 2020 · 3 comments · Fixed by #75363
Closed

Small program causes internal compiler error on rustc 1.45.0 #74918

jesperdj opened this issue Jul 29, 2020 · 3 comments · Fixed by #75363
Labels
A-inference Area: Type inference C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jesperdj
Copy link

jesperdj commented Jul 29, 2020

Code

(I know this is probably incorrect code, but this is what triggered the internal compiler error).

struct ChunkingIterator<T, S: 'static + Iterator<Item = T>> {
    source: S,
}

impl<T, S: Iterator<Item = T>> Iterator for ChunkingIterator<T, S> {
    type Item = IteratorChunk<T, S>;

    fn next(&mut self) -> Option<IteratorChunk<T, S>> {
        todo!()
    }
}

struct IteratorChunk<'a, T, S: Iterator<Item = T>> {
    source: &'a mut S,
}

impl<T, S: Iterator<Item = T>> Iterator for IteratorChunk<'_, T, S> {
    type Item = T;

    fn next(&mut self) -> Option<T> {
        todo!()
    }
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.45.0 (5c1f21c3b 2020-07-13)
binary: rustc
commit-hash: 5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2
commit-date: 2020-07-13
host: x86_64-unknown-linux-gnu
release: 1.45.0
LLVM version: 10.0

Error output

error[E0106]: missing lifetime specifier
 --> src/main.rs:6:31
  |
6 |     type Item = IteratorChunk<T, S>;
  |                               ^ expected named lifetime parameter
  |
help: consider introducing a named lifetime parameter
  |
6 |     type Item<'a> = IteratorChunk<<'a>T, S>;
  |              ^^^^                 ^^^^

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.45.0 (5c1f21c3b 2020-07-13) running on x86_64-unknown-linux-gnu

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

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

error: aborting due to previous error

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

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

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
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:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:490
  12: rust_begin_unwind
             at src/libstd/panicking.rs:388
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:101
  14: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:73
  15: rustc_infer::infer::InferCtxt::shallow_resolve_ty
  16: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
  17: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  18: rustc_middle::ty::fold::TypeFoldable::fold_with
  19: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  20: rustc_middle::ty::fold::TypeFoldable::fold_with
  21: rustc_middle::ty::fold::TypeFoldable::fold_with
  22: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  23: rustc_middle::ty::structural_impls::fold_list
  24: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  25: rustc_middle::ty::fold::TypeFoldable::fold_with
  26: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::expected_found_str_ty
  27: rustc_middle::ty::context::GlobalCtxt::enter_local
  28: rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError::try_report
  29: rustc_infer::infer::error_reporting::<impl rustc_infer::infer::InferCtxt>::report_region_errors
  30: rustc_infer::infer::InferCtxt::resolve_regions_and_report_errors
  31: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt>::regionck_item
  32: rustc_middle::ty::context::tls::with_context::{{closure}}
  33: rustc_infer::infer::InferCtxtBuilder::enter
  34: rustc_typeck::check::compare_method::compare_impl_method
  35: rustc_typeck::check::check_impl_items_against_trait
  36: rustc_typeck::check::check_item_type
  37: rustc_middle::hir::map::Map::visit_item_likes_in_module
  38: rustc_typeck::check::check_mod_item_types
  39: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute
  40: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  41: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  42: rustc_query_system::query::plumbing::get_query_impl
  43: rustc_query_system::query::plumbing::ensure_query_impl
  44: rustc_typeck::check_crate
  45: rustc_interface::passes::analysis
  46: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  47: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  48: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  49: rustc_query_system::query::plumbing::get_query_impl
  50: rustc_middle::ty::context::tls::enter_global
  51: rustc_interface::interface::run_compiler_in_existing_thread_pool
  52: rustc_ast::attr::with_globals

@jesperdj jesperdj 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 29, 2020
@jonas-schievink jonas-schievink added A-inference Area: Type inference I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 29, 2020
@spastorino
Copy link
Member

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@spastorino spastorino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 29, 2020
@estebank estebank added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jul 29, 2020
@estebank
Copy link
Contributor

1.44 doesn't have the ICE.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 3, 2020
@jonas-schievink
Copy link
Contributor

#75361 shows that this can result in no user-facing error message. I suggest increasing priority to P-high.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Aug 10, 2020
Use existing `infcx` when emitting trait impl diagnostic

Fixes rust-lang#75361
Fixes rust-lang#74918

Previously, we were creating a new `InferCtxt`, which caused an ICE when
used with type variables from the existing `InferCtxt`
@bors bors closed this as completed in 4ed0c6a Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inference Area: Type inference C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

5 participants