diff options
| author | Eric Holk <ericholk@microsoft.com> | 2022-02-09 10:53:40 -0800 |
|---|---|---|
| committer | Eric Holk <ericholk@microsoft.com> | 2022-03-07 08:47:18 -0800 |
| commit | 8fc835831c1a84ba27d8bbafec480f02b2e29663 (patch) | |
| tree | 77b52a87c9f3dffef165e72a93a56967cdae1495 /src/test/ui/consts | |
| parent | 7723506d13a03e3191d407aaf3709f157bf75193 (diff) | |
| download | rust-8fc835831c1a84ba27d8bbafec480f02b2e29663.tar.gz rust-8fc835831c1a84ba27d8bbafec480f02b2e29663.zip | |
Update tests after feature stabilization
Diffstat (limited to 'src/test/ui/consts')
36 files changed, 43 insertions, 537 deletions
diff --git a/src/test/ui/consts/auxiliary/const_fn_lib.rs b/src/test/ui/consts/auxiliary/const_fn_lib.rs index bf0b01a2ecf..88cea60e1b8 100644 --- a/src/test/ui/consts/auxiliary/const_fn_lib.rs +++ b/src/test/ui/consts/auxiliary/const_fn_lib.rs @@ -1,6 +1,5 @@ // Crate that exports a const fn. Used for testing cross-crate. -#![feature(const_fn_fn_ptr_basics)] #![crate_type="rlib"] pub const fn foo() -> usize { 22 } diff --git a/src/test/ui/consts/const-block-const-bound.rs b/src/test/ui/consts/const-block-const-bound.rs index f3c82c5f968..1ccd0ee9370 100644 --- a/src/test/ui/consts/const-block-const-bound.rs +++ b/src/test/ui/consts/const-block-const-bound.rs @@ -1,5 +1,5 @@ #![allow(unused)] -#![feature(const_fn_trait_bound, const_trait_impl, inline_const, negative_impls)] +#![feature(const_trait_impl, inline_const, negative_impls)] const fn f<T: ~const Drop>(x: T) {} diff --git a/src/test/ui/consts/const-eval/const_fn_ptr.stderr b/src/test/ui/consts/const-eval/const_fn_ptr.stderr index a16ac7b2a24..ca1585f8837 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr.stderr @@ -10,23 +10,11 @@ help: skipping check that does not even have a feature gate | LL | X_CONST(x) | ^^^^^^^^^^ -help: skipping check for `const_fn_fn_ptr_basics` feature - --> $DIR/const_fn_ptr.rs:18:14 - | -LL | const fn foo(x: fn(usize) -> usize, y: usize) -> usize { - | ^ -help: skipping check for `const_fn_fn_ptr_basics` feature - --> $DIR/const_fn_ptr.rs:19:5 - | -LL | x(y) - | ^ help: skipping check that does not even have a feature gate --> $DIR/const_fn_ptr.rs:19:5 | LL | x(y) | ^^^^ -error: `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine - -error: aborting due to previous error; 1 warning emitted +warning: 1 warning emitted diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr index 4f7a771f418..c17166263ba 100644 --- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -12,16 +12,6 @@ LL | assert_eq!(Z, 4); warning: skipping const checks | -help: skipping check for `const_fn_fn_ptr_basics` feature - --> $DIR/const_fn_ptr_fail2.rs:11:14 - | -LL | const fn bar(x: fn(usize) -> usize, y: usize) -> usize { - | ^ -help: skipping check for `const_fn_fn_ptr_basics` feature - --> $DIR/const_fn_ptr_fail2.rs:12:5 - | -LL | x(y) - | ^ help: skipping check that does not even have a feature gate --> $DIR/const_fn_ptr_fail2.rs:12:5 | diff --git a/src/test/ui/consts/const-eval/issue-49296.rs b/src/test/ui/consts/const-eval/issue-49296.rs index 80f6bbec2a1..917777a32ff 100644 --- a/src/test/ui/consts/const-eval/issue-49296.rs +++ b/src/test/ui/consts/const-eval/issue-49296.rs @@ -1,7 +1,5 @@ // issue-49296: Unsafe shenigans in constants can result in missing errors -#![feature(const_fn_trait_bound)] - use std::mem::transmute; const fn wat(x: u64) -> &'static u64 { diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index bc3074b10be..1864a284579 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/issue-49296.rs:11:16 + --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); | ^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed diff --git a/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs b/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs index bf8bae5ea2c..abd1d32abe2 100644 --- a/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs +++ b/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs @@ -1,5 +1,4 @@ // check-pass -#![feature(const_fn_fn_ptr_basics)] const fn nested(x: (for<'a> fn(&'a ()), String)) -> (fn(&'static ()), String) { x diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs index 46748673067..c7078e46fa6 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.rs @@ -2,8 +2,6 @@ const extern "C" fn unsize(x: &[u8; 3]) -> &[u8] { x } const unsafe extern "C" fn closure() -> fn() { || {} } -//~^ ERROR function pointer -//~| ERROR function pointer cast const unsafe extern "C" fn use_float() { 1.0 + 1.0; } //~^ ERROR floating point arithmetic const extern "C" fn ptr_cast(val: *const u8) { val as usize; } diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr index 2b2d23477f6..4bab466fb95 100644 --- a/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr +++ b/src/test/ui/consts/const-extern-fn/const-extern-fn-min-const-fn.stderr @@ -1,23 +1,5 @@ -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/const-extern-fn-min-const-fn.rs:4:41 - | -LL | const unsafe extern "C" fn closure() -> fn() { || {} } - | ^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/const-extern-fn-min-const-fn.rs:4:48 - | -LL | const unsafe extern "C" fn closure() -> fn() { || {} } - | ^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - error[E0658]: floating point arithmetic is not allowed in constant functions - --> $DIR/const-extern-fn-min-const-fn.rs:7:42 + --> $DIR/const-extern-fn-min-const-fn.rs:5:42 | LL | const unsafe extern "C" fn use_float() { 1.0 + 1.0; } | ^^^^^^^^^ @@ -26,7 +8,7 @@ LL | const unsafe extern "C" fn use_float() { 1.0 + 1.0; } = help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable error: pointers cannot be cast to integers during const eval - --> $DIR/const-extern-fn-min-const-fn.rs:9:48 + --> $DIR/const-extern-fn-min-const-fn.rs:7:48 | LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; } | ^^^^^^^^^^^^ @@ -34,6 +16,6 @@ LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; } = note: at compile-time, pointers do not have an integer value = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-fn.rs b/src/test/ui/consts/const-fn.rs index 1928c51885e..59680e6e4a8 100644 --- a/src/test/ui/consts/const-fn.rs +++ b/src/test/ui/consts/const-fn.rs @@ -4,7 +4,6 @@ // A very basic test of const fn functionality. #![feature(const_indexing)] -#![feature(const_fn_trait_bound)] const fn add(x: u32, y: u32) -> u32 { x + y diff --git a/src/test/ui/consts/const_fn_trait_bound.gated.stderr b/src/test/ui/consts/const_fn_trait_bound.gated.stderr deleted file mode 100644 index ded05cb17c5..00000000000 --- a/src/test/ui/consts/const_fn_trait_bound.gated.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/const_fn_trait_bound.rs:17:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/consts/const_fn_trait_bound.rs b/src/test/ui/consts/const_fn_trait_bound.rs deleted file mode 100644 index 19c08b62144..00000000000 --- a/src/test/ui/consts/const_fn_trait_bound.rs +++ /dev/null @@ -1,17 +0,0 @@ -// gate-test-const_fn_trait_bound - -// revisions: stock gated - -#![feature(rustc_attrs)] -#![cfg_attr(gated, feature(const_fn_trait_bound))] - -const fn test1<T: std::ops::Add>() {} -//[stock]~^ trait bounds -const fn test2(_x: &dyn Send) {} -//[stock]~^ trait objects in const fn are unstable -const fn test3() -> &'static dyn Send { loop {} } -//[stock]~^ trait objects in const fn are unstable - - -#[rustc_error] -fn main() {} //[gated]~ fatal error triggered by #[rustc_error] diff --git a/src/test/ui/consts/const_fn_trait_bound.stock.stderr b/src/test/ui/consts/const_fn_trait_bound.stock.stderr deleted file mode 100644 index 7d9e18cb341..00000000000 --- a/src/test/ui/consts/const_fn_trait_bound.stock.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/const_fn_trait_bound.rs:8:16 - | -LL | const fn test1<T: std::ops::Add>() {} - | ^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/const_fn_trait_bound.rs:10:16 - | -LL | const fn test2(_x: &dyn Send) {} - | ^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/const_fn_trait_bound.rs:12:21 - | -LL | const fn test3() -> &'static dyn Send { loop {} } - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/issue-37550-1.rs b/src/test/ui/consts/issue-37550-1.rs index 35b63bddca2..4d00ac7fd0d 100644 --- a/src/test/ui/consts/issue-37550-1.rs +++ b/src/test/ui/consts/issue-37550-1.rs @@ -1,6 +1,8 @@ +// check-pass + const fn x() { let t = true; - let x = || t; //~ ERROR function pointer + let x = || t; } fn main() {} diff --git a/src/test/ui/consts/issue-37550-1.stderr b/src/test/ui/consts/issue-37550-1.stderr deleted file mode 100644 index f66d7067870..00000000000 --- a/src/test/ui/consts/issue-37550-1.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/issue-37550-1.rs:3:9 - | -LL | let x = || t; - | ^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/issue-37550.rs b/src/test/ui/consts/issue-37550.rs index 15877c53747..724eb28291e 100644 --- a/src/test/ui/consts/issue-37550.rs +++ b/src/test/ui/consts/issue-37550.rs @@ -2,8 +2,6 @@ #![allow(dead_code)] #![allow(unused_variables)] -#![feature(const_fn_fn_ptr_basics)] - const fn x() { let t = true; let x = || t; diff --git a/src/test/ui/consts/issue-46553.rs b/src/test/ui/consts/issue-46553.rs index 0a1e835672d..9438df1937b 100644 --- a/src/test/ui/consts/issue-46553.rs +++ b/src/test/ui/consts/issue-46553.rs @@ -1,5 +1,4 @@ // run-pass -#![feature(const_fn_fn_ptr_basics)] #![deny(const_err)] pub struct Data<T> { diff --git a/src/test/ui/consts/issue-56164.rs b/src/test/ui/consts/issue-56164.rs index 9c673d20b2a..22ac75514f6 100644 --- a/src/test/ui/consts/issue-56164.rs +++ b/src/test/ui/consts/issue-56164.rs @@ -1,5 +1,3 @@ -#![feature(const_fn_fn_ptr_basics)] - const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure diff --git a/src/test/ui/consts/issue-56164.stderr b/src/test/ui/consts/issue-56164.stderr index 62a7c7db6b8..803424eedf3 100644 --- a/src/test/ui/consts/issue-56164.stderr +++ b/src/test/ui/consts/issue-56164.stderr @@ -1,5 +1,5 @@ error[E0015]: cannot call non-const closure in constant functions - --> $DIR/issue-56164.rs:3:18 + --> $DIR/issue-56164.rs:1:18 | LL | const fn foo() { (||{})() } | ^^^^^^^^ @@ -8,7 +8,7 @@ LL | const fn foo() { (||{})() } = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: function pointers are not allowed in const fn - --> $DIR/issue-56164.rs:7:5 + --> $DIR/issue-56164.rs:5:5 | LL | input() | ^^^^^^^ diff --git a/src/test/ui/consts/issue-88071.rs b/src/test/ui/consts/issue-88071.rs index a2d4a642128..1c38c43e6c0 100644 --- a/src/test/ui/consts/issue-88071.rs +++ b/src/test/ui/consts/issue-88071.rs @@ -3,7 +3,6 @@ // regression test for #88071 #![feature(const_btree_new)] -#![feature(const_fn_trait_bound)] use std::collections::BTreeMap; diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr.rs b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr.rs deleted file mode 100644 index a0870ea6de3..00000000000 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(rustc_attrs, staged_api, rustc_allow_const_fn_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")] -const fn error(_: fn()) {} -//~^ ERROR const-stable function cannot use `#[feature(const_fn_fn_ptr_basics)]` - -#[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_stable(since="1.0.0", feature = "mep")] -#[rustc_allow_const_fn_unstable(const_fn_fn_ptr_basics)] -const fn compiles(_: fn()) {} - -fn main() {} diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr.stderr b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr.stderr deleted file mode 100644 index 3523cab49fd..00000000000 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: const-stable function cannot use `#[feature(const_fn_fn_ptr_basics)]` - --> $DIR/allow_const_fn_ptr.rs:7:16 - | -LL | const fn error(_: fn()) {} - | ^ - | -help: if it is not part of the public API, make this function unstably const - | -LL | #[rustc_const_unstable(feature = "...", issue = "...")] - | -help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks - | -LL | #[rustc_allow_const_fn_unstable(const_fn_fn_ptr_basics)] - | - -error: aborting due to previous error - diff --git a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_run_pass.rs b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_run_pass.rs index 430e911aacd..2dbc424d3ba 100644 --- a/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_run_pass.rs +++ b/src/test/ui/consts/min_const_fn/allow_const_fn_ptr_run_pass.rs @@ -1,13 +1,11 @@ // run-pass #![feature(rustc_allow_const_fn_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_const_stable(since="1.0.0", feature = "mep")] -#[rustc_allow_const_fn_unstable(const_fn_fn_ptr_basics)] const fn takes_fn_ptr(_: fn()) {} const FN: fn() = || (); diff --git a/src/test/ui/consts/min_const_fn/cast_errors.rs b/src/test/ui/consts/min_const_fn/cast_errors.rs deleted file mode 100644 index b68f47f5cbc..00000000000 --- a/src/test/ui/consts/min_const_fn/cast_errors.rs +++ /dev/null @@ -1,17 +0,0 @@ -fn main() {} - -const fn unsize(x: &[u8; 3]) -> &[u8] { x } -const fn closure() -> fn() { || {} } -//~^ ERROR function pointer -//~| ERROR function pointer cast -const fn closure2() { - (|| {}) as fn(); -//~^ ERROR function pointer -} -const fn reify(f: fn()) -> unsafe fn() { f } -//~^ ERROR function pointer -//~| ERROR function pointer -//~| ERROR function pointer cast -const fn reify2() { main as unsafe fn(); } -//~^ ERROR function pointer -//~| ERROR function pointer cast diff --git a/src/test/ui/consts/min_const_fn/cast_errors.stderr b/src/test/ui/consts/min_const_fn/cast_errors.stderr deleted file mode 100644 index fb962bdf906..00000000000 --- a/src/test/ui/consts/min_const_fn/cast_errors.stderr +++ /dev/null @@ -1,75 +0,0 @@ -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/cast_errors.rs:4:23 - | -LL | const fn closure() -> fn() { || {} } - | ^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/cast_errors.rs:4:30 - | -LL | const fn closure() -> fn() { || {} } - | ^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/cast_errors.rs:8:5 - | -LL | (|| {}) as fn(); - | ^^^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/cast_errors.rs:11:16 - | -LL | const fn reify(f: fn()) -> unsafe fn() { f } - | ^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/cast_errors.rs:11:28 - | -LL | const fn reify(f: fn()) -> unsafe fn() { f } - | ^^^^^^^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/cast_errors.rs:11:42 - | -LL | const fn reify(f: fn()) -> unsafe fn() { f } - | ^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/cast_errors.rs:15:21 - | -LL | const fn reify2() { main as unsafe fn(); } - | ^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/cast_errors.rs:15:21 - | -LL | const fn reify2() { main as unsafe fn(); } - | ^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/min_const_fn/cast_fn.rs b/src/test/ui/consts/min_const_fn/cast_fn.rs new file mode 100644 index 00000000000..85802a51490 --- /dev/null +++ b/src/test/ui/consts/min_const_fn/cast_fn.rs @@ -0,0 +1,11 @@ +// check-pass + +fn main() {} + +const fn unsize(x: &[u8; 3]) -> &[u8] { x } +const fn closure() -> fn() { || {} } +const fn closure2() { + (|| {}) as fn(); +} +const fn reify(f: fn()) -> unsafe fn() { f } +const fn reify2() { main as unsafe fn(); } diff --git a/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs b/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs index 638ff1d8b9c..e07b269c386 100644 --- a/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs +++ b/src/test/ui/consts/min_const_fn/cmp_fn_pointers.rs @@ -1,6 +1,4 @@ const fn cmp(x: fn(), y: fn()) -> bool { - //~^ ERROR function pointer - //~| ERROR function pointer unsafe { x == y } //~^ ERROR pointers cannot be reliably compared } diff --git a/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr b/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr index 5d8483cd111..3845068d841 100644 --- a/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr +++ b/src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr @@ -1,29 +1,10 @@ -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/cmp_fn_pointers.rs:1:14 - | -LL | const fn cmp(x: fn(), y: fn()) -> bool { - | ^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/cmp_fn_pointers.rs:1:23 - | -LL | const fn cmp(x: fn(), y: fn()) -> bool { - | ^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - error: pointers cannot be reliably compared during const eval - --> $DIR/cmp_fn_pointers.rs:4:14 + --> $DIR/cmp_fn_pointers.rs:2:14 | LL | unsafe { x == y } | ^^^^^^ | = note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information -error: aborting due to 3 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0658`. 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 10347a02074..0bafaf2e81f 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 @@ -80,11 +80,10 @@ const unsafe fn ret_i32_no_unsafe() -> i32 { 42 } const unsafe fn ret_null_ptr_no_unsafe<T>() -> *const T { core::ptr::null() } const unsafe fn ret_null_mut_ptr_no_unsafe<T>() -> *mut T { core::ptr::null_mut() } -// not ok const fn foo11<T: std::fmt::Display>(t: T) -> T { t } -//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable const fn foo11_2<T: Send>(t: T) -> T { t } -//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable + +// not ok static BAR: u32 = 42; const fn foo25() -> u32 { BAR } //~ ERROR cannot refer to statics @@ -108,41 +107,28 @@ const fn foo37(a: bool, b: bool) -> bool { a || b } fn main() {} impl<T: std::fmt::Debug> Foo<T> { -//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable const fn foo(&self) {} } impl<T: std::fmt::Debug + Sized> Foo<T> { -//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable const fn foo2(&self) {} } impl<T: Sync + Sized> Foo<T> { -//~^ ERROR trait bounds other than `Sized` on const fn parameters are unstable const fn foo3(&self) {} } struct AlanTuring<T>(T); const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {} -//~^ ERROR trait bounds other than `Sized` -//~| ERROR destructor +//~^ ERROR destructor const fn no_apit(_x: impl std::fmt::Debug) {} -//~^ ERROR trait bounds other than `Sized` -//~| ERROR destructor +//~^ ERROR destructor const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} -//~^ ERROR trait objects in const fn are unstable const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } -//~^ ERROR trait objects in const fn are unstable const fn no_unsafe() { unsafe {} } -const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } -//~^ ERROR trait objects in const fn are unstable -//~| ERROR trait objects in const fn are unstable -//~| ERROR trait objects in const fn are unstable +const fn traits_are_ok_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } -const fn no_fn_ptrs(_x: fn()) {} -//~^ ERROR function pointer -const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } -//~^ ERROR function pointer -//~| ERROR function pointer cast +const fn fn_ptrs(_x: fn()) {} +const fn fn_ptrs2() -> fn() { fn foo() {} foo } 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 67cb604b6a7..4ad17602c84 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 @@ -130,26 +130,8 @@ LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:84:16 - | -LL | const fn foo11<T: std::fmt::Display>(t: T) -> T { t } - | ^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:86:18 - | -LL | const fn foo11_2<T: Send>(t: T) -> T { t } - | ^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - error[E0013]: constant functions cannot refer to statics - --> $DIR/min_const_fn.rs:90:27 + --> $DIR/min_const_fn.rs:89:27 | LL | const fn foo25() -> u32 { BAR } | ^^^ @@ -157,7 +139,7 @@ LL | const fn foo25() -> u32 { BAR } = help: consider extracting the value of the `static` to a `const`, and referring to that error[E0013]: constant functions cannot refer to statics - --> $DIR/min_const_fn.rs:91:37 + --> $DIR/min_const_fn.rs:90:37 | LL | const fn foo26() -> &'static u32 { &BAR } | ^^^ @@ -165,7 +147,7 @@ LL | const fn foo26() -> &'static u32 { &BAR } = help: consider extracting the value of the `static` to a `const`, and referring to that error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:92:42 + --> $DIR/min_const_fn.rs:91:42 | LL | const fn foo30(x: *const u32) -> usize { x as usize } | ^^^^^^^^^^ @@ -174,7 +156,7 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:94:63 + --> $DIR/min_const_fn.rs:93:63 | LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } | ^^^^^^^^^^ @@ -183,7 +165,7 @@ LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:96:42 + --> $DIR/min_const_fn.rs:95:42 | LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } | ^^^^^^^^^^ @@ -192,7 +174,7 @@ LL | const fn foo30_2(x: *mut u32) -> usize { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error: pointers cannot be cast to integers during const eval - --> $DIR/min_const_fn.rs:98:63 + --> $DIR/min_const_fn.rs:97:63 | LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } } | ^^^^^^^^^^ @@ -201,7 +183,7 @@ LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } = note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior error[E0658]: mutable references are not allowed in constant functions - --> $DIR/min_const_fn.rs:101:14 + --> $DIR/min_const_fn.rs:100:14 | LL | const fn inc(x: &mut i32) { *x += 1 } | ^ @@ -209,155 +191,23 @@ LL | const fn inc(x: &mut i32) { *x += 1 } = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:110:6 - | -LL | impl<T: std::fmt::Debug> Foo<T> { - | ^ -LL | -LL | const fn foo(&self) {} - | ------------------- function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:115:6 - | -LL | impl<T: std::fmt::Debug + Sized> Foo<T> { - | ^ -LL | -LL | const fn foo2(&self) {} - | -------------------- function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:120:6 - | -LL | impl<T: Sync + Sized> Foo<T> { - | ^ -LL | -LL | const fn foo3(&self) {} - | -------------------- function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:126:34 - | -LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:126:19 + --> $DIR/min_const_fn.rs:122:19 | LL | const fn no_apit2(_x: AlanTuring<impl std::fmt::Debug>) {} | ^^ - value is dropped here | | | constant functions cannot evaluate destructors -error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable - --> $DIR/min_const_fn.rs:129:22 - | -LL | const fn no_apit(_x: impl std::fmt::Debug) {} - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - error[E0493]: destructors cannot be evaluated at compile-time - --> $DIR/min_const_fn.rs:129:18 + --> $DIR/min_const_fn.rs:124:18 | LL | const fn no_apit(_x: impl std::fmt::Debug) {} | ^^ - value is dropped here | | | constant functions cannot evaluate destructors -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn.rs:132:23 - | -LL | const fn no_dyn_trait(_x: &dyn std::fmt::Debug) {} - | ^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn.rs:134:32 - | -LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn.rs:139:41 - | -LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } - | ------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn.rs:139:42 - | -LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } - | ------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn.rs:139:42 - | -LL | const fn really_no_traits_i_mean_it() { (&() as &dyn std::fmt::Debug, ()).1 } - | ------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/min_const_fn.rs:144:21 - | -LL | const fn no_fn_ptrs(_x: fn()) {} - | ^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/min_const_fn.rs:146:27 - | -LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/min_const_fn.rs:146:46 - | -LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } - | ^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error: aborting due to 39 previous errors +error: aborting due to 24 previous errors Some errors have detailed explanations: E0013, E0493, E0658. For more information about an error, try `rustc --explain E0013`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs index 1ab8253b414..36c8880093e 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.rs @@ -1,3 +1,5 @@ +// check-pass + struct HasDyn { field: &'static dyn std::fmt::Debug, } @@ -7,9 +9,7 @@ struct Hide(HasDyn); const fn no_inner_dyn_trait(_x: Hide) {} const fn no_inner_dyn_trait2(x: Hide) { x.0.field; -//~^ ERROR trait objects in const fn are unstable } const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } -//~^ ERROR trait objects in const fn are unstable fn main() {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr deleted file mode 100644 index 4c2199101d3..00000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn_dyn.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn_dyn.rs:9:5 - | -LL | const fn no_inner_dyn_trait2(x: Hide) { - | ------------------------------------- function declared as const here -LL | x.0.field; - | ^^^^^^^^^ - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error[E0658]: trait objects in const fn are unstable - --> $DIR/min_const_fn_dyn.rs:12:66 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) } - | ----------------------------------------- ^^ - | | - | function declared as const here - | - = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information - = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs b/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs deleted file mode 100644 index bc6fe89222b..00000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.rs +++ /dev/null @@ -1,19 +0,0 @@ -// gate-test-const_fn_fn_ptr_basics - -struct HasPtr { - field: fn(), -} - -struct Hide(HasPtr); - -fn field() {} - -const fn no_inner_dyn_trait(_x: Hide) {} -const fn no_inner_dyn_trait2(x: Hide) { - x.0.field; -//~^ ERROR function pointer -} -const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasPtr { field }) } -//~^ ERROR function pointer - -fn main() {} diff --git a/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr b/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr deleted file mode 100644 index 8d82674bbf2..00000000000 --- a/src/test/ui/consts/min_const_fn/min_const_fn_fn_ptr.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0658]: function pointers cannot appear in constant functions - --> $DIR/min_const_fn_fn_ptr.rs:13:5 - | -LL | x.0.field; - | ^^^^^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error[E0658]: function pointer casts are not allowed in constant functions - --> $DIR/min_const_fn_fn_ptr.rs:16:59 - | -LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasPtr { field }) } - | ^^^^^ - | - = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information - = help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr index e2f9708ddcb..aaba19c2c8b 100644 --- a/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr +++ b/src/test/ui/consts/miri_unleashed/abi-mismatch.stderr @@ -12,16 +12,6 @@ LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern " warning: skipping const checks | -help: skipping check for `const_fn_fn_ptr_basics` feature - --> $DIR/abi-mismatch.rs:9:23 - | -LL | const fn call_rust_fn(my_fn: extern "Rust" fn()) { - | ^^^^^ -help: skipping check for `const_fn_fn_ptr_basics` feature - --> $DIR/abi-mismatch.rs:10:5 - | -LL | my_fn(); - | ^^^^^ help: skipping check that does not even have a feature gate --> $DIR/abi-mismatch.rs:10:5 | diff --git a/src/test/ui/consts/unstable-const-fn-in-libcore.rs b/src/test/ui/consts/unstable-const-fn-in-libcore.rs index 8ee1270805e..16b36c8d56d 100644 --- a/src/test/ui/consts/unstable-const-fn-in-libcore.rs +++ b/src/test/ui/consts/unstable-const-fn-in-libcore.rs @@ -5,7 +5,6 @@ #![stable(feature = "core", since = "1.6.0")] #![feature(staged_api)] -#![feature(const_fn_trait_bound)] enum Opt<T> { Some(T), |
