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

Forbid use of generics with foreign functions. Closes #10353. #12337

Closed
wants to merge 1 commit into from

Conversation

nrc
Copy link
Member

@nrc nrc commented Feb 17, 2014

and fix up some formatting.

@huonw
Copy link
Member

huonw commented Feb 17, 2014

Would it be sensible to have the formatting change in a separate commit to the actual fix?

@alexcrichton
Copy link
Member

I've found that adding ?w=1 helps at lot with formatting, it shows well how there are very few changes done with this that aren't whitespace

@alexcrichton
Copy link
Member

In the future, you don't need commas after blocks in match statements:

match foo {
    a => b, // comma required
    b => { c } // no comma necessary
    c => { d }, // comma optional
}

@huonw
Copy link
Member

huonw commented Feb 17, 2014

@alexcrichton Woah, the ?w=1 trick is amazing. Thanks.

bors added a commit that referenced this pull request Feb 17, 2014
@bors bors closed this Feb 17, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
internal: document overall approach to reload
flip1995 pushed a commit to flip1995/rust that referenced this pull request Mar 7, 2024
Check for try blocks in `question_mark` more consistently

Fixes rust-lang#12337

I split this PR up into two commits since this moves a method out of an `impl`, which makes for a pretty bad diff (the `&self` parameter is now unused, and there isn't a reason for that function to be part of the `impl` now).

The first commit is the actual relevant change and the 2nd commit just moves stuff (github's "hide whitespace" makes the diff easier to look at)

------------
Now for the actual issue:

`?` within `try {}` blocks desugars to a `break` to the block, rather than a `return`, so that changes behavior in those cases.

The lint has multiple patterns to look for and in *some* of them it already does correctly check whether we're in a try block, but this isn't done for all of its patterns.

We could add another `self.inside_try_block()` check to the function that looks for `let-else-return`, but I chose to actually just move those checks out and instead have them in `LintPass::check_{stmt,expr}`. This has the advantage that we can't (easily) accidentally forget to add that check in new patterns that might be added in the future.

(There's also a bit of a subtle interaction between two lints, where `question_mark`'s LintPass calls into `manual_let_else`, so I added a check to make sure we don't avoid linting for something that doesn't have anything to do with `?`)

changelog: [`question_mark`]: avoid linting on try blocks in more cases
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.

4 participants