Repository navigation
Tracking Issue for De-RFC 3307: Remove type ascription #101728
Copy link
Copy link
Open
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-type_ascription`#![feature(type_ascription)]``#![feature(type_ascription)]`S-tracking-remove-implementationStatus: The feature needs to be removed from the Rust toolchain before this issue can be closedStatus: The feature needs to be removed from the Rust toolchain before this issue can be closedT-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
This supersedes #23416
This is a tracking issue for the RFC "3307" (rust-lang/rfcs#3307).
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Implement the RFC:
- Remove type ascription from the parser and diagnostics
- @rust-lang/compiler: Do y'all have a preference as to how far the removal should go? Unparseable AST nodes could be left in the code, for example (perhaps only instantiable by internal macro)
- Adjust documentation: Remove it from the unstable book
- (No stabilization PR necessary)
- Remove the feature gate.
Unresolved Questions
- Should this be completely removed by the compiler, or left behind in a way that cannot be directly accessed through Rust syntax (or requires using a wrapper macro)?
- [ ]
Implementation history
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
B-RFC-approvedBlocker: Approved by a merged RFC but not yet implemented.Blocker: Approved by a merged RFC but not yet implemented.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-type_ascription`#![feature(type_ascription)]``#![feature(type_ascription)]`S-tracking-remove-implementationStatus: The feature needs to be removed from the Rust toolchain before this issue can be closedStatus: The feature needs to be removed from the Rust toolchain before this issue can be closedT-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Activity
SoniEx2 commentedon Sep 12, 2022
Remove type ascription
Noratrieb commentedon Nov 16, 2022
@rustbot claim
I'll remove all the parsing and diagnostic logic/hacks but leave the AST nodes and everything after it behind for now.
Rollup merge of rust-lang#104614 - Nilstrieb:type-ascribe!, r=TaKO8Ki
Rollup merge of rust-lang#105614 - lukas-code:ascription, r=Nilstrieb
RalfJung commentedon Jan 10, 2023
Would it make sense to possibly replace type ascription by an unstable macro in the standard library?
I noticed #104614 added a magic macro that preserves the old semantics, but maybe we can implement this entirely in userland?
bjorn3 commentedon Jan 10, 2023
That macro shortens the lifetime of temporaries created in the expression.
Skgland commentedon Jan 12, 2023
Would a function eliviate this problems with temporaries?
Or am I missing more temporary stuff?
playground
RalfJung commentedon Jan 12, 2023
That can be wrapped in a macro, of course:
Noratrieb commentedon Feb 13, 2023
This has taken a lot more time than I thought since lots of diagnostics were relying on it in subtle ways and require restructuring. I don't have enough time to work on this and also the other things I'm working on so I'm dropping my assignment here, feel free to take it. There's a WIP PR #106826 which may or may not be useful.
@estebank maybe you're interested in working on it, given all the pains you've had with type ascription :D
@rustbot release-assignment
Auto merge of rust-lang#109128 - chenyukang:yukang/remove-type-ascrip…
Auto merge of rust-lang#109128 - chenyukang:yukang/remove-type-ascrip…
Auto merge of rust-lang#109128 - chenyukang:yukang/remove-type-ascrip…
lcnr commentedon Feb 14, 2026
@chenyukang is there still something to do here after #109128?
chenyukang commentedon Feb 15, 2026
I will take a check in the following days, I remember there are still some macros left.
chenyukang commentedon Mar 25, 2026
@lcnr now we still keep export a build-in macro for type ascription.
rust/library/core/src/macros/mod.rs
Lines 1858 to 1868 in 8a70352
and there are also some tests left for it:
https://github.com/rust-lang/rust/blob/8a703520e80d87d4423c01f9d4fbc9e5f6533a02/tests/ui/type/type-ascription-soundness.rs#L1-L14
I'm not sure can we delete them now, seems https://github.com/rust-lang/rfcs/blob/master/text/3307-de-rfc-type-ascription.md referred
It's quite possible that in the future someone will have an RFC written to reintroduce this feature