2020-06-25 19:43:48 -05:00
|
|
|
const _: () = loop { break (); };
|
2019-11-17 23:11:42 -06:00
|
|
|
|
2020-06-25 19:43:48 -05:00
|
|
|
static FOO: i32 = loop { break 4; };
|
2019-11-17 23:11:42 -06:00
|
|
|
|
|
|
|
const fn foo() {
|
2020-06-25 19:43:48 -05:00
|
|
|
loop {}
|
2019-11-17 23:11:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Foo {
|
2020-06-25 19:43:48 -05:00
|
|
|
const BAR: i32 = loop { break 4; };
|
2019-11-17 23:11:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Foo for () {
|
2020-06-25 19:43:48 -05:00
|
|
|
const BAR: i32 = loop { break 4; };
|
2019-11-17 23:11:42 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn non_const_outside() {
|
|
|
|
const fn const_inside() {
|
2020-06-25 19:43:48 -05:00
|
|
|
loop {}
|
2019-11-17 23:11:42 -06: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-25 19:43:48 -05:00
|
|
|
while x < 4 {
|
2019-11-17 23:11:42 -06:00
|
|
|
x += 1;
|
|
|
|
}
|
|
|
|
|
2020-06-25 19:43:48 -05:00
|
|
|
while x < 8 {
|
2019-11-17 23:11:42 -06:00
|
|
|
x += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
};
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
|
|
|
|
2020-06-25 19:43:48 -05:00
|
|
|
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
2024-02-01 16:45:00 -06:00
|
|
|
//~^ ERROR: cannot call
|
|
|
|
//~| ERROR: mutable references
|
|
|
|
//~| ERROR: cannot convert
|
2019-11-17 23:11:42 -06:00
|
|
|
x += i;
|
|
|
|
}
|
|
|
|
|
2020-06-25 19:43:48 -05:00
|
|
|
for i in 0..4 { //~ ERROR `for` is not allowed in a `const`
|
2024-02-01 16:45:00 -06:00
|
|
|
//~^ ERROR: cannot call
|
|
|
|
//~| ERROR: mutable references
|
|
|
|
//~| ERROR: cannot convert
|
2019-11-17 23:11:42 -06:00
|
|
|
x += i;
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
};
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
|
|
|
|
2020-06-25 19:43:48 -05:00
|
|
|
loop {
|
2019-11-17 23:11:42 -06:00
|
|
|
x += 1;
|
2020-05-21 14:49:38 -05:00
|
|
|
if x == 4 {
|
2019-11-17 23:11:42 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-25 19:43:48 -05:00
|
|
|
loop {
|
2019-11-17 23:11:42 -06:00
|
|
|
x += 1;
|
2020-05-21 14:49:38 -05:00
|
|
|
if x == 8 {
|
2019-11-17 23:11:42 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x
|
|
|
|
};
|
|
|
|
|
|
|
|
const _: i32 = {
|
|
|
|
let mut x = 0;
|
2020-06-25 19:43:48 -05:00
|
|
|
while let None = Some(x) { }
|
|
|
|
while let None = Some(x) { }
|
2019-11-17 23:11:42 -06:00
|
|
|
x
|
|
|
|
};
|