Skip to content

trait that omits & on self type signals LLVM assertion failure #4406

Closed
@jbclements

Description

@jbclements

Compiling this program:

trait BogusTrait {
  fn its1(self) -> int;
}

impl BogusTrait for int {
  fn its1(self) -> int {1}
}

#[test] fn t1 () {assert! ((13).its1() == 1);}

produces this error message:

% ./x86_64-apple-darwin/stage2/bin/rustc --test /tmp/bug4.rs
Assertion failed: (S->getType()->isPtrOrPtrVectorTy() && "Invalid cast"), function CreatePointerCast, file /Users/fklock/Dev/Mozilla/rust.git/src/llvm/lib/IR/Instructions.cpp, line 2394.
Abort trap: 6

(Original bug report follows)

Compiling this program:

trait BogusTrait {
  fn its1(self) -> int;
}

impl int: BogusTrait {
  fn its1(self) -> int {1}
}

#[test] fn t1 () {assert 13.its1() == 1;}

Produces this error message:

jclements-09740:rust-experimenting clements$ rustc --test trait-testing.rs
Assertion failed: (S->getType()->isPointerTy() && "Invalid cast"), function CreatePointerCast, file /Users/clements/rust/src/llvm/lib/VMCore/Instructions.cpp, line 2383.
Abort trap: 6

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationA-trait-systemArea: Trait systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions