Skip to content

Compiler panic when manually indexing vectors #41117

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

Closed
urschrei opened this issue Apr 6, 2017 · 2 comments
Closed

Compiler panic when manually indexing vectors #41117

urschrei opened this issue Apr 6, 2017 · 2 comments

Comments

@urschrei
Copy link
Contributor

urschrei commented Apr 6, 2017

I'm manually indexing some vectors using a usize field from a struct. This is causing a compiler panic.

Code: commit c624f56 at https://github.com/urschrei/rust-geo/tree/polygon_distance.

Rustc version:
nightly-x86_64-apple-darwin
rustc 1.18.0-nightly (91ae22a01 2017-04-05)

Full Backtrace (under dropdown):

error: internal compiler error: src/librustc_typeck/check/coercion.rs:718: expr already has an adjustment on it!
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:416
stack backtrace:
 0:        0x10ad96953 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hbdeac7eba2f064c6
 1:        0x10ada36ed - std::panicking::default_hook::{{closure}}::h9e0a6ca9bb64b479
 2:        0x10ada3234 - std::panicking::default_hook::h9043ae80af471c9f
 3:        0x10ada5e57 - std::panicking::rust_panic_with_hook::h05996066754c6be9
 4:        0x10833994a - std::panicking::begin_panic::hf47fe75ea38aa60c
 5:        0x108351194 - rustc_errors::Handler::bug::h5c4d3c22f7d6cf5f
 6:        0x10754f46c - rustc::session::opt_span_bug_fmt::{{closure}}::hc30486983bf7baa5
 7:        0x10754f270 - rustc::session::opt_span_bug_fmt::hbb1ce5f815a221d0
 8:        0x10754edfa - rustc::session::bug_fmt::h603b74c583ab5af8
 9:        0x106634f2d - rustc_typeck::check::coercion::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::try_coerce::hf1afc4fb1f0fd049
10:        0x1066463c7 - rustc_typeck::check::demand::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::demand_coerce::h5e0424652dca67df
11:        0x106698e9a - rustc_typeck::check::FnCtxt::check_argument_types::h6c5ac67922ecc7f4
12:        0x10669816d - rustc_typeck::check::FnCtxt::check_method_argument_types::hdfcaa2508888d95b
13:        0x1066a34b8 - rustc_typeck::check::FnCtxt::check_expr_kind::h1135e8c4361f6473
14:        0x10669eb20 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h1bb7590703cfb153
15:        0x10669a2f6 - rustc_typeck::check::FnCtxt::check_expr_has_type::heef4496f4d358bdf
16:        0x1066a437d - rustc_typeck::check::FnCtxt::check_expr_kind::h1135e8c4361f6473
17:        0x10669eb20 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h1bb7590703cfb153
18:        0x1066a6fa7 - rustc_typeck::check::FnCtxt::check_decl_initializer::hb2018bec0565c8ca
19:        0x1066a708c - rustc_typeck::check::FnCtxt::check_decl_local::h42d2a6e470f71fbe
20:        0x1066a72e1 - rustc_typeck::check::FnCtxt::check_stmt::h10977bf77ab03006
21:        0x1066a7cee - rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}::h4fc16531f0890bf6
22:        0x1066a7746 - rustc_typeck::check::FnCtxt::check_block_with_expected::ha99b44f2b0900127
23:        0x10669f9bc - rustc_typeck::check::FnCtxt::check_expr_kind::h1135e8c4361f6473
24:        0x10669eb20 - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h1bb7590703cfb153
25:        0x10669b13d - rustc_typeck::check::FnCtxt::check_return_expr::h31d207f50840039d
26:        0x10668b93e - rustc_typeck::check::check_fn::ha1265f1a8a15cfc7
27:        0x10668a12b - rustc_typeck::check::typeck_tables::h8f56b5a1240db926
28:        0x10762ad01 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::try_get::h48076491a959043c
29:        0x10762aeb3 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::get::hac6c722e7d137c6c
30:        0x1075df12c - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::item_tables::h0cc43c4a7e140596
31:        0x106689062 - rustc_typeck::check::typeck_item_bodies::h023401d8604ce9d6
32:        0x107629fcd - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get::ha8f2587920e8897e
33:        0x10762a1d2 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::get::h355bebb502605440
34:        0x1066e16ef - rustc_typeck::check_crate::hbd024fa93952a70d
35:        0x10628e710 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h268f1787328becc3
36:        0x1061dc844 - rustc::ty::context::TyCtxt::create_and_enter::h6fdf5bf007c6624c
37:        0x10628bc34 - rustc_driver::driver::phase_3_run_analysis_passes::he1ec91c87e760611
38:        0x10625cbad - rustc_driver::driver::compile_input::h2d34c130b0e09b8d
39:        0x1062b85cb - rustc_driver::run_compiler::hc1973c7a7c291533
40:        0x10618c928 - std::panicking::try::do_call::hc2d47b7090d8b7b0
41:        0x10ada8c6a - __rust_maybe_catch_panic
42:        0x1061d2a6f - <F as alloc::boxed::FnBox<A>>::call_box::h39cb667f07a35289
43:        0x10ada26d4 - std::sys::imp::thread::Thread::new::thread_start::h4008e1859fbd98b8
44:     0x7fffd89bbaaa - _pthread_body
45:     0x7fffd89bb9f6 - _pthread_start
@est31
Copy link
Member

est31 commented Apr 6, 2017

@urschrei its rejecting invalid code. &Polygon can't be indexed. Still, an ICE is a bug.

Minimized example:

struct Bar();

impl Bar {
    fn nv(&self, _: &()) -> usize { 42 }
}

fn foo(p: &Bar) {
    let _ = p[p.nv(&())];
}

fn main() {}

@eddyb
Copy link
Member

eddyb commented Apr 6, 2017

Closing as duplicate of #40861.

@eddyb eddyb closed this as completed Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants