Skip to content

add back test for stable-const-can-only-call-stable-const #129553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn
const_eval_unstable_in_stable =
const-stable function cannot use `#[feature({$gate})]`
.unstable_sugg = if it is not part of the public API, make this function unstably const
.bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
.bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)

const_eval_unterminated_c_string =
reading a null-terminated string starting at {$pointer} with no null found before end of allocation
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/consts/min_const_fn/allow_const_fn_ptr_run_pass.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//@ run-pass
#![feature(rustc_allow_const_fn_unstable)]

#![feature(rustc_attrs, staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ const fn bar2() -> u32 { foo2() } //~ ERROR not yet stable as a const fn
// conformity is required
const fn bar3() -> u32 {
let x = std::cell::Cell::new(0u32);
x.get()
x.get();
//~^ ERROR const-stable function cannot use `#[feature(const_refs_to_cell)]`
//~| ERROR cannot call non-const fn
foo()
//~^ ERROR is not yet stable as a const fn
}

// check whether this function cannot be called even with the feature gate active
Expand Down
18 changes: 13 additions & 5 deletions tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ LL | const fn bar2() -> u32 { foo2() }
error: const-stable function cannot use `#[feature(const_refs_to_cell)]`
--> $DIR/min_const_fn_libstd_stability.rs:31:5
|
LL | x.get()
LL | x.get();
| ^
|
help: if it is not part of the public API, make this function unstably const
|
LL + #[rustc_const_unstable(feature = "...", issue = "...")]
LL | const fn bar3() -> u32 {
|
help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
|
LL + #[rustc_allow_const_fn_unstable(const_refs_to_cell)]
LL | const fn bar3() -> u32 {
Expand All @@ -34,19 +34,27 @@ LL | const fn bar3() -> u32 {
error[E0015]: cannot call non-const fn `Cell::<u32>::get` in constant functions
--> $DIR/min_const_fn_libstd_stability.rs:31:7
|
LL | x.get()
LL | x.get();
| ^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error: `foo` is not yet stable as a const fn
--> $DIR/min_const_fn_libstd_stability.rs:34:5
|
LL | foo()
| ^^^^^
|
= help: const-stable functions can only call other const-stable functions

error: `foo2_gated` is not yet stable as a const fn
--> $DIR/min_const_fn_libstd_stability.rs:43:32
--> $DIR/min_const_fn_libstd_stability.rs:45:32
|
LL | const fn bar2_gated() -> u32 { foo2_gated() }
| ^^^^^^^^^^^^
|
= help: const-stable functions can only call other const-stable functions

error: aborting due to 5 previous errors
error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0015`.
Loading