Skip to content

Commit b6aa7e3

Browse files
committed
Manually crafted revert of d4ad050 .
1 parent f38ec9c commit b6aa7e3

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

-68
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,13 @@ impl<'a> AstValidator<'a> {
193193
}
194194
}
195195
}
196-
TyKind::AnonymousStruct(ref fields, ..) | TyKind::AnonymousUnion(ref fields, ..) => {
197-
self.with_banned_assoc_ty_bound(|this| {
198-
walk_list!(this, visit_struct_field_def, fields)
199-
});
200-
}
201196
_ => visit::walk_ty(self, t),
202197
}
203198
}
204199

205200
fn visit_struct_field_def(&mut self, field: &'a FieldDef) {
206201
if let Some(ident) = field.ident {
207202
if ident.name == kw::Underscore {
208-
self.check_anonymous_field(field);
209203
self.visit_vis(&field.vis);
210204
self.visit_ident(ident);
211205
self.visit_ty_common(&field.ty);
@@ -251,66 +245,6 @@ impl<'a> AstValidator<'a> {
251245
err.emit();
252246
}
253247

254-
fn check_anonymous_field(&self, field: &FieldDef) {
255-
let FieldDef { ty, .. } = field;
256-
match &ty.kind {
257-
TyKind::AnonymousStruct(..) | TyKind::AnonymousUnion(..) => {
258-
// We already checked for `kw::Underscore` before calling this function,
259-
// so skip the check
260-
}
261-
TyKind::Path(..) => {
262-
// If the anonymous field contains a Path as type, we can't determine
263-
// if the path is a valid struct or union, so skip the check
264-
}
265-
_ => {
266-
let msg = "unnamed fields can only have struct or union types";
267-
let label = "not a struct or union";
268-
self.err_handler()
269-
.struct_span_err(field.span, msg)
270-
.span_label(ty.span, label)
271-
.emit();
272-
}
273-
}
274-
}
275-
276-
fn deny_anonymous_struct(&self, ty: &Ty) {
277-
match &ty.kind {
278-
TyKind::AnonymousStruct(..) => {
279-
self.err_handler()
280-
.struct_span_err(
281-
ty.span,
282-
"anonymous structs are not allowed outside of unnamed struct or union fields",
283-
)
284-
.span_label(ty.span, "anonymous struct declared here")
285-
.emit();
286-
}
287-
TyKind::AnonymousUnion(..) => {
288-
self.err_handler()
289-
.struct_span_err(
290-
ty.span,
291-
"anonymous unions are not allowed outside of unnamed struct or union fields",
292-
)
293-
.span_label(ty.span, "anonymous union declared here")
294-
.emit();
295-
}
296-
_ => {}
297-
}
298-
}
299-
300-
fn deny_anonymous_field(&self, field: &FieldDef) {
301-
if let Some(ident) = field.ident {
302-
if ident.name == kw::Underscore {
303-
self.err_handler()
304-
.struct_span_err(
305-
field.span,
306-
"anonymous fields are not allowed outside of structs or unions",
307-
)
308-
.span_label(ident.span, "anonymous field declared here")
309-
.emit()
310-
}
311-
}
312-
}
313-
314248
fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) {
315249
for Param { pat, .. } in &decl.inputs {
316250
match pat.kind {
@@ -1067,7 +1001,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10671001

10681002
fn visit_ty(&mut self, ty: &'a Ty) {
10691003
self.visit_ty_common(ty);
1070-
self.deny_anonymous_struct(ty);
10711004
self.walk_ty(ty)
10721005
}
10731006

@@ -1082,7 +1015,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
10821015
}
10831016

10841017
fn visit_field_def(&mut self, s: &'a FieldDef) {
1085-
self.deny_anonymous_field(s);
10861018
visit::walk_field_def(self, s)
10871019
}
10881020

0 commit comments

Comments
 (0)