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

Allow missing sections #17

Merged
merged 1 commit into from Aug 6, 2016

Conversation

Projects
None yet
2 participants
@cramertj
Contributor

cramertj commented Aug 3, 2016

Fix #6

Unfortunately, I wasn't able to come up with a simple way to match zero or one instances of a pattern. Because of this, it's possible to write a few pathological errors that will cause infinite recursion rather than a more helpful description.

Example:


#[test]
fn smoke_test_9() {
    error_chain! {
        types {
            Error, ErrorKind, ChainErr, Result;
        }
        types {
            Error, ErrorKind, ChainErr, Result;
        }

        foreign_links { }

        errors {
            HttpStatus(e: u32) {
                description("http request returned an unsuccessful status code")
                display("http request returned an unsuccessful status code: {}", e)
            }
        }
    }
}

Because there are multiple types declarations, they are both combined into a single types declaration which looks like types { Error, ErrorKind, ChainErr, Result; Error, ErrorKind, ChainErr, Result; }, which doesn't match any of the existing rules except the one that produced it.

It is necessary for there to be a rule like this that matches zero or one type blocks with zero or one entry sections, so I don't see how to avoid matching on more than one type block or more than one entry section.

Perhaps an RFC for a macro_rules ? is in order? Do you know why this was excluded to begin with? It seems like a natural extension of * and +.

@brson

This comment has been minimized.

Show comment
Hide comment
@brson

brson Aug 4, 2016

Contributor

Thanks @cramertj ! It's the end of the day here and I'm beat, but I'll look at this tomorrow (really).

Contributor

brson commented Aug 4, 2016

Thanks @cramertj ! It's the end of the day here and I'm beat, but I'll look at this tomorrow (really).

@cramertj

This comment has been minimized.

Show comment
Hide comment
@cramertj

cramertj Aug 4, 2016

Contributor

@brson Sounds good! No rush.

Contributor

cramertj commented Aug 4, 2016

@brson Sounds good! No rush.

@cramertj

This comment has been minimized.

Show comment
Hide comment
@cramertj

cramertj Aug 5, 2016

Contributor

Ping @brson

Contributor

cramertj commented Aug 5, 2016

Ping @brson

@brson brson merged commit 59623e5 into rust-lang-nursery:master Aug 6, 2016

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
@brson

This comment has been minimized.

Show comment
Hide comment
@brson

brson Aug 6, 2016

Contributor

Thanks! I'll get a build out shortly.

Contributor

brson commented Aug 6, 2016

Thanks! I'll get a build out shortly.

@cramertj cramertj deleted the cramertj:allow-missing-sections branch Aug 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment