-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor TyStruct
/TyEnum
/TyUnion
into TyAdt
#36331
Conversation
The diff looks much better with whitespaces ignored https://github.com/rust-lang/rust/pull/36331/files?w=1 |
@@ -555,7 +555,7 @@ impl<'a, 'gcx, 'tcx> Struct { | |||
} | |||
|
|||
// Is this the NonZero lang item wrapping a pointer or integer type? | |||
(&Univariant { non_zero: true, .. }, &ty::TyStruct(def, substs)) => { | |||
(&Univariant { non_zero: true, .. }, &ty::TyAdt(def, substs)) if def.is_struct() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The guard is unnecessary (because non_zero
means it's the NonZero
lang item).
LGTM modulo somewhat minor |
@@ -133,23 +128,27 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { | |||
|
|||
fn handle_field_access(&mut self, lhs: &hir::Expr, name: ast::Name) { | |||
match self.tcx.expr_ty_adjusted(lhs).sty { | |||
ty::TyStruct(def, _) | ty::TyUnion(def, _) => { | |||
ty::TyAdt(def, _) => { | |||
self.insert_def_id(def.struct_variant().field_named(name).did); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here if sty
here was a TyEnum
previously?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct_variant()
reports another span_bug!
Updated, comments addressed. |
@bors r+ |
📌 Commit 553d5f0 has been approved by |
Refactor `TyStruct`/`TyEnum`/`TyUnion` into `TyAdt` r? @eddyb
r? @eddyb