-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Code
I first noticed this in #109122 (review), but there are also existing regressions from other ~const
additions. For example:
type I32Cmp = fn(&i32, &i32) -> core::cmp::Ordering;
pub const fn min_by_i32() -> fn(i32, i32, I32Cmp) -> i32 {
core::cmp::min_by
}
I expected to see this happen: compiles fine.
Instead, this happened: errors that ~const FnOnce
is not implemented for the I32Cmp
function pointer.
error[E0277]: the trait bound `for<'a, 'b> for<'a, 'b> fn(&'a i32, &'b i32) -> std::cmp::Ordering: FnOnce<(&'a i32, &'b i32)>` is not satisfied
--> error.rs:3:5
|
3 | core::cmp::min_by
| ^^^^^^^^^^^^^^^^^ expected an `FnOnce<(&i32, &i32)>` closure, found `for<'a, 'b> fn(&'a i32, &'b i32) -> std::cmp::Ordering`
|
= help: the trait `for<'a, 'b> ~const FnOnce<(&'a i32, &'b i32)>` is not implemented for `for<'a, 'b> fn(&'a i32, &'b i32) -> std::cmp::Ordering`
note: the trait `for<'a, 'b> FnOnce<(&'a i32, &'b i32)>` is implemented for `for<'a, 'b> fn(&'a i32, &'b i32) -> std::cmp::Ordering`, but that implementation is not `const`
--> error.rs:3:5
|
3 | core::cmp::min_by
| ^^^^^^^^^^^^^^^^^
note: required by a bound in `std::cmp::min_by`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
Version it worked on
For that particular example, it most recently worked on: 1.65.0
Version with regression
After #102245 reached stable, rustc --version --verbose
:
rustc 1.66.0 (69f9c33d7 2022-12-12)
binary: rustc
commit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943
commit-date: 2022-12-12
host: x86_64-unknown-linux-gnu
release: 1.66.0
LLVM version: 15.0.2
... but I don't mean to pick on that particular PR -- I think there's a more general problem with ~const
here.
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.