Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Allow missing sections #17

Merged
merged 1 commit into from
Aug 6, 2016

Conversation

cramertj
Copy link
Contributor

@cramertj 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
Copy link
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
Copy link
Contributor Author

cramertj commented Aug 4, 2016

@brson Sounds good! No rush.

@cramertj
Copy link
Contributor Author

cramertj commented Aug 5, 2016

Ping @brson

@brson brson merged commit 59623e5 into rust-lang-deprecated:master Aug 6, 2016
@brson
Copy link
Contributor

brson commented Aug 6, 2016

Thanks! I'll get a build out shortly.

@cramertj cramertj deleted the allow-missing-sections branch August 6, 2016 22:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants