Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loops to doc list of things not stable in const fn #61518

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn check_terminator(

TerminatorKind::FalseEdges { .. } | TerminatorKind::SwitchInt { .. } => Err((
span,
"`if`, `match`, `&&` and `||` are not stable in const fn".into(),
"loops and conditional expressions are not stable in const fn".into(),
)),
| TerminatorKind::Abort | TerminatorKind::Unreachable => {
Err((span, "const fn with unreachable code is not stable".into()))
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:100:38
|
LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
Expand All @@ -169,7 +169,7 @@ LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:102:29
|
LL | const fn foo30_5(b: bool) { while b { } }
Expand All @@ -178,7 +178,7 @@ LL | const fn foo30_5(b: bool) { while b { } }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:104:44
|
LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
Expand All @@ -187,7 +187,7 @@ LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:106:44
|
LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/consts/min_const_fn/min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ const fn foo30_2(x: *mut u32) -> usize { x as usize }
const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
//~^ ERROR casting pointers to ints is unstable
const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
//~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
//~^ ERROR loops and conditional expressions are not stable in const fn
const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn
const fn foo30_6() -> bool { let x = true; x }
const fn foo36(a: bool, b: bool) -> bool { a && b }
//~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
//~^ ERROR loops and conditional expressions are not stable in const fn
const fn foo37(a: bool, b: bool) -> bool { a || b }
//~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
//~^ ERROR loops and conditional expressions are not stable in const fn
const fn inc(x: &mut i32) { *x += 1 }
//~^ ERROR mutable references in const fn are unstable

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/consts/min_const_fn/min_const_fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:100:38
|
LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
Expand All @@ -169,7 +169,7 @@ LL | const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:102:29
|
LL | const fn foo30_5(b: bool) { while b { } }
Expand All @@ -178,7 +178,7 @@ LL | const fn foo30_5(b: bool) { while b { } }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:104:44
|
LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
Expand All @@ -187,7 +187,7 @@ LL | const fn foo36(a: bool, b: bool) -> bool { a && b }
= note: for more information, see issue https://github.com/rust-lang/rust/issues/57563
= help: add #![feature(const_fn)] to the crate attributes to enable

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/min_const_fn.rs:106:44
|
LL | const fn foo37(a: bool, b: bool) -> bool { a || b }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/single_variant_match_ice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl Foo {
use self::Foo::*;

match *self {
Prob => 0x1, //~ ERROR `if`, `match`, `&&` and `||` are not stable in const fn
Prob => 0x1, //~ ERROR loops and conditional expressions are not stable in const fn
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/single_variant_match_ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0019]: constant contains unimplemented expression type
LL | x => 42,
| ^

error[E0723]: `if`, `match`, `&&` and `||` are not stable in const fn
error[E0723]: loops and conditional expressions are not stable in const fn
--> $DIR/single_variant_match_ice.rs:18:13
|
LL | Prob => 0x1,
Expand Down