rustc_metadata: Do not forget to encode inherent impls for foreign types

This commit is contained in:
Vadim Petrochenkov 2020-09-30 22:49:59 +03:00
parent d92d28e523
commit 384eb2691f
3 changed files with 25 additions and 8 deletions

View file

@ -1753,6 +1753,7 @@ fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignIt
self.encode_const_stability(def_id);
self.encode_deprecation(def_id);
self.encode_item_type(def_id);
self.encode_inherent_implementations(def_id);
if let hir::ForeignItemKind::Fn(..) = nitem.kind {
record!(self.tables.fn_sig[def_id] <- tcx.fn_sig(def_id));
self.encode_variances_of(def_id);

View file

@ -0,0 +1,9 @@
#![feature(extern_types)]
extern "C" {
pub type CrossCrate;
}
impl CrossCrate {
pub fn foo(&self) {}
}

View file

@ -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() {}