]> git.lizzy.rs Git - rust.git/commitdiff
Also accept Refs for is_primitive_or_pointer
authorjumbatm <30644300+jumbatm@users.noreply.github.com>
Sun, 16 Aug 2020 08:04:14 +0000 (18:04 +1000)
committerjumbatm <30644300+jumbatm@users.noreply.github.com>
Mon, 17 Aug 2020 16:01:05 +0000 (02:01 +1000)
src/librustc_lint/builtin.rs

index 8625dc096d500674e36ecf768bd62b38da069122..2439fc666063455ef6601ccd29ce4ce54db3d70c 100644 (file)
@@ -2184,8 +2184,9 @@ fn structurally_same_type_impl<'tcx>(
                 };
 
                 #[allow(rustc::usage_of_ty_tykind)]
-                let is_primitive_or_pointer =
-                    |kind: &ty::TyKind<'_>| kind.is_primitive() || matches!(kind, RawPtr(..));
+                let is_primitive_or_pointer = |kind: &ty::TyKind<'_>| {
+                    kind.is_primitive() || matches!(kind, RawPtr(..) | Ref(..))
+                };
 
                 match (a_kind, b_kind) {
                     (Adt(a_def, a_substs), Adt(b_def, b_substs)) => {
@@ -2274,8 +2275,8 @@ fn structurally_same_type_impl<'tcx>(
                     // These definitely should have been caught above.
                     (Bool, Bool) | (Char, Char) | (Never, Never) | (Str, Str) => unreachable!(),
 
-                    // An Adt and a primitive type. This can be FFI-safe is the ADT is an enum with a
-                    // non-null field.
+                    // An Adt and a primitive or pointer type. This can be FFI-safe if non-null
+                    // enum layout optimisation is being applied.
                     (Adt(..), other_kind) | (other_kind, Adt(..))
                         if is_primitive_or_pointer(other_kind) =>
                     {