1use rustc_hir::def_id::{DefId, LOCAL_CRATE};
2use rustc_macros::{Decodable, Encodable, HashStable, TyDecodable, TyEncodable};
3
4use crate::ty::{self, GenericArgsRef, Ty, TyCtxt};
5
6#[derive(#[automatically_derived]
impl ::core::cmp::Eq for SymbolExportLevel {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for SymbolExportLevel {
#[inline]
fn eq(&self, other: &SymbolExportLevel) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for SymbolExportLevel {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
SymbolExportLevel::C => "C",
SymbolExportLevel::Rust => "Rust",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for SymbolExportLevel { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SymbolExportLevel {
#[inline]
fn clone(&self) -> SymbolExportLevel { *self }
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for SymbolExportLevel {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
SymbolExportLevel::C => { 0usize }
SymbolExportLevel::Rust => { 1usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
SymbolExportLevel::C => {}
SymbolExportLevel::Rust => {}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for SymbolExportLevel {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { SymbolExportLevel::C }
1usize => { SymbolExportLevel::Rust }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `SymbolExportLevel`, expected 0..2, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_query_system::ich::StableHashingContext<'__ctx>>
for SymbolExportLevel {
#[inline]
fn hash_stable(&self,
__hcx:
&mut ::rustc_query_system::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
SymbolExportLevel::C => {}
SymbolExportLevel::Rust => {}
}
}
}
};HashStable)]
12pub enum SymbolExportLevel {
13 C,
14 Rust,
15}
16
17impl SymbolExportLevel {
18 pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool {
19 threshold == SymbolExportLevel::Rust || self == SymbolExportLevel::C
21 }
22}
23
24#[derive(#[automatically_derived]
impl ::core::cmp::Eq for SymbolExportKind {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for SymbolExportKind {
#[inline]
fn eq(&self, other: &SymbolExportKind) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for SymbolExportKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
SymbolExportKind::Text => "Text",
SymbolExportKind::Data => "Data",
SymbolExportKind::Tls => "Tls",
})
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for SymbolExportKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SymbolExportKind {
#[inline]
fn clone(&self) -> SymbolExportKind { *self }
}Clone, const _: () =
{
impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
for SymbolExportKind {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
SymbolExportKind::Text => { 0usize }
SymbolExportKind::Data => { 1usize }
SymbolExportKind::Tls => { 2usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
SymbolExportKind::Text => {}
SymbolExportKind::Data => {}
SymbolExportKind::Tls => {}
}
}
}
};Encodable, const _: () =
{
impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
for SymbolExportKind {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => { SymbolExportKind::Text }
1usize => { SymbolExportKind::Data }
2usize => { SymbolExportKind::Tls }
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `SymbolExportKind`, expected 0..3, actual {0}",
n));
}
}
}
}
};Decodable, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_query_system::ich::StableHashingContext<'__ctx>>
for SymbolExportKind {
#[inline]
fn hash_stable(&self,
__hcx:
&mut ::rustc_query_system::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
SymbolExportKind::Text => {}
SymbolExportKind::Data => {}
SymbolExportKind::Tls => {}
}
}
}
};HashStable, #[automatically_derived]
impl ::core::hash::Hash for SymbolExportKind {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
let __self_discr = ::core::intrinsics::discriminant_value(self);
::core::hash::Hash::hash(&__self_discr, state)
}
}Hash)]
26pub enum SymbolExportKind {
27 Text,
28 Data,
29 Tls,
30}
31
32#[derive(#[automatically_derived]
impl ::core::cmp::Eq for SymbolExportInfo {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<SymbolExportLevel>;
let _: ::core::cmp::AssertParamIsEq<SymbolExportKind>;
let _: ::core::cmp::AssertParamIsEq<bool>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for SymbolExportInfo {
#[inline]
fn eq(&self, other: &SymbolExportInfo) -> bool {
self.used == other.used &&
self.rustc_std_internal_symbol ==
other.rustc_std_internal_symbol && self.level == other.level
&& self.kind == other.kind
}
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for SymbolExportInfo {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f,
"SymbolExportInfo", "level", &self.level, "kind", &self.kind,
"used", &self.used, "rustc_std_internal_symbol",
&&self.rustc_std_internal_symbol)
}
}Debug, #[automatically_derived]
impl ::core::marker::Copy for SymbolExportInfo { }Copy, #[automatically_derived]
impl ::core::clone::Clone for SymbolExportInfo {
#[inline]
fn clone(&self) -> SymbolExportInfo {
let _: ::core::clone::AssertParamIsClone<SymbolExportLevel>;
let _: ::core::clone::AssertParamIsClone<SymbolExportKind>;
let _: ::core::clone::AssertParamIsClone<bool>;
*self
}
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for SymbolExportInfo {
fn encode(&self, __encoder: &mut __E) {
match *self {
SymbolExportInfo {
level: ref __binding_0,
kind: ref __binding_1,
used: ref __binding_2,
rustc_std_internal_symbol: ref __binding_3 } => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_2,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_3,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for SymbolExportInfo {
fn decode(__decoder: &mut __D) -> Self {
SymbolExportInfo {
level: ::rustc_serialize::Decodable::decode(__decoder),
kind: ::rustc_serialize::Decodable::decode(__decoder),
used: ::rustc_serialize::Decodable::decode(__decoder),
rustc_std_internal_symbol: ::rustc_serialize::Decodable::decode(__decoder),
}
}
}
};TyDecodable, const _: () =
{
impl<'__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_query_system::ich::StableHashingContext<'__ctx>>
for SymbolExportInfo {
#[inline]
fn hash_stable(&self,
__hcx:
&mut ::rustc_query_system::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
SymbolExportInfo {
level: ref __binding_0,
kind: ref __binding_1,
used: ref __binding_2,
rustc_std_internal_symbol: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
38pub struct SymbolExportInfo {
39 pub level: SymbolExportLevel,
40 pub kind: SymbolExportKind,
41 pub used: bool,
43 pub rustc_std_internal_symbol: bool,
46}
47
48#[derive(#[automatically_derived]
impl<'tcx> ::core::cmp::Eq for ExportedSymbol<'tcx> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<DefId>;
let _: ::core::cmp::AssertParamIsEq<GenericArgsRef<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
let _: ::core::cmp::AssertParamIsEq<ty::SymbolName<'tcx>>;
}
}Eq, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for ExportedSymbol<'tcx> {
#[inline]
fn eq(&self, other: &ExportedSymbol<'tcx>) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(ExportedSymbol::NonGeneric(__self_0),
ExportedSymbol::NonGeneric(__arg1_0)) =>
__self_0 == __arg1_0,
(ExportedSymbol::Generic(__self_0, __self_1),
ExportedSymbol::Generic(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(ExportedSymbol::DropGlue(__self_0),
ExportedSymbol::DropGlue(__arg1_0)) => __self_0 == __arg1_0,
(ExportedSymbol::AsyncDropGlueCtorShim(__self_0),
ExportedSymbol::AsyncDropGlueCtorShim(__arg1_0)) =>
__self_0 == __arg1_0,
(ExportedSymbol::AsyncDropGlue(__self_0, __self_1),
ExportedSymbol::AsyncDropGlue(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(ExportedSymbol::ThreadLocalShim(__self_0),
ExportedSymbol::ThreadLocalShim(__arg1_0)) =>
__self_0 == __arg1_0,
(ExportedSymbol::NoDefId(__self_0),
ExportedSymbol::NoDefId(__arg1_0)) => __self_0 == __arg1_0,
_ => unsafe { ::core::intrinsics::unreachable() }
}
}
}PartialEq, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ExportedSymbol<'tcx> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
ExportedSymbol::NonGeneric(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"NonGeneric", &__self_0),
ExportedSymbol::Generic(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"Generic", __self_0, &__self_1),
ExportedSymbol::DropGlue(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"DropGlue", &__self_0),
ExportedSymbol::AsyncDropGlueCtorShim(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"AsyncDropGlueCtorShim", &__self_0),
ExportedSymbol::AsyncDropGlue(__self_0, __self_1) =>
::core::fmt::Formatter::debug_tuple_field2_finish(f,
"AsyncDropGlue", __self_0, &__self_1),
ExportedSymbol::ThreadLocalShim(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"ThreadLocalShim", &__self_0),
ExportedSymbol::NoDefId(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"NoDefId", &__self_0),
}
}
}Debug, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for ExportedSymbol<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for ExportedSymbol<'tcx> {
#[inline]
fn clone(&self) -> ExportedSymbol<'tcx> {
let _: ::core::clone::AssertParamIsClone<DefId>;
let _: ::core::clone::AssertParamIsClone<GenericArgsRef<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
let _: ::core::clone::AssertParamIsClone<ty::SymbolName<'tcx>>;
*self
}
}Clone, const _: () =
{
impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
::rustc_serialize::Encodable<__E> for ExportedSymbol<'tcx> {
fn encode(&self, __encoder: &mut __E) {
let disc =
match *self {
ExportedSymbol::NonGeneric(ref __binding_0) => { 0usize }
ExportedSymbol::Generic(ref __binding_0, ref __binding_1) =>
{
1usize
}
ExportedSymbol::DropGlue(ref __binding_0) => { 2usize }
ExportedSymbol::AsyncDropGlueCtorShim(ref __binding_0) => {
3usize
}
ExportedSymbol::AsyncDropGlue(ref __binding_0,
ref __binding_1) => {
4usize
}
ExportedSymbol::ThreadLocalShim(ref __binding_0) => {
5usize
}
ExportedSymbol::NoDefId(ref __binding_0) => { 6usize }
};
::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
match *self {
ExportedSymbol::NonGeneric(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ExportedSymbol::Generic(ref __binding_0, ref __binding_1) =>
{
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
ExportedSymbol::DropGlue(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ExportedSymbol::AsyncDropGlueCtorShim(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ExportedSymbol::AsyncDropGlue(ref __binding_0,
ref __binding_1) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
::rustc_serialize::Encodable::<__E>::encode(__binding_1,
__encoder);
}
ExportedSymbol::ThreadLocalShim(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
ExportedSymbol::NoDefId(ref __binding_0) => {
::rustc_serialize::Encodable::<__E>::encode(__binding_0,
__encoder);
}
}
}
}
};TyEncodable, const _: () =
{
impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
::rustc_serialize::Decodable<__D> for ExportedSymbol<'tcx> {
fn decode(__decoder: &mut __D) -> Self {
match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
{
0usize => {
ExportedSymbol::NonGeneric(::rustc_serialize::Decodable::decode(__decoder))
}
1usize => {
ExportedSymbol::Generic(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
2usize => {
ExportedSymbol::DropGlue(::rustc_serialize::Decodable::decode(__decoder))
}
3usize => {
ExportedSymbol::AsyncDropGlueCtorShim(::rustc_serialize::Decodable::decode(__decoder))
}
4usize => {
ExportedSymbol::AsyncDropGlue(::rustc_serialize::Decodable::decode(__decoder),
::rustc_serialize::Decodable::decode(__decoder))
}
5usize => {
ExportedSymbol::ThreadLocalShim(::rustc_serialize::Decodable::decode(__decoder))
}
6usize => {
ExportedSymbol::NoDefId(::rustc_serialize::Decodable::decode(__decoder))
}
n => {
::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ExportedSymbol`, expected 0..7, actual {0}",
n));
}
}
}
}
};TyDecodable, const _: () =
{
impl<'tcx, '__ctx>
::rustc_data_structures::stable_hasher::HashStable<::rustc_query_system::ich::StableHashingContext<'__ctx>>
for ExportedSymbol<'tcx> {
#[inline]
fn hash_stable(&self,
__hcx:
&mut ::rustc_query_system::ich::StableHashingContext<'__ctx>,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
match *self {
ExportedSymbol::NonGeneric(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExportedSymbol::Generic(ref __binding_0, ref __binding_1) =>
{
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExportedSymbol::DropGlue(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExportedSymbol::AsyncDropGlueCtorShim(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExportedSymbol::AsyncDropGlue(ref __binding_0,
ref __binding_1) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
}
ExportedSymbol::ThreadLocalShim(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
ExportedSymbol::NoDefId(ref __binding_0) => {
{ __binding_0.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable)]
49pub enum ExportedSymbol<'tcx> {
50 NonGeneric(DefId),
51 Generic(DefId, GenericArgsRef<'tcx>),
52 DropGlue(Ty<'tcx>),
53 AsyncDropGlueCtorShim(Ty<'tcx>),
54 AsyncDropGlue(DefId, Ty<'tcx>),
55 ThreadLocalShim(DefId),
56 NoDefId(ty::SymbolName<'tcx>),
57}
58
59impl<'tcx> ExportedSymbol<'tcx> {
60 pub fn symbol_name_for_local_instance(&self, tcx: TyCtxt<'tcx>) -> ty::SymbolName<'tcx> {
63 match *self {
64 ExportedSymbol::NonGeneric(def_id) => tcx.symbol_name(ty::Instance::mono(tcx, def_id)),
65 ExportedSymbol::Generic(def_id, args) => {
66 tcx.symbol_name(ty::Instance::new_raw(def_id, args))
67 }
68 ExportedSymbol::DropGlue(ty) => {
69 tcx.symbol_name(ty::Instance::resolve_drop_in_place(tcx, ty))
70 }
71 ExportedSymbol::AsyncDropGlueCtorShim(ty) => {
72 tcx.symbol_name(ty::Instance::resolve_async_drop_in_place(tcx, ty))
73 }
74 ExportedSymbol::AsyncDropGlue(def_id, ty) => {
75 tcx.symbol_name(ty::Instance::resolve_async_drop_in_place_poll(tcx, def_id, ty))
76 }
77 ExportedSymbol::ThreadLocalShim(def_id) => tcx.symbol_name(ty::Instance {
78 def: ty::InstanceKind::ThreadLocalShim(def_id),
79 args: ty::GenericArgs::empty(),
80 }),
81 ExportedSymbol::NoDefId(symbol_name) => symbol_name,
82 }
83 }
84}
85
86pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String {
87 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("rust_metadata_{0}_{1:08x}",
tcx.crate_name(LOCAL_CRATE),
tcx.stable_crate_id(LOCAL_CRATE)))
})format!(
88 "rust_metadata_{}_{:08x}",
89 tcx.crate_name(LOCAL_CRATE),
90 tcx.stable_crate_id(LOCAL_CRATE),
91 )
92}