-
-
Notifications
You must be signed in to change notification settings - Fork 16k
ManuallyDrop allows storing invalid references in consts and statics. #159701
Copy link
Copy link
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-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-langRelevant to the language teamRelevant to the language teamT-opsemRelevant to the opsem teamRelevant to the opsem team
Description
Activity
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-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-langRelevant to the language teamRelevant to the language teamT-opsemRelevant to the opsem teamRelevant to the opsem team
This is not necessarily a bug, but I think it's worth noting as an unintended(?) consequence of the
MaybeDanglingchanges, probably in #150446. See also #118166. Note that theManuallyDroptype currently contains aMaybeDanglinginside.The following code compiles since 1.96.0:
(Note: We're using
4sincei32has alignment4.)In 1.95.0, it produced the following error:
Attempting to use the
constin a pattern results in a strange diagnostic:Is this the correct behavior?
cc @WaffleLapkin @RalfJung
Meta
Tested on
1.99.0-nightly (2026-07-20 87e5904f5eb6398af6b2)on the playground