forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#41055 - Archytaus:compile-fail/const-match-pa…
…ttern-arm, r=arielb1 Fixed ICEs with pattern matching in const expression Fixed 2 ICEs with when pattern matching inside a constant expression. Both of these ICEs now resolve to an appropriate compiler error. 1. ICE was caused by a compiler bug to implement discriminant const qualify. I removed this intentionally thrown bug and changed it to a FIXME as the unimplemented expression type is handled as a compiler error elsewhere. 2. ICE was caused during a drop check when checking if a variable lifetime outlives the current scope if there was no parent scope . I've changed it to stop checking if there is no parent scope for the current scope. It is valid syntax for a const variable to be assigned a match expression with no enclosing scope. The ICE seemed to mainly be used as a defensive check for bugs elsewhere. Fixes rust-lang#38199. Fixes rust-lang#31577. Fixes rust-lang#29093. Fixes rust-lang#40012.
- Loading branch information
Showing
3 changed files
with
33 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
const x: bool = match Some(true) { | ||
Some(value) => true, | ||
//~^ ERROR: constant contains unimplemented expression type [E0019] | ||
_ => false | ||
}; | ||
|
||
const y: bool = { | ||
match Some(true) { | ||
Some(value) => true, | ||
//~^ ERROR: constant contains unimplemented expression type [E0019] | ||
_ => false | ||
} | ||
}; | ||
|
||
fn main() {} |