-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
261 additions
and
99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
// run-pass | ||
// compile-flags: -Zunleash-the-miri-inside-of-you | ||
#![feature(const_fn)] | ||
#![feature(const_fn_ptr)] | ||
|
||
const fn double(x: usize) -> usize { x * 2 } | ||
fn double(x: usize) -> usize { x * 2 } | ||
const fn double_const(x: usize) -> usize { x * 2 } | ||
|
||
const X: fn(usize) -> usize = double; | ||
const X_const: fn(usize) -> usize = double_const; | ||
|
||
const fn bar(x: usize) -> usize { | ||
X(x) | ||
} | ||
|
||
const fn bar_const(x: usize) -> usize { | ||
X_const(x) | ||
} | ||
|
||
const fn foo(x: fn(usize) -> usize, y: usize) -> usize { | ||
x(y) | ||
} | ||
|
||
fn main() { | ||
const Y: usize = bar(2); | ||
const Y: usize = bar_const(2); | ||
assert_eq!(Y, 4); | ||
const Z: usize = foo(double, 2); | ||
let y = bar_const(2); | ||
assert_eq!(y, 4); | ||
let y = bar(2); | ||
assert_eq!(y, 4); | ||
|
||
const Z: usize = foo(double_const, 2); | ||
assert_eq!(Z, 4); | ||
let z = foo(double_const, 2); | ||
assert_eq!(z, 4); | ||
let z = foo(double, 2); | ||
assert_eq!(z, 4); | ||
} |
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,152 @@ | ||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:25:5 | ||
| | ||
LL | assert_eq!(Y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:25:5 | ||
| | ||
LL | assert_eq!(Y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:25:5 | ||
| | ||
LL | assert_eq!(Y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:27:5 | ||
| | ||
LL | assert_eq!(y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:27:5 | ||
| | ||
LL | assert_eq!(y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:27:5 | ||
| | ||
LL | assert_eq!(y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:29:5 | ||
| | ||
LL | assert_eq!(y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:29:5 | ||
| | ||
LL | assert_eq!(y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:29:5 | ||
| | ||
LL | assert_eq!(y, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:32:5 | ||
| | ||
LL | assert_eq!(Z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:32:5 | ||
| | ||
LL | assert_eq!(Z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:32:5 | ||
| | ||
LL | assert_eq!(Z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:34:5 | ||
| | ||
LL | assert_eq!(z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:34:5 | ||
| | ||
LL | assert_eq!(z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:34:5 | ||
| | ||
LL | assert_eq!(z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:36:5 | ||
| | ||
LL | assert_eq!(z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:36:5 | ||
| | ||
LL | assert_eq!(z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: skipping const checks | ||
--> $DIR/const_fn_ptr.rs:36:5 | ||
| | ||
LL | assert_eq!(z, 4); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) | ||
|
||
warning: constant `X_const` should have an upper case name | ||
--> $DIR/const_fn_ptr.rs:9:7 | ||
| | ||
LL | const X_const: fn(usize) -> usize = double_const; | ||
| ^^^^^^^ help: convert the identifier to upper case: `X_CONST` | ||
| | ||
= note: `#[warn(non_upper_case_globals)]` on by default | ||
|
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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
// run-pass | ||
|
||
// FIXME: this should not pass | ||
|
||
// compile-flags: -Zunleash-the-miri-inside-of-you | ||
#![feature(const_fn)] | ||
#![feature(const_fn_ptr)] | ||
#![allow(unused)] | ||
|
||
fn double(x: usize) -> usize { x * 2 } | ||
const X: fn(usize) -> usize = double; | ||
|
||
const fn bar(x: usize) -> usize { | ||
X(x) | ||
X(x) // FIXME: this should error someday | ||
} | ||
|
||
fn main() {} |
This file was deleted.
Oops, something went wrong.
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.