Skip to content

LLVM assertion failure with with borrowed pointer in struct #5884

Closed
@alexcrichton

Description

@alexcrichton

This program

pub struct Foo {
  a: int,
}

struct Bar<'self> {
  a: ~Option<int>,
  b: &'self Foo,
}

fn check(a: @Foo) {
  let mut _ic = Bar{ b: a, a: ~None };
}

fn main(){}

yields

$ rustc foo.rs
Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file /Users/alex/code/rust-src/src/llvm/lib/IR/Instructions.cpp, line 281.

This cropped up after the new self lifetimes as I tried to change field b from @Foo to &'self Foo. If the owned pointer from Bar is removed (even just the sigil), the assertion still trips.

One solution I found is:

fn check(b: @Foo) {
  let a = ~None;
  let mut _ic = Bar{ b: b, a: a };
}

Metadata

Metadata

Assignees

Labels

E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions