Closed
Description
The compiler panics when there's a std::mem::size_of
call for a struct with repr(packed)
that contains a matrix type from nalgebra. I'm fairly new to rust and I'm not sure how to isolate what within the nalgebra crate might be causing this.
src/main.rs:
use nalgebra as na;
#[repr(packed)]
struct Foo(na::Vector3<f32>);
fn main() {
std::mem::size_of::<Foo>();
}
Cargo.toml
[package]
name = "test"
version = "0.1.0"
authors = ["Robert Grindeland <[email protected]>"]
edition = "2018"
[dependencies]
nalgebra = "0.16.13"
Result of RUST_BACKTRACE=1 cargo build --verbose
$ RUST_BACKTRACE=1 cargo build --verbose
Fresh rand_core v0.4.0
Fresh libm v0.1.2
Fresh rawpointer v0.1.0
Fresh rand_core v0.3.1
Fresh num-traits v0.2.6
Fresh winapi v0.3.6
Fresh typenum v1.10.0
Fresh matrixmultiply v0.1.15
Fresh num-complex v0.2.1
Fresh approx v0.3.1
Fresh rand v0.5.6
Fresh generic-array v0.11.1
Fresh alga v0.7.2
Fresh nalgebra v0.16.13
Compiling test v0.1.0 (C:\Users\Rob\Documents\Programming\cpp\compiler-bug)
Running `rustc --edition=2018 --crate-name test 'src\main.rs' --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=9be42db9345f3907 -C extra-filename=-9be42db9345f3907 --out-dir 'C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\deps' -C 'incremental=C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\incremental' -L 'dependency=C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\deps' --extern 'nalgebra=C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\deps\libnalgebra-4080678600ea4cae.rlib'`
error: internal compiler error: librustc_typeck\check\wfcheck.rs:261: inference variables in nalgebra::base::matrix::Matrix<f32, nalgebra::base::dimension::U3, nalgebra::base::dimension::U1, nalgebra::base::array_storage::ArrayStorage<_, _, _>>
--> src\main.rs:4:1
|
4 | struct Foo(na::Vector3<f32>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'main' panicked at 'Box<Any>', librustc_errors\lib.rs:538:9
stack backtrace:
0: <std::sync::mpsc::select::Select as core::fmt::Debug>::fmt
1: std::path::<impl core::convert::From<std::path::PathBuf> for std::ffi::os_str::OsString>::from
2: std::panicking::take_hook
3: std::panicking::take_hook
4: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
5: std::panicking::rust_panic_with_hook
6: rustc_typeck::collect::early_bound_lifetimes_from_generics
7: rustc_typeck::collect::early_bound_lifetimes_from_generics
8: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
9: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
10: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
11: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
12: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
13: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
14: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
15: <rustc_typeck::outlives::explicit::ExplicitPredicatesMap<'tcx> as core::fmt::Debug>::fmt
16: <rustc_typeck::check::method::probe::ProbeScope as core::fmt::Debug>::fmt
17: <rustc_typeck::check::upvar::InferBorrowKind<'a, 'gcx, 'tcx> as rustc::middle::expr_use_visitor::Delegate<'tcx>>::mutate
18: <rustc::traits::query::outlives_bounds::OutlivesBound<'a> as rustc::ty::context::Lift<'tcx>>::lift_to_tcx
19: rustc::ty::context::tls::track_diagnostic
20: rustc::dep_graph::graph::DepGraph::assert_ignored
21: rustc::ty::adjustment::<impl core::convert::From<rustc::ty::adjustment::AutoBorrowMutability> for rustc::hir::Mutability>::from
22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
24: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
25: <rustc_typeck::outlives::implicit_infer::IgnoreSelfTy as core::fmt::Debug>::fmt
26: <rustc_typeck::check::regionck::RegionCtxt<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::nested_visit_map
27: rustc_typeck::check_crate
28: <humantime::date::Error as std::error::Error>::cause
29: <rustc_driver::pretty::NoAnn<'hir> as rustc_driver::pretty::HirPrinterSupport<'hir>>::sess
30: <humantime::date::Error as std::error::Error>::cause
31: rustc_driver::driver::compile_input
32: rustc_driver::run_compiler
33: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
34: rustc_driver::run_compiler
35: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
36: _rust_maybe_catch_panic
37: <unknown>
38: rustc_driver::main
39: <unknown>
40: std::panicking::update_panic_count
41: _rust_maybe_catch_panic
42: std::rt::lang_start_internal
43: <unknown>
44: <unknown>
45: BaseThreadInitThunk
46: RtlUserThreadStart
query stack during panic:
#0 [check_item_well_formed] processing `Foo`
end of query stack
error: aborting due to previous error
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.31.1 (b6c32da9b 2018-12-18) running on x86_64-pc-windows-msvc
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 `test`.
Caused by:
process didn't exit successfully: `rustc --edition=2018 --crate-name test 'src\main.rs' --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=9be42db9345f3907 -C extra-filename=-9be42db9345f3907 --out-dir 'C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\deps' -C 'incremental=C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\incremental' -L 'dependency=C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\deps' --extern 'nalgebra=C:\Users\Rob\Documents\Programming\cpp\compiler-bug\target\debug\deps\libnalgebra-4080678600ea4cae.rlib'` (exit code: 101)