diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 34a3f155baf43..f7faefa240abe 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -153,6 +153,8 @@ fn visit_implementation_of_unpin(checker: &Checker<'_>) -> Result<(), ErrorGuara })); } ty::Adt(_, _) => {} + // `extern type`s have no fields, so they can't be structurally pinned. + ty::Foreign(_) => {} _ => { return Err(tcx.dcx().span_delayed_bug(span, "impl of `Unpin` for a non-adt type")); } diff --git a/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs b/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs index d16110cfd66f9..8dede888055f7 100644 --- a/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs +++ b/compiler/rustc_target/src/spec/targets/aarch64_unknown_fuchsia.rs @@ -5,7 +5,7 @@ use crate::spec::{ pub(crate) fn target() -> Target { let mut base = base::fuchsia::opts(); base.cpu = "generic".into(); - base.features = "+v8a,+crc,+aes,+sha2,+neon".into(); + base.features = "+v8a,+crc,+aes,+sha2,+neon,+fix-cortex-a53-835769".into(); base.max_atomic_width = Some(128); base.stack_probes = StackProbeType::Inline; base.supported_sanitizers = SanitizerSet::ADDRESS diff --git a/tests/codegen-llvm/aarch64-fuchsia-target-features.rs b/tests/codegen-llvm/aarch64-fuchsia-target-features.rs new file mode 100644 index 0000000000000..32cdc2ce8a553 --- /dev/null +++ b/tests/codegen-llvm/aarch64-fuchsia-target-features.rs @@ -0,0 +1,14 @@ +//@ add-minicore +//@ compile-flags: --crate-type=rlib --target=aarch64-unknown-fuchsia +//@ needs-llvm-components: aarch64 + +// CHECK: attributes #0 = { {{.*}}"target-features"="{{.*}}+fix-cortex-a53-835769{{.*}}" } + +#![feature(no_core, lang_items)] +#![no_core] + +extern crate minicore; +use minicore::*; + +#[no_mangle] +pub fn test() {} diff --git a/tests/crashes/155053.rs b/tests/crashes/155053.rs deleted file mode 100644 index 31b9ccaf20540..0000000000000 --- a/tests/crashes/155053.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #155053 -#![feature(pin_ergonomics)] -#![feature(extern_types)] - -unsafe extern "C" { - type ExternType; -} - -impl Unpin for ExternType {} - -fn main() {} diff --git a/tests/ui/pin-ergonomics/impl-unpin-extern-type.rs b/tests/ui/pin-ergonomics/impl-unpin-extern-type.rs new file mode 100644 index 0000000000000..953c71ea84311 --- /dev/null +++ b/tests/ui/pin-ergonomics/impl-unpin-extern-type.rs @@ -0,0 +1,18 @@ +//! Verify that a local `extern type` can manually implement `Unpin` with `pin_ergonomics` enabled. +//! Unlike a `#[pin_v2]` ADT, an extern type has no fields that could be structually pinned. +//! +//! Regression test for . + +//@ check-pass + +#![feature(pin_ergonomics)] +#![feature(extern_types)] +#![allow(incomplete_features)] + +unsafe extern "C" { + type ExternType; +} + +impl Unpin for ExternType {} + +fn main() {}