Skip to content
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

Passing a non-const trait function item value to a const fn is no longer allowed in a constant context #104155

Closed
yvt opened this issue Nov 8, 2022 · 4 comments · Fixed by #104180
Assignees
Labels
C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@yvt
Copy link
Contributor

yvt commented Nov 8, 2022

Code

I tried this code:

const _: () = core::mem::forget(Box::<u32>::default);       // ERROR
const _: () = core::mem::forget(|| Box::<u32>::default());  // ok

(Playground)

I expected to see this happen: Successful compilation

Instead, this happened:

error[E0277]: the trait bound `Box<u32>: Default` is not satisfied
 --> src/lib.rs:1:15
  |
1 | const _: () = core::mem::forget(Box::<u32>::default);
  |               ^^^^^^^^^^^^^^^^^ the trait `~const Default` is not implemented for `Box<u32>`
  |
note: the trait `Default` is implemented for `Box<u32>`, but that implementation is not `const`
 --> src/lib.rs:1:15
  |
1 | const _: () = core::mem::forget(Box::<u32>::default);
  |               ^^^^^^^^^^^^^^^^^

Version it worked on

It most recently worked on: 1.65.0

Version with regression

rustc --version --verbose:

rustc 1.66.0-beta.1 (e080cc5a6 2022-11-01)
binary: rustc
commit-hash: e080cc5a659fb760c0bc561b722a790dad35b5e1
commit-date: 2022-11-01
host: aarch64-apple-darwin
release: 1.66.0-beta.1
LLVM version: 15.0.2

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

@yvt yvt added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Nov 8, 2022
@rustbot rustbot added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed regression-untriaged Untriaged performance or correctness regression. labels Nov 8, 2022
@jruderman
Copy link
Contributor

This became an error due to #100982 (@fee1-dead, @oli-obk).

Bisect info

searched nightlies: from nightly-2022-09-18 to nightly-2022-11-07
regressed nightly: nightly-2022-09-23
searched commit range: 9062b78...e7119a0
regressed commit: 7a8636c

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-apple-darwin

I used cargo bisect-rustc --regress error on the following file

const _: () = core::mem::forget(Box::<u32>::default); 
fn main(){}

@fee1-dead fee1-dead self-assigned this Nov 8, 2022
@inquisitivecrystal inquisitivecrystal added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 9, 2022
@inquisitivecrystal
Copy link
Contributor

Assigning priority as discussed by the Prioritization Working Group.

@fee1-dead
Copy link
Member

awaiting beta backport

@fee1-dead fee1-dead reopened this Nov 9, 2022
yvt added a commit to r3-os/r3 that referenced this issue Nov 10, 2022
yvt added a commit to r3-os/r3 that referenced this issue Nov 12, 2022
…to `BindDefiner::init`"

This reverts commit fd8a537.

The upstream issue [rust-lang/rust#104155][1] was fixed.

[1]: rust-lang/rust#104155
@yvt
Copy link
Contributor Author

yvt commented Nov 23, 2022

Can this be closed now that beta backport (#104447) is complete?

@oli-obk oli-obk closed this as completed Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. P-critical Critical priority regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants