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

task <unnamed> failed at 'assertion failed: rp.is_none()', .../librustc/middle/typeck/collect.rs:1108 #8846

Closed
utkarshkukreti opened this issue Aug 29, 2013 · 1 comment

Comments

@utkarshkukreti
Copy link
Contributor

Pretty sure there is something wrong with my code, but Rust doesn't give any meaningful error message, just fails and requests to report this here.

Code + Error message:

$ cat rust_bug.rs
struct Parser<'self, A> (&'self fn(&str) -> Option<(A, uint)>);

fn char<'self>(c: u8) -> Parser<'self, u8> {
  Parser(|string|
   if string[0] == c {
     Some((c, 1))
   } else {
     None
   })
}

fn main() {
}

$ rust run rust_bug.rs
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues

$ RUST_LOG=rustc=1 rust run rust_bug.rs
task <unnamed> failed at 'assertion failed: rp.is_none()', /Users/utkarsh/dev/git/rust/src/librustc/middle/typeck/collect.rs:1108
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /Users/utkarsh/dev/git/rust/src/librustc/rustc.rs:376

I'm using the HEAD of master branch as of this moment: 89d0400.

@huonw
Copy link
Member

huonw commented Aug 29, 2013

Hi! Thanks for the bug report, but I think this is a dup of #8741 (and #7989, and a few others). It's very confusing at the moment, but the lifetime called 'self should essentially only be used when the compiler says you can't use anything else, the "correct" thing to use is:

fn char<'a>(c: u8) -> Parser<'a, u8> {
   ...
}

However, the above still won't work (although it will give a proper error message rather than an ICE), since &fn's with captures cannot be returned. Parser<A>(~fn(&str) -> Option<(A, uint)>) or @fn probably work better.

@huonw huonw closed this as completed Aug 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants