Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f496659

Browse files
committedOct 11, 2024
Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiser
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * #49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: #49804 (comment)
2 parents 484c8e7 + 6628bba commit f496659

File tree

66 files changed

+32
-3708
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+32
-3708
lines changed
 

‎compiler/rustc_ast/src/ast.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,10 +2167,6 @@ pub enum TyKind {
21672167
Never,
21682168
/// A tuple (`(A, B, C, D,...)`).
21692169
Tup(ThinVec<P<Ty>>),
2170-
/// An anonymous struct type i.e. `struct { foo: Type }`.
2171-
AnonStruct(NodeId, ThinVec<FieldDef>),
2172-
/// An anonymous union type i.e. `union { bar: Type }`.
2173-
AnonUnion(NodeId, ThinVec<FieldDef>),
21742170
/// A path (`module::module::...::Type`), optionally
21752171
/// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
21762172
///
@@ -2227,10 +2223,6 @@ impl TyKind {
22272223
None
22282224
}
22292225
}
2230-
2231-
pub fn is_anon_adt(&self) -> bool {
2232-
matches!(self, TyKind::AnonStruct(..) | TyKind::AnonUnion(..))
2233-
}
22342226
}
22352227

22362228
/// Syntax used to declare a trait object.

‎compiler/rustc_ast/src/mut_visit.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,6 @@ pub fn walk_ty<T: MutVisitor>(vis: &mut T, ty: &mut P<Ty>) {
519519
visit_vec(bounds, |bound| vis.visit_param_bound(bound, BoundKind::Impl));
520520
}
521521
TyKind::MacCall(mac) => vis.visit_mac_call(mac),
522-
TyKind::AnonStruct(id, fields) | TyKind::AnonUnion(id, fields) => {
523-
vis.visit_id(id);
524-
fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
525-
}
526522
}
527523
visit_lazy_tts(vis, tokens);
528524
vis.visit_span(span);

0 commit comments

Comments
 (0)
Please sign in to comment.