summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_symbol_mangling
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /compiler/rustc_symbol_mangling
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_symbol_mangling')
-rw-r--r--compiler/rustc_symbol_mangling/src/legacy.rs20
-rw-r--r--compiler/rustc_symbol_mangling/src/lib.rs16
-rw-r--r--compiler/rustc_symbol_mangling/src/test.rs4
-rw-r--r--compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs163
-rw-r--r--compiler/rustc_symbol_mangling/src/v0.rs51
5 files changed, 129 insertions, 125 deletions
diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs
index ec7032cd3..3a3356808 100644
--- a/compiler/rustc_symbol_mangling/src/legacy.rs
+++ b/compiler/rustc_symbol_mangling/src/legacy.rs
@@ -2,8 +2,8 @@ use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
use rustc_hir::def_id::CrateNum;
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
use rustc_middle::ty::print::{PrettyPrinter, Print, Printer};
-use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeVisitableExt};
+use rustc_middle::ty::{GenericArg, GenericArgKind};
use rustc_middle::util::common::record_time;
use std::fmt::{self, Write};
@@ -26,7 +26,7 @@ pub(super) fn mangle<'tcx>(
let key = tcx.def_key(ty_def_id);
match key.disambiguated_data.data {
DefPathData::TypeNs(_) | DefPathData::ValueNs(_) => {
- instance_ty = tcx.type_of(ty_def_id).subst_identity();
+ instance_ty = tcx.type_of(ty_def_id).instantiate_identity();
debug!(?instance_ty);
break;
}
@@ -58,7 +58,7 @@ pub(super) fn mangle<'tcx>(
def_id,
if let ty::InstanceDef::DropGlue(_, _) = instance.def {
// Add the name of the dropped type to the symbol name
- &*instance.substs
+ &*instance.args
} else {
&[]
},
@@ -95,8 +95,8 @@ fn get_symbol_hash<'tcx>(
instantiating_crate: Option<CrateNum>,
) -> Hash64 {
let def_id = instance.def_id();
- let substs = instance.substs;
- debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
+ let args = instance.args;
+ debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, args);
tcx.with_stable_hashing_context(|mut hcx| {
let mut hasher = StableHasher::new();
@@ -122,7 +122,7 @@ fn get_symbol_hash<'tcx>(
}
// also include any type parameters (for generic items)
- substs.hash_stable(hcx, &mut hasher);
+ args.hash_stable(hcx, &mut hasher);
if let Some(instantiating_crate) = instantiating_crate {
tcx.def_path_hash(instantiating_crate.as_def_id())
@@ -219,10 +219,10 @@ impl<'tcx> Printer<'tcx> for &mut SymbolPrinter<'tcx> {
fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
match *ty.kind() {
// Print all nominal types as paths (unlike `pretty_print_type`).
- ty::FnDef(def_id, substs)
- | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, substs, .. })
- | ty::Closure(def_id, substs)
- | ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
+ ty::FnDef(def_id, args)
+ | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. })
+ | ty::Closure(def_id, args)
+ | ty::Generator(def_id, args, _) => self.print_def_path(def_id, args),
// The `pretty_print_type` formatting of array size depends on
// -Zverbose flag, so we cannot reuse it here.
diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs
index 692542da7..74538e9f5 100644
--- a/compiler/rustc_symbol_mangling/src/lib.rs
+++ b/compiler/rustc_symbol_mangling/src/lib.rs
@@ -108,7 +108,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
use rustc_middle::query::Providers;
-use rustc_middle::ty::subst::SubstsRef;
+use rustc_middle::ty::GenericArgsRef;
use rustc_middle::ty::{self, Instance, TyCtxt};
use rustc_session::config::SymbolManglingVersion;
@@ -144,7 +144,7 @@ fn symbol_name_provider<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> ty
// This closure determines the instantiating crate for instances that
// need an instantiating-crate-suffix for their symbol name, in order
// to differentiate between local copies.
- if is_generic(instance.substs) {
+ if is_generic(instance.args) {
// For generics we might find re-usable upstream instances. If there
// is one, we rely on the symbol being instantiated locally.
instance.upstream_monomorphization(tcx).unwrap_or(LOCAL_CRATE)
@@ -174,13 +174,13 @@ fn compute_symbol_name<'tcx>(
compute_instantiating_crate: impl FnOnce() -> CrateNum,
) -> String {
let def_id = instance.def_id();
- let substs = instance.substs;
+ let args = instance.args;
- debug!("symbol_name(def_id={:?}, substs={:?})", def_id, substs);
+ debug!("symbol_name(def_id={:?}, args={:?})", def_id, args);
if let Some(def_id) = def_id.as_local() {
if tcx.proc_macro_decls_static(()) == Some(def_id) {
- let stable_crate_id = tcx.sess.local_stable_crate_id();
+ let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE);
return tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id);
}
}
@@ -246,7 +246,7 @@ fn compute_symbol_name<'tcx>(
// the ID of the instantiating crate. This avoids symbol conflicts
// in case the same instances is emitted in two crates of the same
// project.
- let avoid_cross_crate_conflicts = is_generic(substs) || is_globally_shared_function;
+ let avoid_cross_crate_conflicts = is_generic(args) || is_globally_shared_function;
let instantiating_crate = avoid_cross_crate_conflicts.then(compute_instantiating_crate);
@@ -278,6 +278,6 @@ fn compute_symbol_name<'tcx>(
symbol
}
-fn is_generic(substs: SubstsRef<'_>) -> bool {
- substs.non_erasable_generics().next().is_some()
+fn is_generic(args: GenericArgsRef<'_>) -> bool {
+ args.non_erasable_generics().next().is_some()
}
diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs
index 985b22107..eddfd0df3 100644
--- a/compiler/rustc_symbol_mangling/src/test.rs
+++ b/compiler/rustc_symbol_mangling/src/test.rs
@@ -7,7 +7,7 @@
use crate::errors::{Kind, TestOutput};
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::print::with_no_trimmed_paths;
-use rustc_middle::ty::{subst::InternalSubsts, Instance, TyCtxt};
+use rustc_middle::ty::{GenericArgs, Instance, TyCtxt};
use rustc_span::symbol::{sym, Symbol};
const SYMBOL_NAME: Symbol = sym::rustc_symbol_name;
@@ -57,7 +57,7 @@ impl SymbolNamesTest<'_> {
let def_id = def_id.to_def_id();
let instance = Instance::new(
def_id,
- tcx.erase_regions(InternalSubsts::identity_for_item(tcx, def_id)),
+ tcx.erase_regions(GenericArgs::identity_for_item(tcx, def_id)),
);
let mangled = tcx.symbol_name(instance);
tcx.sess.emit_err(TestOutput {
diff --git a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
index 3b46275ec..d345368d5 100644
--- a/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
+++ b/compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
@@ -7,18 +7,19 @@
///
/// For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler,
/// see design document in the tracking issue #89653.
-use core::fmt::Display;
use rustc_data_structures::base_n;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
-use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
+use rustc_middle::ty::layout::IntegerExt;
use rustc_middle::ty::{
self, Const, ExistentialPredicate, FloatTy, FnSig, Instance, IntTy, List, Region, RegionKind,
TermKind, Ty, TyCtxt, UintTy,
};
+use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgsRef};
use rustc_span::def_id::DefId;
use rustc_span::sym;
use rustc_target::abi::call::{Conv, FnAbi};
+use rustc_target::abi::Integer;
use rustc_target::spec::abi::Abi;
use std::fmt::Write as _;
@@ -93,44 +94,54 @@ fn encode_const<'tcx>(
dict: &mut FxHashMap<DictKey<'tcx>, usize>,
options: EncodeTyOptions,
) -> String {
- // L<element-type>[n]<element-value>E as literal argument
+ // L<element-type>[n][<element-value>]E as literal argument
let mut s = String::from('L');
- // Element type
- s.push_str(&encode_ty(tcx, c.ty(), dict, options));
+ match c.kind() {
+ // Const parameters
+ ty::ConstKind::Param(..) => {
+ // L<element-type>E as literal argument
- // The only allowed types of const parameters are bool, u8, u16, u32, u64, u128, usize i8, i16,
- // i32, i64, i128, isize, and char. The bool value false is encoded as 0 and true as 1.
- fn push_signed_value<T: Display + PartialOrd>(s: &mut String, value: T, zero: T) {
- if value < zero {
- s.push('n')
- };
- let _ = write!(s, "{value}");
- }
-
- fn push_unsigned_value<T: Display>(s: &mut String, value: T) {
- let _ = write!(s, "{value}");
- }
+ // Element type
+ s.push_str(&encode_ty(tcx, c.ty(), dict, options));
+ }
- if let Some(scalar_int) = c.try_to_scalar_int() {
- let signed = c.ty().is_signed();
- match scalar_int.size().bits() {
- 8 if signed => push_signed_value(&mut s, scalar_int.try_to_i8().unwrap(), 0),
- 16 if signed => push_signed_value(&mut s, scalar_int.try_to_i16().unwrap(), 0),
- 32 if signed => push_signed_value(&mut s, scalar_int.try_to_i32().unwrap(), 0),
- 64 if signed => push_signed_value(&mut s, scalar_int.try_to_i64().unwrap(), 0),
- 128 if signed => push_signed_value(&mut s, scalar_int.try_to_i128().unwrap(), 0),
- 8 => push_unsigned_value(&mut s, scalar_int.try_to_u8().unwrap()),
- 16 => push_unsigned_value(&mut s, scalar_int.try_to_u16().unwrap()),
- 32 => push_unsigned_value(&mut s, scalar_int.try_to_u32().unwrap()),
- 64 => push_unsigned_value(&mut s, scalar_int.try_to_u64().unwrap()),
- 128 => push_unsigned_value(&mut s, scalar_int.try_to_u128().unwrap()),
- _ => {
- bug!("encode_const: unexpected size `{:?}`", scalar_int.size().bits());
+ // Literal arguments
+ ty::ConstKind::Value(..) => {
+ // L<element-type>[n]<element-value>E as literal argument
+
+ // Element type
+ s.push_str(&encode_ty(tcx, c.ty(), dict, options));
+
+ // The only allowed types of const values are bool, u8, u16, u32,
+ // u64, u128, usize i8, i16, i32, i64, i128, isize, and char. The
+ // bool value false is encoded as 0 and true as 1.
+ match c.ty().kind() {
+ ty::Int(ity) => {
+ let bits = c.eval_bits(tcx, ty::ParamEnv::reveal_all(), c.ty());
+ let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
+ if val < 0 {
+ s.push('n');
+ }
+ let _ = write!(s, "{val}");
+ }
+ ty::Uint(_) => {
+ let val = c.eval_bits(tcx, ty::ParamEnv::reveal_all(), c.ty());
+ let _ = write!(s, "{val}");
+ }
+ ty::Bool => {
+ let val = c.try_eval_bool(tcx, ty::ParamEnv::reveal_all()).unwrap();
+ let _ = write!(s, "{val}");
+ }
+ _ => {
+ bug!("encode_const: unexpected type `{:?}`", c.ty());
+ }
}
- };
- } else {
- bug!("encode_const: unexpected type `{:?}`", c.ty());
+ }
+
+ _ => {
+ bug!("encode_const: unexpected kind `{:?}`", c.kind());
+ }
}
// Close the "L..E" pair
@@ -212,12 +223,12 @@ fn encode_predicate<'tcx>(
ty::ExistentialPredicate::Trait(trait_ref) => {
let name = encode_ty_name(tcx, trait_ref.def_id);
let _ = write!(s, "u{}{}", name.len(), &name);
- s.push_str(&encode_substs(tcx, trait_ref.substs, dict, options));
+ s.push_str(&encode_args(tcx, trait_ref.args, dict, options));
}
ty::ExistentialPredicate::Projection(projection) => {
let name = encode_ty_name(tcx, projection.def_id);
let _ = write!(s, "u{}{}", name.len(), &name);
- s.push_str(&encode_substs(tcx, projection.substs, dict, options));
+ s.push_str(&encode_args(tcx, projection.args, dict, options));
match projection.term.unpack() {
TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)),
TermKind::Const(c) => s.push_str(&encode_const(tcx, c, dict, options)),
@@ -286,21 +297,21 @@ fn encode_region<'tcx>(
s
}
-/// Encodes substs using the Itanium C++ ABI with vendor extended type qualifiers and types for Rust
+/// Encodes args using the Itanium C++ ABI with vendor extended type qualifiers and types for Rust
/// types that are not used at the FFI boundary.
-fn encode_substs<'tcx>(
+fn encode_args<'tcx>(
tcx: TyCtxt<'tcx>,
- substs: SubstsRef<'tcx>,
+ args: GenericArgsRef<'tcx>,
dict: &mut FxHashMap<DictKey<'tcx>, usize>,
options: EncodeTyOptions,
) -> String {
// [I<subst1..substN>E] as part of vendor extended type
let mut s = String::new();
- let substs: Vec<GenericArg<'_>> = substs.iter().collect();
- if !substs.is_empty() {
+ let args: Vec<GenericArg<'_>> = args.iter().collect();
+ if !args.is_empty() {
s.push('I');
- for subst in substs {
- match subst.unpack() {
+ for arg in args {
+ match arg.unpack() {
GenericArgKind::Lifetime(region) => {
s.push_str(&encode_region(tcx, region, dict, options));
}
@@ -400,7 +411,7 @@ fn encode_ty_name(tcx: TyCtxt<'_>, def_id: DefId) -> String {
let _ = write!(s, "{}", name.len());
// Prepend a '_' if name starts with a digit or '_'
- if let Some(first) = name.as_bytes().get(0) {
+ if let Some(first) = name.as_bytes().first() {
if first.is_ascii_digit() || *first == b'_' {
s.push('_');
}
@@ -524,7 +535,7 @@ fn encode_ty<'tcx>(
}
// User-defined types
- ty::Adt(adt_def, substs) => {
+ ty::Adt(adt_def, args) => {
let mut s = String::new();
let def_id = adt_def.did();
if let Some(cfi_encoding) = tcx.get_attr(def_id, sym::cfi_encoding) {
@@ -570,7 +581,7 @@ fn encode_ty<'tcx>(
// <subst>, as vendor extended type.
let name = encode_ty_name(tcx, def_id);
let _ = write!(s, "u{}{}", name.len(), &name);
- s.push_str(&encode_substs(tcx, substs, dict, options));
+ s.push_str(&encode_args(tcx, args, dict, options));
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
}
typeid.push_str(&s);
@@ -608,27 +619,27 @@ fn encode_ty<'tcx>(
}
// Function types
- ty::FnDef(def_id, substs) | ty::Closure(def_id, substs) => {
+ ty::FnDef(def_id, args) | ty::Closure(def_id, args) => {
// u<length><name>[I<element-type1..element-typeN>E], where <element-type> is <subst>,
// as vendor extended type.
let mut s = String::new();
let name = encode_ty_name(tcx, *def_id);
let _ = write!(s, "u{}{}", name.len(), &name);
- s.push_str(&encode_substs(tcx, substs, dict, options));
+ s.push_str(&encode_args(tcx, args, dict, options));
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
typeid.push_str(&s);
}
- ty::Generator(def_id, substs, ..) => {
+ ty::Generator(def_id, args, ..) => {
// u<length><name>[I<element-type1..element-typeN>E], where <element-type> is <subst>,
// as vendor extended type.
let mut s = String::new();
let name = encode_ty_name(tcx, *def_id);
let _ = write!(s, "u{}{}", name.len(), &name);
- // Encode parent substs only
- s.push_str(&encode_substs(
+ // Encode parent args only
+ s.push_str(&encode_args(
tcx,
- tcx.mk_substs(substs.as_generator().parent_substs()),
+ tcx.mk_args(args.as_generator().parent_args()),
dict,
options,
));
@@ -732,18 +743,18 @@ fn transform_predicates<'tcx>(
tcx.mk_poly_existential_predicates(&predicates)
}
-/// Transforms substs for being encoded and used in the substitution dictionary.
-fn transform_substs<'tcx>(
+/// Transforms args for being encoded and used in the substitution dictionary.
+fn transform_args<'tcx>(
tcx: TyCtxt<'tcx>,
- substs: SubstsRef<'tcx>,
+ args: GenericArgsRef<'tcx>,
options: TransformTyOptions,
-) -> SubstsRef<'tcx> {
- let substs = substs.iter().map(|subst| match subst.unpack() {
+) -> GenericArgsRef<'tcx> {
+ let args = args.iter().map(|arg| match arg.unpack() {
GenericArgKind::Type(ty) if ty.is_c_void(tcx) => Ty::new_unit(tcx).into(),
GenericArgKind::Type(ty) => transform_ty(tcx, ty, options).into(),
- _ => subst,
+ _ => arg,
});
- tcx.mk_substs_from_iter(substs)
+ tcx.mk_args_from_iter(args)
}
// Transforms a ty:Ty for being encoded and used in the substitution dictionary. It transforms all
@@ -813,11 +824,8 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
}
ty::Array(ty0, len) => {
- let len = len
- .try_to_scalar()
- .unwrap()
- .to_u64()
- .unwrap_or_else(|_| panic!("failed to convert length to u64"));
+ let len = len.eval_target_usize(tcx, ty::ParamEnv::reveal_all());
+
ty = Ty::new_array(tcx, transform_ty(tcx, *ty0, options), len);
}
@@ -825,7 +833,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
ty = Ty::new_slice(tcx, transform_ty(tcx, *ty0, options));
}
- ty::Adt(adt_def, substs) => {
+ ty::Adt(adt_def, args) => {
if ty.is_c_void(tcx) {
ty = Ty::new_unit(tcx);
} else if options.contains(TransformTyOptions::GENERALIZE_REPR_C) && adt_def.repr().c()
@@ -840,13 +848,13 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
let variant = adt_def.non_enum_variant();
let param_env = tcx.param_env(variant.def_id);
let field = variant.fields.iter().find(|field| {
- let ty = tcx.type_of(field.did).subst_identity();
+ let ty = tcx.type_of(field.did).instantiate_identity();
let is_zst =
tcx.layout_of(param_env.and(ty)).is_ok_and(|layout| layout.is_zst());
!is_zst
});
if let Some(field) = field {
- let ty0 = tcx.type_of(field.did).subst(tcx, substs);
+ let ty0 = tcx.type_of(field.did).instantiate(tcx, args);
// Generalize any repr(transparent) user-defined type that is either a pointer
// or reference, and either references itself or any other type that contains or
// references itself, to avoid a reference cycle.
@@ -864,25 +872,20 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
ty = Ty::new_unit(tcx);
}
} else {
- ty = Ty::new_adt(tcx, *adt_def, transform_substs(tcx, substs, options));
+ ty = Ty::new_adt(tcx, *adt_def, transform_args(tcx, args, options));
}
}
- ty::FnDef(def_id, substs) => {
- ty = Ty::new_fn_def(tcx, *def_id, transform_substs(tcx, substs, options));
+ ty::FnDef(def_id, args) => {
+ ty = Ty::new_fn_def(tcx, *def_id, transform_args(tcx, args, options));
}
- ty::Closure(def_id, substs) => {
- ty = Ty::new_closure(tcx, *def_id, transform_substs(tcx, substs, options));
+ ty::Closure(def_id, args) => {
+ ty = Ty::new_closure(tcx, *def_id, transform_args(tcx, args, options));
}
- ty::Generator(def_id, substs, movability) => {
- ty = Ty::new_generator(
- tcx,
- *def_id,
- transform_substs(tcx, substs, options),
- *movability,
- );
+ ty::Generator(def_id, args, movability) => {
+ ty = Ty::new_generator(tcx, *def_id, transform_args(tcx, args, options), *movability);
}
ty::Ref(region, ty0, ..) => {
diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs
index 5e5cc6e4e..da19a3ba4 100644
--- a/compiler/rustc_symbol_mangling/src/v0.rs
+++ b/compiler/rustc_symbol_mangling/src/v0.rs
@@ -27,7 +27,7 @@ pub(super) fn mangle<'tcx>(
) -> String {
let def_id = instance.def_id();
// FIXME(eddyb) this should ideally not be needed.
- let substs = tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), instance.substs);
+ let args = tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), instance.args);
let prefix = "_R";
let mut cx = &mut SymbolMangler {
@@ -50,9 +50,9 @@ pub(super) fn mangle<'tcx>(
};
cx = if let Some(shim_kind) = shim_kind {
- cx.path_append_ns(|cx| cx.print_def_path(def_id, substs), 'S', 0, shim_kind).unwrap()
+ cx.path_append_ns(|cx| cx.print_def_path(def_id, args), 'S', 0, shim_kind).unwrap()
} else {
- cx.print_def_path(def_id, substs).unwrap()
+ cx.print_def_path(def_id, args).unwrap()
};
if let Some(instantiating_crate) = instantiating_crate {
cx = cx.print_def_path(instantiating_crate.as_def_id(), &[]).unwrap();
@@ -245,19 +245,19 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
fn print_def_path(
mut self,
def_id: DefId,
- substs: &'tcx [GenericArg<'tcx>],
+ args: &'tcx [GenericArg<'tcx>],
) -> Result<Self::Path, Self::Error> {
- if let Some(&i) = self.paths.get(&(def_id, substs)) {
+ if let Some(&i) = self.paths.get(&(def_id, args)) {
return self.print_backref(i);
}
let start = self.out.len();
- self = self.default_print_def_path(def_id, substs)?;
+ self = self.default_print_def_path(def_id, args)?;
// Only cache paths that do not refer to an enclosing
// binder (which would change depending on context).
- if !substs.iter().any(|k| k.has_escaping_bound_vars()) {
- self.paths.insert((def_id, substs), start);
+ if !args.iter().any(|k| k.has_escaping_bound_vars()) {
+ self.paths.insert((def_id, args), start);
}
Ok(self)
}
@@ -265,7 +265,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
fn print_impl_path(
mut self,
impl_def_id: DefId,
- substs: &'tcx [GenericArg<'tcx>],
+ args: &'tcx [GenericArg<'tcx>],
mut self_ty: Ty<'tcx>,
mut impl_trait_ref: Option<ty::TraitRef<'tcx>>,
) -> Result<Self::Path, Self::Error> {
@@ -273,8 +273,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
let parent_def_id = DefId { index: key.parent.unwrap(), ..impl_def_id };
let mut param_env = self.tcx.param_env_reveal_all_normalized(impl_def_id);
- if !substs.is_empty() {
- param_env = EarlyBinder::bind(param_env).subst(self.tcx, substs);
+ if !args.is_empty() {
+ param_env = EarlyBinder::bind(param_env).instantiate(self.tcx, args);
}
match &mut impl_trait_ref {
@@ -295,7 +295,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
// Encode impl generic params if the substitutions contain parameters (implying
// polymorphization is enabled) and this isn't an inherent impl.
- if impl_trait_ref.is_some() && substs.iter().any(|a| a.has_non_region_param()) {
+ if impl_trait_ref.is_some() && args.iter().any(|a| a.has_non_region_param()) {
self = self.path_generic_args(
|this| {
this.path_append_ns(
@@ -305,7 +305,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
"",
)
},
- substs,
+ args,
)?;
} else {
self.push_disambiguator(key.disambiguated_data.disambiguator as u64);
@@ -315,7 +315,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
self = self_ty.print(self)?;
if let Some(trait_ref) = impl_trait_ref {
- self = self.print_def_path(trait_ref.def_id, trait_ref.substs)?;
+ self = self.print_def_path(trait_ref.def_id, trait_ref.args)?;
}
Ok(self)
@@ -431,12 +431,12 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
}
// Mangle all nominal types as paths.
- ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
- | ty::FnDef(def_id, substs)
- | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, substs, .. })
- | ty::Closure(def_id, substs)
- | ty::Generator(def_id, substs, _) => {
- self = self.print_def_path(def_id, substs)?;
+ ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
+ | ty::FnDef(def_id, args)
+ | ty::Alias(ty::Projection | ty::Opaque, ty::AliasTy { def_id, args, .. })
+ | ty::Closure(def_id, args)
+ | ty::Generator(def_id, args, _) => {
+ self = self.print_def_path(def_id, args)?;
}
ty::Foreign(def_id) => {
self = self.print_def_path(def_id, &[])?;
@@ -537,7 +537,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
// Use a type that can't appear in defaults of type parameters.
let dummy_self = Ty::new_fresh(cx.tcx, 0);
let trait_ref = trait_ref.with_self_ty(cx.tcx, dummy_self);
- cx = cx.print_def_path(trait_ref.def_id, trait_ref.substs)?;
+ cx = cx.print_def_path(trait_ref.def_id, trait_ref.args)?;
}
ty::ExistentialPredicate::Projection(projection) => {
let name = cx.tcx.associated_item(projection.def_id).name;
@@ -628,7 +628,8 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
valtree, ty
)
});
- let s = std::str::from_utf8(slice).expect("non utf8 str from miri");
+ let s = std::str::from_utf8(slice)
+ .expect("non utf8 str from MIR interpreter");
self.push("e");
@@ -679,13 +680,13 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
self.push("T");
self = print_field_list(self)?;
}
- ty::Adt(def, substs) => {
+ ty::Adt(def, args) => {
let variant_idx =
contents.variant.expect("destructed const of adt without variant idx");
let variant_def = &def.variant(variant_idx);
self.push("V");
- self = self.print_def_path(variant_def.def_id, substs)?;
+ self = self.print_def_path(variant_def.def_id, args)?;
match variant_def.ctor_kind() {
Some(CtorKind::Const) => {
@@ -750,7 +751,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> {
self.push("Y");
self = self_ty.print(self)?;
- self.print_def_path(trait_ref.def_id, trait_ref.substs)
+ self.print_def_path(trait_ref.def_id, trait_ref.args)
}
fn path_append_impl(