Skip to content

struct matching problem with rparse #3866

New issue

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

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

Already on GitHub? # to your account

Closed
dckc opened this issue Oct 26, 2012 · 2 comments
Closed

struct matching problem with rparse #3866

dckc opened this issue Oct 26, 2012 · 2 comments
Labels
A-metadata Area: Crate metadata

Comments

@dckc
Copy link
Contributor

dckc commented Oct 26, 2012

I get:

$ rustc  structmatch.rs --test
structmatch.rs:24:7: 24:18 error: `ParseFailed` does not name a structure
structmatch.rs:24     Err(ParseFailed{file: f, line: y, col: x, mesg: txt}) => assert x == 6,
                         ^~~~~~~~~~~
error: aborting due to previous error

with this:

extern mod std; // else --test goes wonky

extern mod rparse; // https://github.com/jesse99/rparse or: cargo install rparse

use rparse::{Parser, Combinators, ParseFailed, match0 };

pub fn space() -> Parser<@~str> { match0(|ch| ws_char.contains_char(ch)) }
const ws_char: &str = &" \t\r\n\x0A";

#[cfg(test)]
mod test_preliminaries {

    // This shows ParseFailed is correctly imported.
    fn mk_failed() -> ParseFailed {
ParseFailed{file: @~"", line: 1, col: 2, mesg: @~"hello"}
    }

    #[test]
    fn match_problemr() {
        let actual = space()
            .parse(@~"f", @"$( x \u0000 is not allowed $)");
        match actual {
Ok(_) => fail,
Err(ParseFailed{file: f, line: y, col: x, mesg: txt}) => assert x == 6,
          // The with the line below in place of the one above, this compiles.
//Err(_) => ()
        }
    }
}

current revision of rparse is:

commit 1c6f5e8a15dd9d4972fcbf8692ebe79cc72d4b46
Author: Jesse Jones
Date: Wed Oct 17 07:05:59 2012 -0700

Meanwhile, this compiles fine...

extern mod std; // else --test goes wonky

struct ParseFailed {
  file: @~str,
  line: uint,
  col: uint,
  mesg: @~str
}

type ParseResult = Result<int, ParseFailed>;

fn match_problem() {
    let actual: ParseResult = Ok(1);

    match actual {
      Ok(_) => fail,
      Err(ParseFailed{file: f, line: y, col: x, mesg: txt}) => assert x == 6,
    }
}
@brson
Copy link
Contributor

brson commented Oct 29, 2012

Maybe struct's can't be constructed across crates.

@catamorphism
Copy link
Contributor

Dup of #3767

RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 17, 2024
Bump ui test to 0.26

lots of issues fixed and various improvements

🤞 that it works this time around
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-metadata Area: Crate metadata
Projects
None yet
Development

No branches or pull requests

3 participants