Closed
Metadata
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Blocker: Approved by a merged RFC and implemented but not stabilized.Blocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the language team
Activity
const fn
#57563Centril commentedon Jun 15, 2019
Implemented on 2019-06-07 by @matthewjasper in #61209 which was reviewed by @oli-obk
mexus commentedon Aug 26, 2019
Is there anything else needs to be done to resolve this issue?
mati865 commentedon Aug 26, 2019
FCP and stabilization pull request.
Centril commentedon Aug 26, 2019
@matthewjasper Do you think you have time to write a report (e.g. in the style of #61682) and amend the reference after?
matthewjasper commentedon Sep 15, 2019
Stabilization proposal
I propose that we stabilize
#![feature(const_constructor)]
.Tracking issue: #61456
Version target: 1.40 (2019-11-05 => beta, 2019-12-19 => stable).
What is stabilized
User guide
Tuple struct and tuple variant constructors are now considered to be constant functions. As such a call expression where the callee has a tuple struct or variant constructor "function item" type can be called :
Motivation
Consistency with other
const fn
.This should also ensure that constructors implement
const Fn
traits and can be coerced toconst fn
function pointers, if they are introduced.Test
https://github.com/rust-lang/rust/blob/0d75ab2293a106eb674ac01860910cfc1580837e/src/test/ui/consts/const_constructor/const-construct-call.rs - Tests various syntactic forms, use in both
const fn
andconst
items, and constructors in both the current and extern crates.The case in #64247 should also get a test.
const_constructor
feature rust-lang/reference#677Centril commentedon Sep 15, 2019
@matthewjasper Thanks! Could you embed this report in a PR with the aforementioned test added there as well? I'll FCP that PR.
const_constructor
#65188Auto merge of #65188 - matthewjasper:stabilize-const-constructor, r=C…
Auto merge of #65188 - matthewjasper:stabilize-const-constructor, r=C…
Option<&'static dyn T>::None
in aconst fn
requiresconst_fn_trait_bounds
#87240