Closed
Description
Repro steps: create a new cargo binary with cargo new
. Replace src/main.rs
with the following code. Then run cargo build
. Hope this is helpful! I've tried to minimize the code as much as possible.
Code
use std::iter;
fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> {
iter::empty()
}
fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> {
f(data).filter(|x| x == target)
}
fn main() {}
Meta
rustc --version --verbose
:
rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-apple-darwin
release: 1.57.0
LLVM version: 13.0.0
Error output
error[E0107]: missing generics for struct `Vec`
--> src/main.rs:3:43
|
3 | fn f<T>(data: &[T]) -> impl Iterator<Item=Vec> {
| ^^^ expected at least 1 generic argument
|
help: add missing generic argument
|
3 | fn f<T>(data: &[T]) -> impl Iterator<Item=Vec<T>> {
| ~~~~~~
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: PlaceBuilder { base: Upvar { var_hir_id: HirId { owner: DefId(0:9 ~ ice_repro[c5a9]::g), local_id: 4 }, closure_def_id: DefId(0:12 ~ ice_repro[c5a9]::g::{closure#0}), closure_kind: FnMut }, projection: [] }', compiler/rustc_mir_build/src/build/expr/as_place.rs:306:69
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.57.0 (f1edd0429 2021-11-29) running on x86_64-apple-darwin
note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [mir_built] building MIR for `g::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `g::{closure#0}`
end of query stack
For more information about this error, try `rustc --explain E0107`.
error: could not compile `ice_repro` due to previous error
Backtrace
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: PlaceBuilder { base: Upvar { var_hir_id: HirId { owner: DefId(0:9 ~ ice_repro[c5a9]::g), local_id: 4 }, closure_def_id: DefId(0:12 ~ ice_repro[c5a9]::g::{closure#0}), closure_kind: FnMut }, projection: [] }', compiler/rustc_mir_build/src/build/expr/as_place.rs:306:69
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: rustc_mir_build::build::expr::as_place::PlaceBuilder::into_place
4: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
5: rustc_mir_build::build::expr::as_temp::<impl rustc_mir_build::build::Builder>::as_temp_inner
6: rustc_mir_build::build::expr::as_operand::<impl rustc_mir_build::build::Builder>::as_operand
7: rustc_mir_build::build::expr::as_operand::<impl rustc_mir_build::build::Builder>::as_call_operand
8: rustc_mir_build::build::expr::as_operand::<impl rustc_mir_build::build::Builder>::as_call_operand
9: <core::iter::adapters::copied::Copied<I> as core::iter::traits::iterator::Iterator>::fold
10: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
11: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
12: rustc_mir_build::build::scope::<impl rustc_mir_build::build::Builder>::in_scope
13: rustc_data_structures::stack::ensure_sufficient_stack
14: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
15: rustc_mir_build::build::scope::<impl rustc_mir_build::build::Builder>::in_scope
16: rustc_data_structures::stack::ensure_sufficient_stack
17: rustc_mir_build::build::expr::into::<impl rustc_mir_build::build::Builder>::expr_into_dest
18: rustc_mir_build::build::construct_fn
19: rustc_infer::infer::InferCtxtBuilder::enter
20: rustc_mir_build::build::mir_built
21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
22: rustc_data_structures::stack::ensure_sufficient_stack
23: rustc_query_system::query::plumbing::try_execute_query
24: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_built
25: rustc_mir_transform::check_unsafety::unsafety_check_result
26: core::ops::function::FnOnce::call_once
27: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
28: rustc_data_structures::stack::ensure_sufficient_stack
29: rustc_query_system::query::plumbing::try_execute_query
30: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result
31: <rustc_mir_transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_rvalue
32: rustc_mir_transform::check_unsafety::unsafety_check_result
33: core::ops::function::FnOnce::call_once
34: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
35: rustc_data_structures::stack::ensure_sufficient_stack
36: rustc_query_system::query::plumbing::try_execute_query
37: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::unsafety_check_result
38: rustc_mir_transform::mir_const
39: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
40: rustc_data_structures::stack::ensure_sufficient_stack
41: rustc_query_system::query::plumbing::try_execute_query
42: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const
43: rustc_mir_transform::mir_promoted
44: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
45: rustc_data_structures::stack::ensure_sufficient_stack
46: rustc_query_system::query::plumbing::try_execute_query
47: rustc_query_system::query::plumbing::get_query
48: rustc_borrowck::mir_borrowck
49: core::ops::function::FnOnce::call_once
50: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
51: rustc_data_structures::stack::ensure_sufficient_stack
52: rustc_query_system::query::plumbing::try_execute_query
53: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
54: rustc_typeck::collect::type_of::type_of
55: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
56: rustc_data_structures::stack::ensure_sufficient_stack
57: rustc_query_system::query::plumbing::try_execute_query
58: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
59: rustc_typeck::check::check::check_item_type
60: rustc_middle::hir::map::Map::visit_item_likes_in_module
61: rustc_typeck::check::check::check_mod_item_types
62: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
63: rustc_data_structures::stack::ensure_sufficient_stack
64: rustc_query_system::query::plumbing::try_execute_query
65: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
66: rustc_middle::hir::map::Map::for_each_module
67: rustc_typeck::check_crate
68: rustc_interface::passes::analysis
69: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
70: rustc_data_structures::stack::ensure_sufficient_stack
71: rustc_query_system::query::plumbing::try_execute_query
72: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
73: rustc_interface::passes::QueryContext::enter
74: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
75: rustc_span::with_source_map
76: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
...
query stack during panic:
#0 [mir_built] building MIR for `g::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `g::{closure#0}`
#2 [unsafety_check_result] unsafety-checking `g`
#3 [mir_const] processing MIR for `g`
#4 [mir_promoted] processing `g`
#5 [mir_borrowck] borrow-checking `g`
#6 [type_of] computing type of `g::{opaque#0}`
#7 [check_mod_item_types] checking item types in top-level module
#8 [analysis] running analysis passes on this crate
end of query stack
Metadata
Metadata
Assignees
Labels
Category: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.Performance or correctness regression from one stable version to another.