Fixed ICEs with pattern matching in const fn. Fixes #38199, fixes #31577, fixes #29093, and fixes #40012.
This commit is contained in:
parent
5309a3e31d
commit
e753dfa9a9
3 changed files with 33 additions and 7 deletions
|
|
@ -722,11 +722,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
|
|||
}
|
||||
|
||||
Rvalue::Discriminant(..) => {
|
||||
// FIXME discriminant
|
||||
// FIXME implement discriminant const qualify
|
||||
self.add(Qualif::NOT_CONST);
|
||||
if self.mode != Mode::Fn {
|
||||
bug!("implement discriminant const qualify");
|
||||
}
|
||||
// Discriminants in consts will error elsewhere as an unimplemented expression type
|
||||
}
|
||||
|
||||
Rvalue::Box(_) => {
|
||||
|
|
|
|||
|
|
@ -278,9 +278,12 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'gcx, 'tcx>(
|
|||
debug!("check_safety_of_destructor_if_necessary typ: {:?} scope: {:?}",
|
||||
typ, scope);
|
||||
|
||||
let parent_scope = rcx.tcx.region_maps.opt_encl_scope(scope).unwrap_or_else(|| {
|
||||
span_bug!(span, "no enclosing scope found for scope: {:?}", scope)
|
||||
});
|
||||
|
||||
let parent_scope = match rcx.tcx.region_maps.opt_encl_scope(scope) {
|
||||
Some(parent_scope) => parent_scope,
|
||||
// If no enclosing scope, then it must be the root scope which cannot be outlived.
|
||||
None => return
|
||||
};
|
||||
|
||||
let result = iterate_over_potentially_unsafe_regions_in_type(
|
||||
&mut DropckContext {
|
||||
|
|
|
|||
25
src/test/compile-fail/const-match-pattern-arm.rs
Normal file
25
src/test/compile-fail/const-match-pattern-arm.rs
Normal file
|
|
@ -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() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue