From 384eb2691f53bb0cdeb17a5ccf73c83e861d9aa1 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 30 Sep 2020 22:49:59 +0300 Subject: rustc_metadata: Do not forget to encode inherent impls for foreign types --- .../extern/auxiliary/extern-types-inherent-impl.rs | 9 +++++++++ src/test/ui/extern/extern-types-inherent-impl.rs | 23 ++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs (limited to 'src') diff --git a/src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs b/src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs new file mode 100644 index 00000000000..a1efe181843 --- /dev/null +++ b/src/test/ui/extern/auxiliary/extern-types-inherent-impl.rs @@ -0,0 +1,9 @@ +#![feature(extern_types)] + +extern "C" { + pub type CrossCrate; +} + +impl CrossCrate { + pub fn foo(&self) {} +} diff --git a/src/test/ui/extern/extern-types-inherent-impl.rs b/src/test/ui/extern/extern-types-inherent-impl.rs index fc98f55dc07..3f09ac7b8c3 100644 --- a/src/test/ui/extern/extern-types-inherent-impl.rs +++ b/src/test/ui/extern/extern-types-inherent-impl.rs @@ -1,19 +1,26 @@ -// run-pass -#![allow(dead_code)] // Test that inherent impls can be defined for extern types. +// check-pass +// aux-build:extern-types-inherent-impl.rs + #![feature(extern_types)] -extern { - type A; +extern crate extern_types_inherent_impl; +use extern_types_inherent_impl::CrossCrate; + +extern "C" { + type Local; } -impl A { - fn foo(&self) { } +impl Local { + fn foo(&self) {} } -fn use_foo(x: &A) { +fn use_foo(x: &Local, y: &CrossCrate) { + Local::foo(x); x.foo(); + CrossCrate::foo(y); + y.foo(); } -fn main() { } +fn main() {} -- cgit 1.4.1-3-g733a5