Skip to content

-Z print-type-sizes: internal error: entered unreachable code: FieldsShape::offset: Primitives have no fields' #86528

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jyn514 opened this issue Jun 22, 2021 · 11 comments · Fixed by #89329
Labels
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) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Jun 22, 2021

Code

rust-lang/docs.rs@69b1f3d

MCVE:

pub fn test() {
    Vec::<()>::new()
        .into_iter()
        .filter(|_| true)
        .collect::<Vec<_>>();
}

Meta

rustc --version: rustc 1.54.0-nightly (cc77ba46f 2021-06-03)

Error output

thread 'rustc' panicked at 'internal error: entered unreachable code: FieldsShape::offset: `Primitive`s have no fields', compiler\rustc_target\src\abi\mod.rs:768:17
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.54.0-nightly (cc77ba46f 2021-06-03) running on x86_64-pc-windows-msvc

note: compiler flags: -Z print-type-sizes -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:
end of query stack
@jyn514 jyn514 added 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. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example requires-nightly This issue requires a nightly compiler in some way. labels Jun 22, 2021
@jyn514 jyn514 changed the title internal error: entered unreachable code: FieldsShape::offset: Primitives have no fields' -Z print-type-sizes: internal error: entered unreachable code: FieldsShape::offset: Primitives have no fields' Jun 22, 2021
@jyn514
Copy link
Member Author

jyn514 commented Jun 22, 2021

pub fn offset(&self, i: usize) -> Size {
match *self {
FieldsShape::Primitive => {
unreachable!("FieldsShape::offset: `Primitive`s have no fields")
}

@Skepfyr
Copy link
Contributor

Skepfyr commented Jun 28, 2021

"Minimised" to a reproducer involving 3 crates, 2 of which are empty: repo containing repro.

The crates are laid out like so:

root -> my_macro[proc-macro=true] -> dep

root and my_macro are both empty, dep contains the following code:

use std::str::FromStr;

pub fn foo() {
    f64::from_str("");
}

Using that repro I used cargo-bisect to find the offending commit:
searched nightlies: from nightly-2021-03-28 to nightly-2021-06-27
regressed nightly: nightly-2021-05-19
searched commits: from 3e99439 to 4e3e6db
regressed commit: 4e3e6db (#84767)

bisected with cargo-bisect-rustc v0.6.0

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

cargo bisect-rustc --start=2021-03-28 --end=2021-06-27 --script ./test.sh

@Skepfyr
Copy link
Contributor

Skepfyr commented Jun 28, 2021

It's worth adding that this was triggered by syn, so it will probably occur for all crates that depend on a proc macro that depends on syn (i.e. basically everything).

@jyn514
Copy link
Member Author

jyn514 commented Jun 28, 2021

Uhh #84767 is not the PR I would have expected but I guess cc @scottmcm just in case you know why this broke?

@scottmcm
Copy link
Member

Repros on godbolt, so the 2 empty crates don't seem needed: https://rust.godbolt.org/z/KEW4Koz7a

Agreed, @jyn514, I'm also completely surprised that the ? change would break this.

Only thing I could think of would be that somehow it propagated a different type that somehow still compiled, but I've never seen an example of that. And the layout stuff is using LayoutError, which is quite well-behaved -- no weird Froms that could potentially have it do strange things -- and even then it's very sparse on ? usage.

Unless maybe it's another instance of something getting confused by the default parameter on FromResidual somehow? (Not sure how it could be, but rust-lang/rust-analyzer#8692 came to mind.)

Full backtrace from a build with debug info, in case it helps somebody
thread 'rustc' panicked at 'internal error: entered unreachable code: FieldsShape::offset: `Primitive`s have no fields', compiler\rustc_target\src\abi\mod.rs:764:17
stack backtrace:
   0:     0x7ffa13ee5ef6 - std::backtrace_rs::backtrace::dbghelp::trace
                               at C:\src\rust\library\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ffa13ee5ef6 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at C:\src\rust\library\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffa13ef37d0 - std::sys_common::backtrace::_print_fmt
                               at C:\src\rust\library\std\src\sys_common\backtrace.rs:67
   3:     0x7ffa13ef37d0 - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at C:\src\rust\library\std\src\sys_common\backtrace.rs:46
   4:     0x7ffa13f128ab - core::fmt::write
                               at C:\src\rust\library\core\src\fmt\mod.rs:1111
   5:     0x7ffa13ef0e18 - std::io::Write::write_fmt
                               at C:\src\rust\library\std\src\io\mod.rs:1640
   6:     0x7ffa13ef49e4 - std::sys_common::backtrace::_print
                               at C:\src\rust\library\std\src\sys_common\backtrace.rs:49
   7:     0x7ffa13ef49e4 - std::sys_common::backtrace::print
                               at C:\src\rust\library\std\src\sys_common\backtrace.rs:36
   8:     0x7ffa13ef49e4 - std::panicking::default_hook::{{closure}}
                               at C:\src\rust\library\std\src\panicking.rs:208
   9:     0x7ffa13ef4660 - std::panicking::default_hook
                               at C:\src\rust\library\std\src\panicking.rs:225
  10:     0x7ff9d2f96690 - alloc::boxed::{{impl}}::call
                               at C:\src\rust\library\alloc\src\boxed.rs:1589
  11:     0x7ff9d2f96690 - rustc_driver::report_ice
                               at C:\src\rust\compiler\rustc_driver\src\lib.rs:1182
  12:     0x7ffa13ef51ef - std::panicking::rust_panic_with_hook
                               at C:\src\rust\library\std\src\panicking.rs:626
  13:     0x7ffa13ef4da1 - std::panicking::begin_panic_handler::{{closure}}
                               at C:\src\rust\library\std\src\panicking.rs:519
  14:     0x7ffa13ef3a6f - std::sys_common::backtrace::__rust_end_short_backtrace
                               at C:\src\rust\library\std\src\sys_common\backtrace.rs:141
  15:     0x7ffa13ef4cf2 - std::panicking::begin_panic_handler
                               at C:\src\rust\library\std\src\panicking.rs:515
  16:     0x7ffa13f39a30 - core::panicking::panic_fmt
                               at C:\src\rust\library\core\src\panicking.rs:92
  17:     0x7ff9d4a4525a - rustc_target::abi::FieldsShape::offset
                               at C:\src\rust\compiler\rustc_target\src\abi\mod.rs:764
  18:     0x7ff9d47ff58a - rustc_middle::ty::layout::{{impl}}::record_layout_for_printing_outlined::{{closure}}::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:1774
  19:     0x7ff9d47ff58a - core::iter::adapters::map::map_fold::{{closure}}
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:82
  20:     0x7ff9d47ff58a - core::iter::adapters::enumerate::{{impl}}::fold::enumerate::{{closure}}
                               at C:\src\rust\library\core\src\iter\adapters\enumerate.rs:104
  21:     0x7ff9d47ff58a - core::iter::traits::iterator::Iterator::fold
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:2173
  22:     0x7ff9d47ff58a - core::iter::adapters::enumerate::{{impl}}::fold
                               at C:\src\rust\library\core\src\iter\adapters\enumerate.rs:110
  23:     0x7ff9d47ff58a - core::iter::adapters::map::{{impl}}::fold>,closure-0,tuple<>,closure-0>
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:122
  24:     0x7ff9d4781571 - core::iter::traits::iterator::Iterator::for_each
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:736
  25:     0x7ff9d4781571 - alloc::vec::spec_extend::{{impl}}::spec_extend
                               at C:\src\rust\library\alloc\src\vec\spec_extend.rs:97
  26:     0x7ff9d4781571 - alloc::vec::spec_from_iter_nested::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter_nested.rs:56
  27:     0x7ff9d4781571 - alloc::vec::spec_from_iter::{{impl}}::from_iter>, closure-0>>
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter.rs:33
  28:     0x7ff9d48d751f - alloc::vec::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\mod.rs:2461
  29:     0x7ff9d48d751f - core::iter::traits::iterator::Iterator::collect
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:1748
  30:     0x7ff9d48d751f - rustc_middle::ty::layout::{{impl}}::record_layout_for_printing_outlined::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:1732
  31:     0x7ff9d48d751f - rustc_middle::ty::layout::LayoutCx::record_layout_for_printing_outlined
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:1808
  32:     0x7ff9d48d751f - rustc_middle::ty::layout::LayoutCx::record_layout_for_printing
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:1717
  33:     0x7ff9d48d751f - rustc_middle::ty::layout::{{impl}}::layout_of
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:2051
  34:     0x7ff9d480246c - rustc_middle::ty::layout::{{impl}}::layout_raw_uncached::{{closure}}::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:804
  35:     0x7ff9d480246c - core::iter::adapters::map::map_try_fold::{{closure}}
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:89
  36:     0x7ff9d480246c - core::iter::traits::iterator::Iterator::try_fold
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:1997
  37:     0x7ff9d480246c - core::iter::adapters::map::{{impl}}::try_fold, rustc_middle::ty::layout::LayoutError>,core::slice::iter::Iter,closure-0,tuple<>,closure-0,core::ops::co
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:115
  38:     0x7ff9d48bc004 - core::iter::adapters::{{impl}}::try_fold
                               at C:\src\rust\library\core\src\iter\adapters\mod.rs:174
  39:     0x7ff9d48bc004 - core::iter::traits::iterator::Iterator::find
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:2385
  40:     0x7ff9d48bc004 - core::iter::adapters::{{impl}}::next, closure-0>,rustc_target::abi::TyAndLayout,rustc_middle::ty::layout::LayoutError>
                               at C:\src\rust\library\core\src\iter\adapters\mod.rs:156
  41:     0x7ff9d4781826 - alloc::vec::spec_from_iter_nested::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter_nested.rs:52
  42:     0x7ff9d4781826 - alloc::vec::spec_from_iter::{{impl}}::from_iter,core::iter::adapters::ResultShunt, closure-0>, rustc_middle::ty::layo
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter.rs:33
  43:     0x7ff9d48c0417 - alloc::vec::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\mod.rs:2461
  44:     0x7ff9d48c0417 - core::iter::traits::iterator::Iterator::collect
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:1748
  45:     0x7ff9d48c0417 - core::result::{{impl}}::from_iter::{{closure}}
                               at C:\src\rust\library\core\src\result.rs:1625
  46:     0x7ff9d48c0417 - core::iter::adapters::process_results, closure-0>,rustc_target::abi::TyAndLayout,rustc_middle::ty::layout::LayoutError,closure-0,alloc::vec::Vec, alloc::alloc::Global>, rustc_middle::ty::layout::LayoutError>,core::slice::iter::Iter,
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:115
  53:     0x7ff9d48bc055 - core::iter::adapters::{{impl}}::try_fold
                               at C:\src\rust\library\core\src\iter\adapters\mod.rs:174
  54:     0x7ff9d48bc055 - core::iter::traits::iterator::Iterator::find
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:2385
  55:     0x7ff9d48bc055 - core::iter::adapters::{{impl}}::next, closure-5>,alloc::vec::Vec, alloc::alloc::Global>,rustc_middle::ty::layout::L
                               at C:\src\rust\library\core\src\iter\adapters\mod.rs:156
  56:     0x7ff9d478597f - alloc::vec::Vec::extend_desugared
                               at C:\src\rust\library\alloc\src\vec\mod.rs:2558
  57:     0x7ff9d478597f - alloc::vec::spec_extend::{{impl}}::spec_extend
                               at C:\src\rust\library\alloc\src\vec\spec_extend.rs:84
  58:     0x7ff9d478597f - alloc::vec::spec_from_iter_nested::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter_nested.rs:66
  59:     0x7ff9d478597f - alloc::vec::spec_from_iter::{{impl}}::from_iter, alloc::alloc::Global>,core::iter::adapters::ResultShunt,closure-0>
                               at C:\src\rust\compiler\rustc_data_structures\src\stack.rs:16
  82:     0x7ff9d39eaf59 - rustc_query_impl::plumbing::{{impl}}::start_query::{{closure}}::{{closure}}
                               at C:\src\rust\compiler\rustc_query_impl\src\plumbing.rs:133
  83:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::enter_context::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1744
  84:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::set_tlv
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1728
  85:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::enter_context
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1744
  86:     0x7ff9d39eaf59 - rustc_query_impl::plumbing::{{impl}}::start_query::{{closure}}
                               at C:\src\rust\compiler\rustc_query_impl\src\plumbing.rs:132
  87:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::with_related_context::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1788
  88:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::with_context::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1772
  89:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::with_context_opt
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1761
  90:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::with_context
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1772
  91:     0x7ff9d39eaf59 - rustc_middle::ty::context::tls::with_related_context
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1785
  92:     0x7ff9d39eaf59 - rustc_query_impl::plumbing::{{impl}}::start_query
                               at C:\src\rust\compiler\rustc_query_impl\src\plumbing.rs:121
  93:     0x7ff9d39eaf59 - rustc_query_system::query::plumbing::try_execute_query
                               at C:\src\rust\compiler\rustc_query_system\src\query\plumbing.rs:461
  94:     0x7ff9d39eaf59 - rustc_query_system::query::plumbing::get_query_impl, core::result::Result
                               at C:\src\rust\compiler\rustc_query_system\src\query\plumbing.rs:828
  96:     0x7ff9d38c7bbe - rustc_query_impl::{{impl}}::layout_raw
                               at C:\src\rust\compiler\rustc_query_impl\src\plumbing.rs:552
  97:     0x7ff9d48d71dc - rustc_middle::ty::query::TyCtxtAt::layout_raw
                               at C:\src\rust\compiler\rustc_middle\src\ty\query\mod.rs:206
  98:     0x7ff9d48d71dc - rustc_middle::ty::context::TyCtxt::layout_raw
                               at C:\src\rust\compiler\rustc_middle\src\ty\query\mod.rs:187
  99:     0x7ff9d48d71dc - rustc_middle::ty::layout::{{impl}}::layout_of
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:2042
 100:     0x7ff9d30dab68 - rustc_middle::ty::context::TyCtxt::layout_of
                               at C:\src\rust\compiler\rustc_middle\src\ty\layout.rs:2092
 101:     0x7ff9d30dab68 - rustc_codegen_llvm::context::{{impl}}::spanned_layout_of
                               at C:\src\rust\compiler\rustc_codegen_llvm\src\context.rs:797
 102:     0x7ff9d30dab68 - rustc_codegen_ssa::mir::analyze::non_ssa_locals::{{closure}}
                               at C:\src\rust\compiler\rustc_codegen_ssa\src\mir\analyze.rs:25
 103:     0x7ff9d30dab68 - core::iter::adapters::map::map_fold::{{closure}}
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:82
 104:     0x7ff9d30dab68 - core::iter::traits::iterator::Iterator::fold
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:2173
 105:     0x7ff9d30dab68 - core::iter::adapters::map::{{impl}}::fold,closure-0,tuple<>,closure-0>
                               at C:\src\rust\library\core\src\iter\adapters\map.rs:122
 106:     0x7ff9d31756a2 - core::iter::traits::iterator::Iterator::for_each
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:736
 107:     0x7ff9d31756a2 - alloc::vec::spec_extend::{{impl}}::spec_extend
                               at C:\src\rust\library\alloc\src\vec\spec_extend.rs:40
 108:     0x7ff9d31756a2 - alloc::vec::spec_from_iter_nested::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter_nested.rs:56
 109:     0x7ff9d31756a2 - alloc::vec::spec_from_iter::{{impl}}::from_iter, closure-0>>
                               at C:\src\rust\library\alloc\src\vec\spec_from_iter.rs:33
 110:     0x7ff9d30fda4f - alloc::vec::{{impl}}::from_iter
                               at C:\src\rust\library\alloc\src\vec\mod.rs:2461
 111:     0x7ff9d30fda4f - rustc_index::vec::{{impl}}::from_iter
                               at C:\src\rust\compiler\rustc_index\src\vec.rs:786
 112:     0x7ff9d30fda4f - core::iter::traits::iterator::Iterator::collect
                               at C:\src\rust\library\core\src\iter\traits\iterator.rs:1748
 113:     0x7ff9d30fda4f - rustc_codegen_ssa::mir::analyze::non_ssa_locals
                               at C:\src\rust\compiler\rustc_codegen_ssa\src\mir\analyze.rs:20
 114:     0x7ff9d31999e2 - rustc_codegen_ssa::mir::codegen_mir
                               at C:\src\rust\compiler\rustc_codegen_ssa\src\mir\mod.rs:210
 115:     0x7ff9d3164262 - rustc_codegen_ssa::base::codegen_instance
                               at C:\src\rust\compiler\rustc_codegen_ssa\src\base.rs:343
 116:     0x7ff9d313fe4c - rustc_codegen_ssa::mono_item::{{impl}}::define
                               at C:\src\rust\compiler\rustc_codegen_ssa\src\mono_item.rs:70
 117:     0x7ff9d3158c6b - rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
                               at C:\src\rust\compiler\rustc_codegen_llvm\src\base.rs:141
 118:     0x7ff9d31455a5 - rustc_query_system::dep_graph::graph::DepGraph::with_task_impl
                               at C:\src\rust\compiler\rustc_query_system\src\dep_graph\graph.rs:278
 119:     0x7ff9d31455a5 - rustc_query_system::dep_graph::graph::DepGraph::with_task,fn(mut rustc_middle::ich::hc
                               at C:\src\rust\compiler\rustc_query_system\src\dep_graph\graph.rs:213
 120:     0x7ff9d31587a2 - rustc_codegen_llvm::base::compile_codegen_unit
                               at C:\src\rust\compiler\rustc_codegen_llvm\src\base.rs:117
 121:     0x7ff9d31622cc - rustc_codegen_llvm::{{impl}}::compile_codegen_unit
                               at C:\src\rust\compiler\rustc_codegen_llvm\src\lib.rs:107
 122:     0x7ff9d31622cc - rustc_codegen_ssa::base::codegen_crate
                               at C:\src\rust\compiler\rustc_codegen_ssa\src\base.rs:647
 123:     0x7ff9d314f3da - rustc_codegen_llvm::{{impl}}::codegen_crate
                               at C:\src\rust\compiler\rustc_codegen_llvm\src\lib.rs:257
 124:     0x7ff9d2ff2cac - rustc_interface::passes::start_codegen::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\passes.rs:1060
 125:     0x7ff9d2ff2cac - rustc_data_structures::profiling::VerboseTimingGuard::run
                               at C:\src\rust\compiler\rustc_data_structures\src\profiling.rs:573
 126:     0x7ff9d2ff2cac - rustc_session::session::Session::time,closure-0>
                               at C:\src\rust\compiler\rustc_session\src\utils.rs:16
 127:     0x7ff9d300dd5a - rustc_interface::passes::start_codegen
                               at C:\src\rust\compiler\rustc_interface\src\passes.rs:1059
 128:     0x7ff9d302be30 - rustc_interface::queries::{{impl}}::ongoing_codegen::{{closure}}::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\queries.rs:295
 129:     0x7ff9d302be30 - rustc_interface::passes::{{impl}}::enter::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\passes.rs:799
 130:     0x7ff9d302be30 - rustc_middle::ty::context::tls::enter_context::{{closure}}
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1744
 131:     0x7ff9d302be30 - rustc_middle::ty::context::tls::set_tlv
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1728
 132:     0x7ff9d302be30 - rustc_middle::ty::context::tls::enter_context
                               at C:\src\rust\compiler\rustc_middle\src\ty\context.rs:1744
 133:     0x7ff9d302be30 - rustc_interface::passes::QueryContext::enter
                               at C:\src\rust\compiler\rustc_interface\src\passes.rs:799
 134:     0x7ff9d302be30 - rustc_interface::queries::{{impl}}::ongoing_codegen::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\queries.rs:286
 135:     0x7ff9d302be30 - rustc_interface::queries::Query::compute,closure-0>
                               at C:\src\rust\compiler\rustc_interface\src\queries.rs:40
 136:     0x7ff9d2ffd62a - rustc_interface::queries::Queries::ongoing_codegen
                               at C:\src\rust\compiler\rustc_interface\src\queries.rs:284
 137:     0x7ff9d2f6607d - rustc_driver::run_compiler::{{closure}}::{{closure}}
                               at C:\src\rust\compiler\rustc_driver\src\lib.rs:414
 138:     0x7ff9d2f6607d - rustc_interface::interface::Compiler::enter, rustc_errors::ErrorReported>>
                               at C:\src\rust\compiler\rustc_interface\src\queries.rs:431
 139:     0x7ff9d2f722d0 - rustc_driver::run_compiler::{{closure}}
                               at C:\src\rust\compiler\rustc_driver\src\lib.rs:313
 140:     0x7ff9d2f722d0 - rustc_interface::interface::create_compiler_and_run::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\interface.rs:208
 141:     0x7ff9d2f722d0 - rustc_span::with_source_map, rustc_errors::ErrorReported>,closure-0>
                               at C:\src\rust\compiler\rustc_span\src\lib.rs:873
 142:     0x7ff9d2f64a32 - rustc_interface::interface::create_compiler_and_run
                               at C:\src\rust\compiler\rustc_interface\src\interface.rs:202
 143:     0x7ff9d2f64a32 - rustc_interface::interface::run_compiler::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\interface.rs:224
 144:     0x7ff9d2f64a32 - rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\util.rs:158
 145:     0x7ff9d2f64a32 - scoped_tls::ScopedKey::set, rustc_errors::ErrorReported>>
                               at C:\Users\xxx\.cargo\registry\src\github.heygears.com-1ecc6299db9ec823\scoped-tls-1.0.0\src\lib.rs:137
 146:     0x7ff9d2f72df8 - rustc_span::with_session_globals, rustc_errors::ErrorReported>,closure-0>
                               at C:\src\rust\compiler\rustc_span\src\lib.rs:104
 147:     0x7ff9d2f7be91 - rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\util.rs:156
 148:     0x7ff9d2f7be91 - rustc_interface::util::scoped_thread::{{closure}}
                               at C:\src\rust\compiler\rustc_interface\src\util.rs:131
 149:     0x7ff9d2f7be91 - std::sys_common::backtrace::__rust_begin_short_backtrace>
                               at C:\src\rust\library\std\src\sys_common\backtrace.rs:125
 150:     0x7ff9d2f5fea7 - std::thread::{{impl}}::spawn_unchecked::{{closure}}::{{closure}}
                               at C:\src\rust\library\std\src\thread\mod.rs:476
 151:     0x7ff9d2f5fea7 - std::panic::{{impl}}::call_once
                               at C:\src\rust\library\std\src\panic.rs:347
 152:     0x7ff9d2f5fea7 - std::panicking::try::do_call
                               at C:\src\rust\library\std\src\panicking.rs:401
 153:     0x7ff9d2f5fea7 - std::panicking::try,std::panic::AssertUnwindSafe>
                               at C:\src\rust\library\std\src\panicking.rs:365
 154:     0x7ff9d2f6e639 - std::panic::catch_unwind
                               at C:\src\rust\library\std\src\panic.rs:434
 155:     0x7ff9d2f6e639 - std::thread::{{impl}}::spawn_unchecked::{{closure}}
                               at C:\src\rust\library\std\src\thread\mod.rs:475
 156:     0x7ff9d2f6e639 - core::ops::function::FnOnce::call_once>
                               at C:\src\rust\library\core\src\ops\function.rs:227
 157:     0x7ffa13eeae5c - alloc::boxed::{{impl}}::call_once
                               at C:\src\rust\library\alloc\src\boxed.rs:1575
 158:     0x7ffa13eeae5c - alloc::boxed::{{impl}}::call_once
                               at C:\src\rust\library\alloc\src\boxed.rs:1575
 159:     0x7ffa13eeae5c - std::sys::windows::thread::{{impl}}::new::thread_start
                               at C:\src\rust\library\std\src\sys\windows\thread.rs:57
 160:     0x7ffa5b697034 - BaseThreadInitThunk
 161:     0x7ffa5c6e2651 - RtlUserThreadStart

fanninpm added a commit to fanninpm/glacier that referenced this issue Jul 4, 2021
@JohnTitor JohnTitor removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Jul 6, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jul 6, 2021
@JohnTitor
Copy link
Member

Triage: #86761 removed the ICE but it doesn't seem like an actual fix. Any other examples to reproduce it?

@jyn514
Copy link
Member Author

jyn514 commented Jul 18, 2021

This still ICEs on docs.rs.

thread 'rustc' panicked at 'internal error: entered unreachable code: FieldsShape::offset: `Primitive`s have no fields', compiler/rustc_target/src/abi/mod.rs:764:17
Backtrace
   0: rust_begin_unwind
             at /rustc/c7331d65bdbab1187f5a9b8f5b918248678ebdb9/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c7331d65bdbab1187f5a9b8f5b918248678ebdb9/library/core/src/panicking.rs:92:14
   2: rustc_target::abi::FieldsShape::offset
   3: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of
   6: <rustc_codegen_llvm::context::CodegenCx as rustc_target::abi::LayoutOf>::spanned_layout_of
   7: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   8: <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold
   9: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  10: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal
  11: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::of_instance
  12: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
  13: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  15: rustc_codegen_llvm::base::compile_codegen_unit
  16: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  17: rustc_interface::passes::QueryContext::enter
  18: rustc_interface::queries::Queries::ongoing_codegen
  19: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  20: rustc_span::with_source_map
  21: rustc_interface::interface::create_compiler_and_run
  22: scoped_tls::ScopedKey<T>::set

note: rustc 1.55.0-nightly (c7331d65b 2021-07-17) running on x86_64-unknown-linux-gnu

@Chris--B
Copy link

I ran this on vulkano-rs/vulkano@ab01ae7 (master at the time of testing)
cargo +nightly rustc -- -Zprint-type-sizes

There is an issue with Vulkano that overflows the stack because of some huge structs, and looking for a clippy lint I found this nightly flag. Gave it a go. Oops?

Meta

rustc --version --verbose:

rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-apple-darwin
release: 1.54.0
LLVM version: 12.0.1

Error output

thread 'rustc' panicked at 'internal error: entered unreachable code: FieldsShape::offset: `Primitive`s have no fields', compiler/rustc_target/src/abi/mod.rs:781:17
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.56.0-nightly (af140757b 2021-08-22) running on x86_64-apple-darwin

note: compiler flags: -Z print-type-sizes -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
end of query stack
warning: `vulkano` (lib) generated 2 warnings
error: could not compile `vulkano`; 2 warnings emitted

Backtrace

stack backtrace:
   0:        0x10626b431 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h48a34cf9e392861a
   1:        0x1062bb3ed - core::fmt::write::h8160330c41daaf61
   2:        0x10625cf7a - std::io::Write::write_fmt::h96cef022ec8f7c98
   3:        0x10626e845 - std::panicking::default_hook::{{closure}}::h0e535124ce564aa4
   4:        0x10626e42c - std::panicking::default_hook::ha71ede6560618eb7
   5:        0x10b962708 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h368c83eb55044bb7
   6:        0x10626f086 - std::panicking::rust_panic_with_hook::h0972190e91792801
   7:        0x10626eafe - std::panicking::begin_panic_handler::{{closure}}::h01a54edb492b70d4
   8:        0x10626b8c7 - std::sys_common::backtrace::__rust_end_short_backtrace::hc48a9aab75427fc4
   9:        0x10626ea6a - _rust_begin_unwind
  10:        0x1062e654f - core::panicking::panic_fmt::h2e3306ce37bd7247
  11:        0x10fe79c9a - rustc_target::abi::FieldsShape::offset::hfd4cf83702c75039
  12:        0x10fbcc3c7 - <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold::h2cbd7a737c59b179
  13:        0x10fbc7a63 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::h79ffd67a13d3a9d6
  14:        0x10fbecebe - rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt>::record_layout_for_printing_outlined::{{closure}}::h8e536359c823a4ee
  15:        0x10fbee09a - <rustc_middle::ty::layout::LayoutCx<rustc_middle::ty::context::TyCtxt> as rustc_target::abi::LayoutOf>::layout_of::hbd28d2902a701d18
  16:        0x10bbf279d - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h18e176ba2ab183ee
  17:        0x10bbfb8fb - <core::iter::adapters::chain::Chain<A,B> as core::iter::traits::iterator::Iterator>::fold::h799903408cddae55
  18:        0x10bb6dbf3 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::h2d63cf092896c881
  19:        0x10bc11665 - <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::new_internal::h6b4ac1529e739edb
  20:        0x10bc11008 - <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::of_instance::h59d454373b5cacaa
  21:        0x10bbc6d8e - rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn::h6baa1d862020acd8
  22:        0x10bbfa96a - rustc_codegen_llvm::base::compile_codegen_unit::module_codegen::h4899f239f9899df6
  23:        0x10bbcd0a7 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h6f2b5464c6200537
  24:        0x10bbfa26a - rustc_codegen_llvm::base::compile_codegen_unit::hacdf15d8b3940747
  25:        0x10bb9d467 - rustc_codegen_ssa::base::codegen_crate::h742d61e022cd1ec7
  26:        0x10bbe4560 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h05fb9130036d6c8a
  27:        0x10ba8104d - rustc_interface::queries::Queries::ongoing_codegen::h46c464fb5cff49c4
  28:        0x10b9a22cc - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::h14dfcdb394aff575
  29:        0x10b96dc8e - rustc_span::with_source_map::h5e4953ed546e8a02
  30:        0x10b99fa36 - scoped_tls::ScopedKey<T>::set::h14ee411341c0e6ff
  31:        0x10b96ea29 - std::sys_common::backtrace::__rust_begin_short_backtrace::hee28e6cddabf9af9
  32:        0x10b965b6d - core::ops::function::FnOnce::call_once{{vtable.shim}}::h0c7b72c6ba13b917
  33:        0x10627a507 - std::sys::unix::thread::Thread::new::thread_start::ha97bc2d64cfc5adc
  34:     0x7fff204138fc - __pthread_start

@Skepfyr
Copy link
Contributor

Skepfyr commented Sep 4, 2021

I have another minimal reproducer, it's no more enlightening than the first:

pub fn test() {
    Vec::<()>::new()
        .into_iter()
        .filter(|_| true)
        .collect::<Vec<_>>();
}

@nazar-pc
Copy link

Crashed for me on serde_repr crate:

thread 'rustc' panicked at 'internal error: entered unreachable code: FieldsShape::offset: `Primitive`s have no fields', /rustc/9bb77da74dac4768489127d21e32db19b59ada5b/compiler/rustc_target/src/abi/mod.rs:895:17
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-nightly (9bb77da74 2021-09-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z print-type-sizes -C prefer-dynamic -C embed-bitcode=no -C debug-assertions=off --crate-type proc-macro

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

query stack during panic:
#0 [layout_of] computing layout of `std::result::Result<std::convert::Infallible, !>`
#1 [layout_of] computing layout of `std::ops::ControlFlow<std::result::Result<std::convert::Infallible, !>>`
end of query stack
error: could not compile `serde_repr`

Manishearth added a commit to Manishearth/rust that referenced this issue Oct 6, 2021
… r=jackh726

print-type-sizes: skip field printing for primitives

Fixes rust-lang#86528.
@bors bors closed this as completed in b87a9a8 Oct 6, 2021
@jyn514
Copy link
Member Author

jyn514 commented Oct 7, 2021

Yay, this works on docs.rs now 🎉

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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