diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-11 17:13:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-11 17:13:54 +0200 |
| commit | 17393b26b961937cda562a2f4bb5e80b2ce49b1e (patch) | |
| tree | 7924110c0e4af1994f62a37dfdc5d820c5c52c75 | |
| parent | 8e948df707ea8a3c88c65bf2ffdcb2f1cf5491be (diff) | |
| parent | 8e7ade85e60f2834f6f6637d916c5709a33a9109 (diff) | |
| download | rust-17393b26b961937cda562a2f4bb5e80b2ce49b1e.tar.gz rust-17393b26b961937cda562a2f4bb5e80b2ce49b1e.zip | |
Rollup merge of #61518 - czipperz:const-fn-doc-disallow-loops, r=Centril
Add loops to doc list of things not stable in const fn Closes #61508
6 files changed, 14 insertions, 14 deletions
diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index f9667586456..7bafef79acd 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -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())) diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr index 7a10c469c51..abbdb4ab632 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr @@ -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 } } @@ -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 { } } @@ -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 } @@ -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 } diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 96b6057c8fd..40e7107e4a1 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -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 diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index e388b443d23..28a5ffb2015 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -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 } } @@ -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 { } } @@ -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 } @@ -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 } diff --git a/src/test/ui/consts/single_variant_match_ice.rs b/src/test/ui/consts/single_variant_match_ice.rs index 79dde3c18e8..6002506689e 100644 --- a/src/test/ui/consts/single_variant_match_ice.rs +++ b/src/test/ui/consts/single_variant_match_ice.rs @@ -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 } } } diff --git a/src/test/ui/consts/single_variant_match_ice.stderr b/src/test/ui/consts/single_variant_match_ice.stderr index b8ad775f1c3..1e092c8af99 100644 --- a/src/test/ui/consts/single_variant_match_ice.stderr +++ b/src/test/ui/consts/single_variant_match_ice.stderr @@ -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, |
