about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/check_const.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-08-15 20:34:25 +0200
committerGitHub <noreply@github.com>2023-08-15 20:34:25 +0200
commit8db5a6d8ee36e4a2d745fd356e7af09809b72d34 (patch)
tree2af5919b13396c09796ac96d08c0690cdb5b147a /compiler/rustc_passes/src/check_const.rs
parent5baf2a110fb699a1dc6c8036fd7dedbf746c54ca (diff)
parent58aa903848028ede4c8ccd584cb67f3780b082e9 (diff)
downloadrust-8db5a6d8ee36e4a2d745fd356e7af09809b72d34.tar.gz
rust-8db5a6d8ee36e4a2d745fd356e7af09809b72d34.zip
Rollup merge of #114819 - estebank:issue-78124, r=compiler-errors
Point at return type when it influences non-first `match` arm

When encountering code like

```rust
fn foo() -> i32 {
    match 0 {
        1 => return 0,
        2 => "",
        _ => 1,
    }
}
```

Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`.

Fix #78124.
Diffstat (limited to 'compiler/rustc_passes/src/check_const.rs')
-rw-r--r--compiler/rustc_passes/src/check_const.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs
index 495eb615ed8..8437e9a40e2 100644
--- a/compiler/rustc_passes/src/check_const.rs
+++ b/compiler/rustc_passes/src/check_const.rs
@@ -45,7 +45,7 @@ impl NonConstExpr {
 
             Self::Loop(ForLoop) | Self::Match(ForLoopDesugar) => &[sym::const_for],
 
-            Self::Match(TryDesugar) => &[sym::const_try],
+            Self::Match(TryDesugar(_)) => &[sym::const_try],
 
             // All other expressions are allowed.
             Self::Loop(Loop | While) | Self::Match(Normal | FormatArgs) => &[],