Add regression test for #52475

This commit is contained in:
Bruno Dutra 2018-08-18 14:48:14 +02:00
parent 927c709eb9
commit 806ecabab1
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Copyright 2018 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.
#![feature(const_let)]
fn main() {
let _ = [(); {
//~^ WARNING Constant evaluating a complex constant, this might take some time
//~| ERROR could not evaluate repeat length
let mut x = &0;
let mut n = 0;
while n < 5 { //~ ERROR constant contains unimplemented expression type
n = (n + 1) % 5;
x = &0; // Materialize a new AllocId
}
0
}];
}

View File

@ -0,0 +1,42 @@
error[E0019]: constant contains unimplemented expression type
--> $DIR/issue-52475.rs:19:9
|
LL | / while n < 5 { //~ ERROR constant contains unimplemented expression type
LL | | n = (n + 1) % 5;
LL | | x = &0; // Materialize a new AllocId
LL | | }
| |_________^
warning: Constant evaluating a complex constant, this might take some time
--> $DIR/issue-52475.rs:14:18
|
LL | let _ = [(); {
| __________________^
LL | | //~^ WARNING Constant evaluating a complex constant, this might take some time
LL | | //~| ERROR could not evaluate repeat length
LL | | let mut x = &0;
... |
LL | | 0
LL | | }];
| |_____^
error[E0080]: could not evaluate repeat length
--> $DIR/issue-52475.rs:14:18
|
LL | let _ = [(); {
| __________________^
LL | | //~^ WARNING Constant evaluating a complex constant, this might take some time
LL | | //~| ERROR could not evaluate repeat length
LL | | let mut x = &0;
... |
LL | | n = (n + 1) % 5;
| | ----------- duplicate interpreter state observed here, const evaluation will never terminate
... |
LL | | 0
LL | | }];
| |_____^
error: aborting due to 2 previous errors
Some errors occurred: E0019, E0080.
For more information about an error, try `rustc --explain E0019`.