Misc fixes (pattern type lowering, cfi, pretty printing)
This commit is contained in:
parent
a454da3b1c
commit
56092a345b
4 changed files with 36 additions and 40 deletions
|
@ -68,6 +68,8 @@ fn compress<'tcx>(
|
|||
fn encode_args<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
args: GenericArgsRef<'tcx>,
|
||||
for_def: DefId,
|
||||
has_erased_self: bool,
|
||||
dict: &mut FxHashMap<DictKey<'tcx>, usize>,
|
||||
options: EncodeTyOptions,
|
||||
) -> String {
|
||||
|
@ -76,7 +78,8 @@ fn encode_args<'tcx>(
|
|||
let args: Vec<GenericArg<'_>> = args.iter().collect();
|
||||
if !args.is_empty() {
|
||||
s.push('I');
|
||||
for arg in args {
|
||||
let def_generics = tcx.generics_of(for_def);
|
||||
for (n, arg) in args.iter().enumerate() {
|
||||
match arg.unpack() {
|
||||
GenericArgKind::Lifetime(region) => {
|
||||
s.push_str(&encode_region(region, dict));
|
||||
|
@ -85,7 +88,10 @@ fn encode_args<'tcx>(
|
|||
s.push_str(&encode_ty(tcx, ty, dict, options));
|
||||
}
|
||||
GenericArgKind::Const(c) => {
|
||||
s.push_str(&encode_const(tcx, c, dict, options));
|
||||
let n = n + (has_erased_self as usize);
|
||||
let ct_ty =
|
||||
tcx.type_of(def_generics.param_at(n, tcx).def_id).instantiate_identity();
|
||||
s.push_str(&encode_const(tcx, c, ct_ty, dict, options));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +105,7 @@ fn encode_args<'tcx>(
|
|||
fn encode_const<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
c: Const<'tcx>,
|
||||
ct_ty: Ty<'tcx>,
|
||||
dict: &mut FxHashMap<DictKey<'tcx>, usize>,
|
||||
options: EncodeTyOptions,
|
||||
) -> String {
|
||||
|
@ -111,8 +118,7 @@ fn encode_const<'tcx>(
|
|||
// L<element-type>E as literal argument
|
||||
|
||||
// Element type
|
||||
// THISPR
|
||||
s.push_str(&encode_ty(tcx, todo!(), dict, options));
|
||||
s.push_str(&encode_ty(tcx, ct_ty, dict, options));
|
||||
}
|
||||
|
||||
// Literal arguments
|
||||
|
@ -232,15 +238,21 @@ 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_args(tcx, trait_ref.args, dict, options));
|
||||
s.push_str(&encode_args(tcx, trait_ref.args, trait_ref.def_id, true, 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_args(tcx, projection.args, dict, options));
|
||||
s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, 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)),
|
||||
TermKind::Const(c) => s.push_str(&encode_const(
|
||||
tcx,
|
||||
c,
|
||||
tcx.type_of(projection.def_id).instantiate(tcx, projection.args),
|
||||
dict,
|
||||
options,
|
||||
)),
|
||||
}
|
||||
}
|
||||
ty::ExistentialPredicate::AutoTrait(def_id) => {
|
||||
|
@ -486,7 +498,7 @@ pub 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_args(tcx, args, dict, options));
|
||||
s.push_str(&encode_args(tcx, args, def_id, false, dict, options));
|
||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||
}
|
||||
typeid.push_str(&s);
|
||||
|
@ -530,7 +542,7 @@ pub fn encode_ty<'tcx>(
|
|||
let mut s = String::new();
|
||||
let name = encode_ty_name(tcx, *def_id);
|
||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
||||
s.push_str(&encode_args(tcx, args, dict, options));
|
||||
s.push_str(&encode_args(tcx, args, *def_id, false, dict, options));
|
||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||
typeid.push_str(&s);
|
||||
}
|
||||
|
@ -542,7 +554,7 @@ pub fn encode_ty<'tcx>(
|
|||
let name = encode_ty_name(tcx, *def_id);
|
||||
let _ = write!(s, "u{}{}", name.len(), &name);
|
||||
let parent_args = tcx.mk_args(args.as_coroutine_closure().parent_args());
|
||||
s.push_str(&encode_args(tcx, parent_args, dict, options));
|
||||
s.push_str(&encode_args(tcx, parent_args, *def_id, false, dict, options));
|
||||
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||
typeid.push_str(&s);
|
||||
}
|
||||
|
@ -557,6 +569,8 @@ pub fn encode_ty<'tcx>(
|
|||
s.push_str(&encode_args(
|
||||
tcx,
|
||||
tcx.mk_args(args.as_coroutine().parent_args()),
|
||||
*def_id,
|
||||
false,
|
||||
dict,
|
||||
options,
|
||||
));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue