Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Irrefutable bindings matching code is broken #3235

Closed
bblum opened this issue Aug 20, 2012 · 11 comments
Closed

Irrefutable bindings matching code is broken #3235

bblum opened this issue Aug 20, 2012 · 11 comments
Assignees
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@bblum
Copy link
Contributor

bblum commented Aug 20, 2012

fn main() {
    let x = "hello";
    let ref y = x;
    // let y = match x { ref y => y };  // this way works fine
    error!("%?", *y);
}

produces:

rustc: /home/bblum/rust/src/llvm/lib/VMCore/Instructions.cpp:280:
void llvm::CallInst::init(llvm::Value*, llvm::ArrayRef<llvm::Value*>,
const llvm::Twine&): Assertion `(i >= FTy->getNumParams() ||
FTy->getParamType(i) == Args[i]->getType()) && "Calling a function
with a bad signature!"' failed.
Aborted (core dumped)

Happens with structs, tuples, etc too.

@nikomatsakis
Copy link
Contributor

for some reason that is fairly unclear to me, trans/alt has a completely distinct code path for irrefutable patterns. that path should be deleted and they should all use the normal alt path, imo. anyway, that particular path is hard-coded to copy and doesn't know about ref bindings.

@nikomatsakis
Copy link
Contributor

I changed the title to my preferred solution.

@catamorphism
Copy link
Contributor

Ugh, this has been a pain in the you-know-what. Not going to be ready for 0.5

@Aatch
Copy link
Contributor

Aatch commented Apr 3, 2013

Also causes this strange behaviour:

fn main() -> () {
    let a = ~(1, 2);
    test(a);
}

fn test<T,U>(a : &(T, U)) {
    let (ref _x, ref _y) = *a;
}

Returns error: moving out of dereference of immutable & pointer

However:

fn main() -> () {
    let a = ~(1, 2);
    test(a);
}

fn test<T,U>(a : &(T, U)) {
    let (_a, _b) = match *a {
        (ref a, ref b) => (a, b)
    };
}

Is fine.

@alexcrichton
Copy link
Member

Nominating for the well-defined milestone.

This makes working with non-copyable tuples laborious, and actually has serious performance implications for destructuring assignment (at least I think that's related to this bug, copies are generated when they shouldn't be). Failing the well-defined milestone, I think this would fit well into the feature-complete milestone.

@catamorphism
Copy link
Contributor

I don't feel like this fits under anything except production-ready, but I agree with nominating it.

@nikomatsakis
Copy link
Contributor

For what it's worth, I don't think that this is necessarily the right fix anymore. But the bug is real.

@nikomatsakis
Copy link
Contributor

Update the title to reflect the general bug.

@nikomatsakis
Copy link
Contributor

Very close to fixing this. I've got a branch that's been slowly progress towards stability.

@graydon
Copy link
Contributor

graydon commented Jun 20, 2013

accepted for backwards-compatible milestone

@catamorphism
Copy link
Contributor

a48ca32 fixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

6 participants