Skip to content

Borrowck doesn't correctly handle lifetime of ~rvalue #2977

Closed
@varnie

Description

@varnie

good day. the following intentionally buggy program crashes rustc:

//buggy.rs
use std;
import std::map::hashmap;
import std::map;

fn main() {
    let buggy_map :hashmap<uint, &uint> = hashmap::<uint, &uint>(uint::hash, uint::eq);
    buggy_map.insert(42, ~1);
    buggy_map.insert(43, ~2);
}

here is the result of "rustc buggy.rs":

rustc: /home/varnie/rust/src/llvm/lib/VMCore/Instructions.cpp:1056: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.
Aborted (core dumped)

rustc version is:
rustc 0.3 (6081eb7 2012-07-15 05:41:24 -0700)
host: i686-unknown-linux-gnu

Metadata

Metadata

Assignees

Labels

A-lifetimesArea: Lifetimes / regionsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions