Skip to content

Crashed with simple example #77378

Closed
Closed
@BruceBrown

Description

@BruceBrown

Code

use std::collections::HashMap;
use std::sync::Mutex;

#[derive(Debug, Default)]
struct SomeMutableData {
    names: HashMap<u128, Vec<u8>>,
}


#[derive(Debug, Default)]
struct SomeStruct {
    mutable: Mutex<SomeMutableData>,
}
impl SomeStruct {
    fn received_bytes(&self, conn_id: u128, bytes: Vec<u8>) {
        let mutable = self.mutable.lock().unwrap();
        let mut name: Vec<u8> = Vec::with_capacity(64);
        if Some(name) = mutable.names.get(&conn_id) {
            let mut msg = name.clone();
        }
    }
}

fn main() {}

Meta

note: rustc 1.48.0-nightly (623fb90 2020-09-26) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

error: aborting due to previous error

error: could not compile test-hashmap
rustc --version --verbose:

<version>

Error output

<output>
Backtrace This is pretty simple to reproduce. I admit the use of name is a bit odd and maybe illegal. However, it just crashed without an error or warning

<backtrace>
   Compiling test-hashmap v0.1.0 (/Users/bruce/Projects/rust/examples/test-hashmap)
error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt.rs:459:25: while adjusting Expr { hir_id: HirId { owner: DefId(0:6 ~ test_hashmap[6477]::{impl#0}::received_bytes), local_id: 50 }, kind: Path(Resolved(None, Path { span: src/main.rs:19:25: 19:32 (#0), res: Local(HirId { owner: DefId(0:6 ~ test_hashmap[6477]::{impl#0}::received_bytes), local_id: 4 }), segments: [PathSegment { ident: mutable#0, hir_id: Some(HirId { owner: DefId(0:6 ~ test_hashmap[6477]::{impl#0}::received_bytes), local_id: 49 }), res: Some(Local(HirId { owner: DefId(0:6 ~ test_hashmap[6477]::{impl#0}::received_bytes), local_id: 4 })), args: None, infer_args: true }] })), attrs: ThinVec(None), span: src/main.rs:19:25: 19:32 (#0) }, can't compose [Deref(Some(OverloadedDeref { region: '_#6r, mutbl: Not, span: src/main.rs:19:25: 19:38 (#0) })) -> SomeMutableData] and [Deref(Some(OverloadedDeref { region: '_#13r, mutbl: Not, span: src/main.rs:19:25: 19:38 (#0) })) -> SomeMutableData]

thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

note: the compiler unexpectedly panicked. this is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions