Skip to content

LLVM assertion when implementing methods that take self by-value on numeric types #5474

Closed
@bstrie

Description

@bstrie

This:

fn main() {
    10u.to_vec();
}

trait ToVec {
    fn to_vec(self);
}

impl ToVec for uint {
    fn to_vec(self){}
}

causes this:

rustc: /media/linhaus/rust/src/llvm/lib/VMCore/Instructions.cpp:2383: static llvm::CastInst* llvm::CastInst::CreatePointerCast(llvm::Value*, llvm::Type*, const llvm::Twine&, llvm::Instruction*): Assertion `S->getType()->isPointerTy() && "Invalid cast"' failed.
Aborted

Changing self to &self makes it work, so it has to do with passing self by-value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions