1
Fork 0

Update tests with new feature gate

This commit is contained in:
Dylan MacKenzie 2020-09-24 16:18:41 -07:00
parent 3cbd17fcc6
commit e2622b915a
15 changed files with 32 additions and 26 deletions

View file

@ -1,6 +1,6 @@
// Crate that exports a const fn. Used for testing cross-crate. // Crate that exports a const fn. Used for testing cross-crate.
#![feature(const_fn)] #![feature(const_fn_fn_ptr_basics)]
#![crate_type="rlib"] #![crate_type="rlib"]
pub const fn foo() -> usize { 22 } pub const fn foo() -> usize { 22 }

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
#![feature(const_fn)] #![feature(const_fn_fn_ptr_basics)]
const fn nested(x: (for<'a> fn(&'a ()), String)) -> (fn(&'static ()), String) { const fn nested(x: (for<'a> fn(&'a ()), String)) -> (fn(&'static ()), String) {
x x

View file

@ -2,7 +2,7 @@
const extern fn unsize(x: &[u8; 3]) -> &[u8] { x } const extern fn unsize(x: &[u8; 3]) -> &[u8] { x }
const unsafe extern "C" fn closure() -> fn() { || {} } const unsafe extern "C" fn closure() -> fn() { || {} }
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer
const unsafe extern fn use_float() { 1.0 + 1.0; } const unsafe extern fn use_float() { 1.0 + 1.0; }
//~^ ERROR floating point arithmetic //~^ ERROR floating point arithmetic
const extern "C" fn ptr_cast(val: *const u8) { val as usize; } const extern "C" fn ptr_cast(val: *const u8) { val as usize; }

View file

@ -2,7 +2,7 @@
#![allow(dead_code)] #![allow(dead_code)]
#![allow(unused_variables)] #![allow(unused_variables)]
#![feature(const_fn)] #![feature(const_fn_fn_ptr_basics)]
const fn x() { const fn x() {
let t = true; let t = true;

View file

@ -1,12 +1,11 @@
#![feature(const_fn)] #![feature(const_fn_fn_ptr_basics)]
const fn foo() { (||{})() } const fn foo() { (||{})() }
//~^ ERROR calls in constant functions are limited to constant functions, tuple structs and tuple //~^ ERROR calls in constant functions
// variants
const fn bad(input: fn()) { const fn bad(input: fn()) {
input() input()
//~^ ERROR function pointers are not allowed in const fn //~^ ERROR function pointer
} }
fn main() { fn main() {

View file

@ -1,12 +1,14 @@
#![feature(rustc_attrs, staged_api)] #![feature(rustc_attrs, staged_api, allow_internal_unstable)]
#![feature(const_fn_fn_ptr_basics)]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(since="1.0.0", feature = "mep")] #[rustc_const_stable(since="1.0.0", feature = "mep")]
const fn error(_: fn()) {} //~ ERROR function pointers in const fn are unstable const fn error(_: fn()) {}
//~^ ERROR const-stable function cannot use `#[feature(const_fn_fn_ptr_basics)]`
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_allow_const_fn_ptr]
#[rustc_const_stable(since="1.0.0", feature = "mep")] #[rustc_const_stable(since="1.0.0", feature = "mep")]
#[allow_internal_unstable(const_fn_fn_ptr_basics)]
const fn compiles(_: fn()) {} const fn compiles(_: fn()) {}
fn main() {} fn main() {}

View file

@ -2,10 +2,13 @@
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
const fn error(_: fn()) {} const fn error(_: fn()) {}
//~^ ERROR `rustc_const_stable` or `rustc_const_unstable`
//~| ERROR `rustc_const_stable` or `rustc_const_unstable`
//~| ERROR function pointers
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_allow_const_fn_ptr] #[rustc_const_stable(since="1.0.0", feature = "mep")]
//~^ ERROR internal implementation detail
const fn compiles(_: fn()) {} const fn compiles(_: fn()) {}
//~^ ERROR function pointers
fn main() {} fn main() {}

View file

@ -1,11 +1,13 @@
// run-pass // run-pass
#![feature(allow_internal_unstable)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(rustc_attrs, staged_api)] #![feature(rustc_attrs, staged_api)]
#![stable(feature = "rust1", since = "1.0.0")] #![stable(feature = "rust1", since = "1.0.0")]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_allow_const_fn_ptr]
#[rustc_const_stable(since="1.0.0", feature = "mep")] #[rustc_const_stable(since="1.0.0", feature = "mep")]
#[allow_internal_unstable(const_fn_fn_ptr_basics)]
const fn takes_fn_ptr(_: fn()) {} const fn takes_fn_ptr(_: fn()) {}
const FN: fn() = || (); const FN: fn() = || ();

View file

@ -2,12 +2,12 @@ fn main() {}
const fn unsize(x: &[u8; 3]) -> &[u8] { x } const fn unsize(x: &[u8; 3]) -> &[u8] { x }
const fn closure() -> fn() { || {} } const fn closure() -> fn() { || {} }
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer
const fn closure2() { const fn closure2() {
(|| {}) as fn(); (|| {}) as fn();
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer
} }
const fn reify(f: fn()) -> unsafe fn() { f } const fn reify(f: fn()) -> unsafe fn() { f }
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer
const fn reify2() { main as unsafe fn(); } const fn reify2() { main as unsafe fn(); }
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer

View file

@ -1,4 +1,4 @@
const fn cmp(x: fn(), y: fn()) -> bool { //~ ERROR function pointers in const fn are unstable const fn cmp(x: fn(), y: fn()) -> bool { //~ ERROR function pointer
unsafe { x == y } unsafe { x == y }
} }

View file

@ -128,6 +128,6 @@ const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 }
//~^ ERROR trait bounds other than `Sized` //~^ ERROR trait bounds other than `Sized`
const fn no_fn_ptrs(_x: fn()) {} const fn no_fn_ptrs(_x: fn()) {}
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer
const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
//~^ ERROR function pointers in const fn are unstable //~^ ERROR function pointer

View file

@ -9,9 +9,9 @@ fn field() {}
const fn no_inner_dyn_trait(_x: Hide) {} const fn no_inner_dyn_trait(_x: Hide) {}
const fn no_inner_dyn_trait2(x: Hide) { const fn no_inner_dyn_trait2(x: Hide) {
x.0.field; x.0.field;
//~^ ERROR function pointers in const fn //~^ ERROR function pointer
} }
const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasPtr { field }) } const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasPtr { field }) }
//~^ ERROR function pointers in const fn //~^ ERROR function pointer
fn main() {} fn main() {}

View file

@ -1,6 +1,6 @@
const fn x() { const fn x() {
let t = true; let t = true;
let x = || t; //~ ERROR function pointers in const fn are unstable let x = || t; //~ ERROR function pointer
} }
fn main() {} fn main() {}

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
#![feature(const_fn)] #![feature(const_fn_fn_ptr_basics)]
#![deny(const_err)] #![deny(const_err)]
pub struct Data<T> { pub struct Data<T> {

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
#![feature(const_fn)] #![feature(const_fn, const_fn_fn_ptr_basics)]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
type Foo = impl Fn() -> usize; type Foo = impl Fn() -> usize;