forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#77122 - ecstatic-morse:const-fn-arithmetic,…
… r=RalfJung,oli-obk Add `#![feature(const_fn_floating_point_arithmetic)]` cc rust-lang#76618 This is a template for splitting up `const_fn` into granular feature gates. I think this will make it easier, both for us and for users, to track stabilization of each individual feature. We don't *have* to do this, however. We could also keep stabilizing things out from under `const_fn`. cc @rust-lang/wg-const-eval r? @oli-obk
- Loading branch information
Showing
18 changed files
with
159 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/test/ui/consts/const_fn_floating_point_arithmetic.gated.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: fatal error triggered by #[rustc_error] | ||
--> $DIR/const_fn_floating_point_arithmetic.rs:20:1 | ||
| | ||
LL | fn main() {} | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// gate-test-const_fn_floating_point_arithmetic | ||
|
||
// revisions: stock gated | ||
|
||
#![feature(rustc_attrs)] | ||
#![cfg_attr(gated, feature(const_fn_floating_point_arithmetic))] | ||
|
||
const fn add(f: f32) -> f32 { f + 2.0 } | ||
//[stock]~^ floating point arithmetic | ||
const fn sub(f: f32) -> f32 { 2.0 - f } | ||
//[stock]~^ floating point arithmetic | ||
const fn mul(f: f32, g: f32) -> f32 { f * g } | ||
//[stock]~^ floating point arithmetic | ||
const fn div(f: f32, g: f32) -> f32 { f / g } | ||
//[stock]~^ floating point arithmetic | ||
const fn neg(f: f32) -> f32 { -f } | ||
//[stock]~^ floating point arithmetic | ||
|
||
#[rustc_error] | ||
fn main() {} //[gated]~ fatal error triggered by #[rustc_error] |
48 changes: 48 additions & 0 deletions
48
src/test/ui/consts/const_fn_floating_point_arithmetic.stock.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
error[E0658]: floating point arithmetic is not allowed in constant functions | ||
--> $DIR/const_fn_floating_point_arithmetic.rs:8:31 | ||
| | ||
LL | const fn add(f: f32) -> f32 { f + 2.0 } | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information | ||
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable | ||
|
||
error[E0658]: floating point arithmetic is not allowed in constant functions | ||
--> $DIR/const_fn_floating_point_arithmetic.rs:10:31 | ||
| | ||
LL | const fn sub(f: f32) -> f32 { 2.0 - f } | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information | ||
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable | ||
|
||
error[E0658]: floating point arithmetic is not allowed in constant functions | ||
--> $DIR/const_fn_floating_point_arithmetic.rs:12:39 | ||
| | ||
LL | const fn mul(f: f32, g: f32) -> f32 { f * g } | ||
| ^^^^^ | ||
| | ||
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information | ||
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable | ||
|
||
error[E0658]: floating point arithmetic is not allowed in constant functions | ||
--> $DIR/const_fn_floating_point_arithmetic.rs:14:39 | ||
| | ||
LL | const fn div(f: f32, g: f32) -> f32 { f / g } | ||
| ^^^^^ | ||
| | ||
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information | ||
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable | ||
|
||
error[E0658]: floating point arithmetic is not allowed in constant functions | ||
--> $DIR/const_fn_floating_point_arithmetic.rs:16:31 | ||
| | ||
LL | const fn neg(f: f32) -> f32 { -f } | ||
| ^^ | ||
| | ||
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information | ||
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.