Skip to content

ICE when trying to Add a Vec and vec![] on 1.17 nightly #40610

Closed
@kennytm

Description

@kennytm

Repro case:

fn r(v: Vec<f32>) {
    v + <[f32]>::into_vec(Box::new([])); 
}

The <[f32]>::into_vec(Box::new([])) is expanded from vec![].

No ICE on 1.16 stable.
No ICE when trying using -, *, / etc.
No ICE when swapping the two arguments vec![] + v.
No ICE when using v + Vec::new().
No ICE when not using UFCS v + (Box::new([]) as Box<[f32]>).into_vec();


Error (panic on this line):

error: main function not found

error[E0369]: binary operation `+` cannot be applied to type `std::vec::Vec<f32>`
 --> 1.rs:2:5
  |
2 |     v + <[f32]>::into_vec(Box::new([]));
  |     ^
  |
  = note: an implementation of `std::ops::Add` might be missing for `std::vec::Vec<f32>`

error: internal compiler error: src/librustc_typeck/check/coercion.rs:693: expr already has an adjustment on it!

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:418
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: rustc_errors::Handler::bug
   1: rustc::session::opt_span_bug_fmt::{{closure}}
   2: rustc::session::opt_span_bug_fmt
   3: rustc::session::bug_fmt
   4: rustc_typeck::check::coercion::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::try_coerce
   5: rustc_typeck::check::demand::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::demand_coerce
   6: rustc_typeck::check::FnCtxt::check_argument_types
   7: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call
   8: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_call
   9: rustc_typeck::check::FnCtxt::check_expr_kind
  10: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  11: rustc_typeck::check::op::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_overloaded_binop
  12: rustc_typeck::check::op::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_binop
  13: rustc_typeck::check::FnCtxt::check_expr_kind
  14: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  15: rustc_typeck::check::FnCtxt::check_stmt
  16: rustc_typeck::check::FnCtxt::check_block_with_expected
  17: rustc_typeck::check::FnCtxt::check_expr_kind
  18: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  19: rustc_typeck::check::check_fn
  20: rustc_typeck::check::typeck_tables
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::try_get
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::get
  23: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::item_tables
  24: rustc_typeck::check::check_item_bodies
  25: rustc_typeck::check_crate
  26: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  27: rustc_driver::driver::phase_3_run_analysis_passes
  28: rustc_driver::driver::compile_input
  29: rustc_driver::run_compiler
  30: std::panicking::try::do_call
  31: __rust_maybe_catch_panic
  32: <F as alloc::boxed::FnBox<A>>::call_box
  33: std::sys::imp::thread::Thread::new::thread_start
  34: _pthread_body
  35: _pthread_start

Version:

$ rustc +nightly -vV
rustc 1.17.0-nightly (0aeb9c129 2017-03-15)
binary: rustc
commit-hash: 0aeb9c12979e6da753701a798d04105b6b1a8c28
commit-date: 2017-03-15
host: x86_64-apple-darwin
release: 1.17.0-nightly
LLVM version: 3.9

Metadata

Metadata

Assignees

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions