diff options
| author | bors <bors@rust-lang.org> | 2024-03-04 14:34:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-04 14:34:56 +0000 |
| commit | e970fa52e799cdeeee3fe022d390ca321f1767ef (patch) | |
| tree | cf827539dc75df75240f2ae8fd6b8ccd84a23125 /compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp | |
| parent | f75d8c7f1be223d4003fe35e428eed7d036c5e29 (diff) | |
| parent | 1430623e0470fa90bf6415f18225ecac88e0cba8 (diff) | |
| download | rust-e970fa52e799cdeeee3fe022d390ca321f1767ef.tar.gz rust-e970fa52e799cdeeee3fe022d390ca321f1767ef.zip | |
Auto merge of #12341 - y21:issue12337, r=dswij
Check for try blocks in `question_mark` more consistently
Fixes #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
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
