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.
#![feature(const_fn)]
#![feature(const_fn_fn_ptr_basics)]
#![crate_type="rlib"]
pub const fn foo() -> usize { 22 }

View File

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

View File

@ -2,7 +2,7 @@
const extern fn unsize(x: &[u8; 3]) -> &[u8] { x }
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; }
//~^ ERROR floating point arithmetic
const extern "C" fn ptr_cast(val: *const u8) { val as usize; }

View File

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

View File

@ -1,12 +1,11 @@
#![feature(const_fn)]
#![feature(const_fn_fn_ptr_basics)]
const fn foo() { (||{})() }
//~^ ERROR calls in constant functions are limited to constant functions, tuple structs and tuple
// variants
//~^ ERROR calls in constant functions
const fn bad(input: fn()) {
input()
//~^ ERROR function pointers are not allowed in const fn
//~^ ERROR function pointer
}
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")]
#[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")]
#[rustc_allow_const_fn_ptr]
#[rustc_const_stable(since="1.0.0", feature = "mep")]
#[allow_internal_unstable(const_fn_fn_ptr_basics)]
const fn compiles(_: fn()) {}
fn main() {}

View File

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

View File

@ -1,11 +1,13 @@
// run-pass
#![feature(allow_internal_unstable)]
#![feature(const_fn_fn_ptr_basics)]
#![feature(rustc_attrs, staged_api)]
#![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")]
#[allow_internal_unstable(const_fn_fn_ptr_basics)]
const fn takes_fn_ptr(_: fn()) {}
const FN: fn() = || ();

View File

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

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`
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 }
//~^ 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_trait2(x: Hide) {
x.0.field;
//~^ ERROR function pointers in const fn
//~^ ERROR function pointer
}
const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasPtr { field }) }
//~^ ERROR function pointers in const fn
//~^ ERROR function pointer
fn main() {}

View File

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

View File

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

View File

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