2020-06-26 00:43:48 +00:00
|
|
|
const _: () = loop { break (); };
|
2019-11-18 05:11:42 +00:00
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
static FOO: i32 = loop { break 4; };
|
2019-11-18 05:11:42 +00:00
|
|
|
|
|
|
|
const fn foo() {
|
2020-06-26 00:43:48 +00:00
|
|
|
loop {}
|
2019-11-18 05:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Foo {
|
2020-06-26 00:43:48 +00:00
|
|
|
const BAR: i32 = loop { break 4; };
|
2019-11-18 05:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for () {
|
2020-06-26 00:43:48 +00:00
|
|
|
const BAR: i32 = loop { break 4; };
|
2019-11-18 05:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn non_const_outside() {
|
|
|
|
const fn const_inside() {
|
2020-06-26 00:43:48 +00:00
|
|
|
loop {}
|
2019-11-18 05:11:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const fn const_outside() {
|
|
|
|
fn non_const_inside() {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = [0; {
|
|
|
|
while false {}
|
|
|
|
4
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
while x < 4 {
|
2019-11-18 05:11:42 +00:00
|
|
|
x += 1;
|
|
|
|
}
|
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
while x < 8 {
|
2019-11-18 05:11:42 +00:00
|
|
|
x += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
};
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
2019-11-18 05:11:42 +00:00
|
|
|
x += i;
|
|
|
|
}
|
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
2019-11-18 05:11:42 +00:00
|
|
|
x += i;
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
};
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
loop {
|
2019-11-18 05:11:42 +00:00
|
|
|
x += 1;
|
2020-05-21 19:49:38 +00:00
|
|
|
if x == 4 {
|
2019-11-18 05:11:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-26 00:43:48 +00:00
|
|
|
loop {
|
2019-11-18 05:11:42 +00:00
|
|
|
x += 1;
|
2020-05-21 19:49:38 +00:00
|
|
|
if x == 8 {
|
2019-11-18 05:11:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
};
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
2020-06-26 00:43:48 +00:00
|
|
|
while let None = Some(x) { }
|
|
|
|
while let None = Some(x) { }
|
2019-11-18 05:11:42 +00:00
|
|
|
x
|
|
|
|
};
|