Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

ICE in type inference? type checking? on broken/wrong BTreeMap code, if inserting into BTreeMap #108042

Closed

Description

@wareya

Ran into an ICE while refactoring. Only happens on nightly. Don't know what else I should write here.

Code

extern crate alloc;
use alloc::collections::BTreeMap;

struct Struct {
    map : BTreeMap<String, String>,
}

fn main() {
    let mut map = BTreeMap::new(); // ICE
    //let mut map = BTreeMap::<(String, String), String>::new(); // ICE
    //let mut map = BTreeMap::<String, String>::new(); // no ICE
    map.insert(("a".to_string(), "a".to_string()));
    let mut structdef = Struct { map };
}

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.67.1 (d5a82bbd2 2023-02-07)
binary: rustc
commit-hash: d5a82bbd26e1ad8b7401f6a718a9c57c96905483
commit-date: 2023-02-07
host: x86_64-pc-windows-gnu
release: 1.67.1
LLVM version: 15.0.6

$ rustc +nightly --version --verbose
rustc 1.69.0-nightly (065852def 2023-02-13)
binary: rustc
commit-hash: 065852def0903296da33a9eaf557f230bcf3a61a
commit-date: 2023-02-13
host: x86_64-pc-windows-msvc
release: 1.69.0-nightly
LLVM version: 15.0.7

Error output

$ rustc +nightly test.rs
error[E0061]: this method takes 2 arguments but 1 argument was supplied
  --> test.rs:12:9
   |
12 |     map.insert(("a".to_string(), "a".to_string()));
   |         ^^^^^^------------------------------------ an argument is missing
   |
note: associated function defined here
  --> /rustc/065852def0903296da33a9eaf557f230bcf3a61a\library\alloc\src\collections\btree\map.rs:955:12
help: provide the argument
   |
12 |     map.insert(("a".to_string(), "a".to_string()), /* value */);
   |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

thread 'rustc' panicked at 'index out of bounds: the len is 1 but the index is 1', compiler\rustc_hir_typeck\src\demand.rs:332:40
<backtrace omitted, see below>

error: 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.69.0-nightly (065852def 2023-02-13) running on x86_64-pc-windows-msvc

query stack during panic:
#0 [typeck] type-checking `main`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.
Backtrace

stack backtrace:
   0:     0x7ffcfd6698a2 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h78e89e9946a237ab
   1:     0x7ffcfd6a532b - core::fmt::write::hb0cb1c9de7a39696
   2:     0x7ffcfd65c88a - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h2d13ae8023f6410a
   3:     0x7ffcfd6695eb - std::sys::common::alloc::realloc_fallback::h95ea3faf57f4bab2
   4:     0x7ffcfd66cf89 - std::panicking::default_hook::h031c528ccf47d428
   5:     0x7ffcfd66cc0b - std::panicking::default_hook::h031c528ccf47d428
   6:     0x7ffce4ac00ef - rustc_driver_impl[e542371b9e5deca1]::describe_lints
   7:     0x7ffcfd66d8ef - std::panicking::rust_panic_with_hook::h2bf5e2387af40df5
   8:     0x7ffcfd66d64e - <std::panicking::begin_panic_handler::StrPanicPayload as core::panic::BoxMeUp>::get::h3fc7e7bd4173a984
   9:     0x7ffcfd66a59f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h78e89e9946a237ab
  10:     0x7ffcfd66d300 - rust_begin_unwind
  11:     0x7ffcfd6d8a05 - core::panicking::panic_fmt::h3223cb95b63b2d59
  12:     0x7ffcfd6d8b97 - core::panicking::panic_bounds_check::hfedaf1b227ea46ee
  13:     0x7ffce4c547f3 - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::point_at_expr_source_of_inferred_type
  14:     0x7ffce4c50e1c - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::emit_type_mismatch_suggestions
  15:     0x7ffce4c51afc - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::emit_coerce_suggestions
  16:     0x7ffce2fcb5b6 - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::demand_coerce_diag
  17:     0x7ffce2f7c940 - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::demand_coerce
  18:     0x7ffce2f5aafc - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::demand_coerce
  19:     0x7ffce2fafc7d - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::check_struct_path
  20:     0x7ffce2fb11d8 - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::check_struct_path
  21:     0x7ffce2f587c3 - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::demand_coerce
  22:     0x7ffce2f7a4ed - <rustc_hir_typeck[96d41babe8f90f07]::fn_ctxt::FnCtxt>::demand_coerce
  23:     0x7ffce30505b1 - <rustc_hir_typeck[96d41babe8f90f07]::method::probe::Pick>::maybe_emit_unstable_name_collision_hint
  24:     0x7ffce305f529 - <rustc_hir_typeck[96d41babe8f90f07]::inherited::Inherited as core[7f56be9053635011]::ops::deref::Deref>::deref
  25:     0x7ffce3748913 - <rustc_middle[9cf1323aa3ef55]::ty::Visibility as rustc_privacy[4607b2c41700df30]::VisibilityLike>::new_min
  26:     0x7ffce2fffcb6 - <rustc_hir_typeck[96d41babe8f90f07]::writeback::WritebackCx as rustc_hir[cc46961c34403ead]::intravisit::Visitor>::visit_ty
  27:     0x7ffce1dba42f - <rustc_hir_typeck[96d41babe8f90f07]::inherited::Inherited>::build
  28:     0x7ffce20c3aec - rustc_privacy[4607b2c41700df30]::provide
  29:     0x7ffce21bc172 - <rustc_query_impl[83d2b7f35e45599c]::Queries as rustc_middle[9cf1323aa3ef55]::ty::query::QueryEngine>::try_mark_green
  30:     0x7ffce1d27245 - <rustc_hir_analysis[4c58ae939ed73dca]::bounds::Bounds>::push_projection_bound
  31:     0x7ffce1d027f3 - rustc_hir_analysis[4c58ae939ed73dca]::check_crate
  32:     0x7ffce1e18160 - rustc_interface[71bf077bc0e4ea2b]::passes::analysis
  33:     0x7ffce216273d - rustc_privacy[4607b2c41700df30]::provide
  34:     0x7ffce21b963f - <rustc_query_impl[83d2b7f35e45599c]::Queries as rustc_middle[9cf1323aa3ef55]::ty::query::QueryEngine>::try_mark_green
  35:     0x7ffce1c3d27c - rustc_driver_impl[e542371b9e5deca1]::args::arg_expand_all
  36:     0x7ffce1c3b443 - rustc_driver_impl[e542371b9e5deca1]::args::arg_expand_all
  37:     0x7ffce1c3a627 - rustc_driver_impl[e542371b9e5deca1]::args::arg_expand_all
  38:     0x7ffce1c284d3 - <rustc_data_structures[72e258867a716a8c]::temp_dir::MaybeTempDir>::new
  39:     0x7ffce1c20cbd - <rustc_data_structures[72e258867a716a8c]::temp_dir::MaybeTempDir>::new
  40:     0x7ffcfd67fefc - std::sys::windows::thread::Thread::new::hcd7eb12de5a8a905
  41:     0x7ffd76fb7614 - BaseThreadInitThunk
  42:     0x7ffd791226a1 - RtlUserThreadStart

Activity

  1. added
    C-bug
    I-ICE
    T-compiler
    on Feb 14, 2023
  2. added
    E-needs-bisection
    on Feb 14, 2023
  3. Noratrieb commented on Feb 14, 2023

    @Noratrieb
    Member

    I cannot reproduce this using cargo-bisect-rustc on nightly-2023-02-13.
    ERROR: the end of the range (nightly-2023-02-13) does not reproduce the regression
    I ran it on my bisection website
    Could you try bisecting this yourself locally (I am not able to right now)

  4. martingms commented on Feb 14, 2023

    @martingms
    Contributor

    I hit this same bug and got a patch, can post a PR soon if useful!

  5. Noratrieb commented on Feb 14, 2023

    @Noratrieb
    Member

    Sounds great!
    @rustbot assign @martingms

  6. added a commit that references this issue on Feb 16, 2023
    5fac20f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugE-needs-bisectionI-ICET-compiler

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions