-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix scoping for let chains in match guards #119554
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
Changes to the size of AST and/or HIR nodes. cc @nnethercote Some changes might have occurred in exhaustiveness checking cc @Nadrieril |
This comment has been minimized.
This comment has been minimized.
@@ -1258,7 +1258,7 @@ pub struct Arm<'hir> { | |||
/// If this pattern and the optional guard matches, then `body` is evaluated. | |||
pub pat: &'hir Pat<'hir>, | |||
/// Optional guard clause. | |||
pub guard: Option<Guard<'hir>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I've always been so confused why this was represented differently in HIR. This was also what caused the bug fixed by #119402, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if_let_guards was implemented before let chains were ready. But it's definitely outstayed its usefulness.
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question below.
@rustbot author |
43d59ba
to
6c935b3
Compare
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
Match guards with an if let guard or an if let chain guard should have a temporary scope of the whole arm. This is to allow ref bindings to temporaries to borrow check.
6c935b3
to
44bba54
Compare
@rustbot ready |
@bors r+ |
…tion, r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes rust-lang#118593
…tion, r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes rust-lang#118593
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#118680 (Add support for shell argfiles) - rust-lang#119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - rust-lang#119350 (Imply outlives-bounds on lazy type aliases) - rust-lang#119354 (Make `negative_bounds` internal & fix some of its issues) - rust-lang#119506 (Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error`) - rust-lang#119554 (Fix scoping for let chains in match guards) - rust-lang#119563 (Check yield terminator's resume type in borrowck) - rust-lang#119589 (cstore: Remove unnecessary locking from `CrateMetadata`) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - rust-lang#119350 (Imply outlives-bounds on lazy type aliases) - rust-lang#119354 (Make `negative_bounds` internal & fix some of its issues) - rust-lang#119506 (Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error`) - rust-lang#119554 (Fix scoping for let chains in match guards) - rust-lang#119563 (Check yield terminator's resume type in borrowck) - rust-lang#119589 (cstore: Remove unnecessary locking from `CrateMetadata`) - rust-lang#119622 (never patterns: Document behavior of never patterns with macros-by-example) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119554 - matthewjasper:remove-guard-distinction, r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes rust-lang#118593
…tion, r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes rust-lang#118593
If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards.
hir::Guard
andthir::Guard
.closes #118593