Skip to content

Test eof is reached when parsing format strings #8944

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

Closed
wants to merge 1 commit into from

Conversation

alexcrichton
Copy link
Member

Otherwise extra stuff after a lone '}' character is simply ignored, which is
very bad.

Closes #8938

@huonw
Copy link
Member

huonw commented Sep 3, 2013

Wouldn't this be best to actually signal an error when an unopened } is encountered?

@alexcrichton
Copy link
Member Author

The way the parser currently works is that it just halts parsing on an } character. That way the parser recursively calls itself when parsing the interiors of methods. I thought it turned out to be pretty nice, but this was the one corner case that it encountered where it got a bit ugly.

I haven't exactly written a lot of hand-written parsers, so this could probably be re-implemented in some other fashion. I was just happy that the only fields of the parser were the source string an an iterator.

@alexcrichton
Copy link
Member Author

The relevant code is:

fn select(&mut self) -> ~Method<'self> {                                   
    // Consume arms one at a time                                          
    loop {                                                                 
        let selector = ...;
        let pieces = self.collect();                                       
        arms.push(SelectArm { selector: selector, result: pieces });   
        ...
    }                                                                      
}                                                                          

Which may just be too clever by a half for this.

Otherwise extra stuff after a lone '}' character is simply ignored, which is
very bad.

Closes rust-lang#8938
bors added a commit that referenced this pull request Sep 5, 2013
Otherwise extra stuff after a lone '}' character is simply ignored, which is
very bad.

Closes #8938
@bors bors closed this Sep 5, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 16, 2022
…ishearth

List configuration values can now be extended instead of replaced

I've seen some `clippy.toml` files, that have a few additions to the default list of a configuration and then a copy of our default. The list will therefore not be updated, when we add new names. This change should make it simple for new users to append values instead of replacing them.

I'm uncertain if the documentation of the `".."` is apparent. Any suggestions are welcome. I've also check that the lint list displays the examples correctly.

<details>
<summary>Lint list screenshots</summary>

![image](https://user-images.githubusercontent.com/17087237/171999434-393f2f83-09aa-4bab-8b05-bd4973150f27.png)

![image](https://user-images.githubusercontent.com/17087237/171999401-e6942b53-25e6-4b09-89e5-d867c7463156.png)

</details>

---

changelog: enhancement: [`doc_markdown`]: Users can now indicate, that the `doc-valid-idents` should extend the default and not replace it
changelog: enhancement: [`blacklisted-name`]: Users can now indicate, that the `blacklisted-names` should extend the default and not replace it

Closes: rust-lang#8877

That's it. Have a fantastic weekend to everyone reading this. Here is a cookie 🍪
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

Successfully merging this pull request may close these issues.

format! stops early on spurious '}'
3 participants