about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjumbatm <30644300+jumbatm@users.noreply.github.com>2020-08-16 18:04:14 +1000
committerjumbatm <30644300+jumbatm@users.noreply.github.com>2020-08-18 02:01:05 +1000
commit1321a2dce32893588a0ec4ba586c3a04fb5e47cf (patch)
treea15e68b48115e840a7ff0b00115baeed2215830b
parent7708abbbef679d208041bff57aa9ad50e9419895 (diff)
Also accept Refs for is_primitive_or_pointer
-rw-r--r--src/librustc_lint/builtin.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index 8625dc096d5..2439fc66606 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -2184,8 +2184,9 @@ impl ClashingExternDeclarations {
                 };
 
                 #[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 @@ impl ClashingExternDeclarations {
                     // 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) =>
                     {