Skip to content

Commit 384eb26

Browse files
committed
rustc_metadata: Do not forget to encode inherent impls for foreign types
1 parent d92d28e commit 384eb26

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ impl EncodeContext<'a, 'tcx> {
17531753
self.encode_const_stability(def_id);
17541754
self.encode_deprecation(def_id);
17551755
self.encode_item_type(def_id);
1756+
self.encode_inherent_implementations(def_id);
17561757
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
17571758
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
17581759
self.encode_variances_of(def_id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(extern_types)]
2+
3+
extern "C" {
4+
pub type CrossCrate;
5+
}
6+
7+
impl CrossCrate {
8+
pub fn foo(&self) {}
9+
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
// run-pass
2-
#![allow(dead_code)]
31
// Test that inherent impls can be defined for extern types.
42

3+
// check-pass
4+
// aux-build:extern-types-inherent-impl.rs
5+
56
#![feature(extern_types)]
67

7-
extern {
8-
type A;
8+
extern crate extern_types_inherent_impl;
9+
use extern_types_inherent_impl::CrossCrate;
10+
11+
extern "C" {
12+
type Local;
913
}
1014

11-
impl A {
12-
fn foo(&self) { }
15+
impl Local {
16+
fn foo(&self) {}
1317
}
1418

15-
fn use_foo(x: &A) {
19+
fn use_foo(x: &Local, y: &CrossCrate) {
20+
Local::foo(x);
1621
x.foo();
22+
CrossCrate::foo(y);
23+
y.foo();
1724
}
1825

19-
fn main() { }
26+
fn main() {}

0 commit comments

Comments
 (0)