CFI: Fix cfi with async: transform_ty: unexpected GeneratorWitness(Binde
Fixes #111184 by encoding ty::Generator parent substs only.
This commit is contained in:
parent
d5699874dc
commit
76ff5ec886
@ -608,9 +608,7 @@ fn encode_ty<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function types
|
// Function types
|
||||||
ty::FnDef(def_id, substs)
|
ty::FnDef(def_id, substs) | ty::Closure(def_id, substs) => {
|
||||||
| ty::Closure(def_id, substs)
|
|
||||||
| ty::Generator(def_id, substs, ..) => {
|
|
||||||
// u<length><name>[I<element-type1..element-typeN>E], where <element-type> is <subst>,
|
// u<length><name>[I<element-type1..element-typeN>E], where <element-type> is <subst>,
|
||||||
// as vendor extended type.
|
// as vendor extended type.
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
@ -621,6 +619,23 @@ fn encode_ty<'tcx>(
|
|||||||
typeid.push_str(&s);
|
typeid.push_str(&s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::Generator(def_id, substs, ..) => {
|
||||||
|
// 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(
|
||||||
|
tcx,
|
||||||
|
tcx.mk_substs(substs.as_generator().parent_substs()),
|
||||||
|
dict,
|
||||||
|
options,
|
||||||
|
));
|
||||||
|
compress(dict, DictKey::Ty(ty, TyQ::None), &mut s);
|
||||||
|
typeid.push_str(&s);
|
||||||
|
}
|
||||||
|
|
||||||
// Pointer types
|
// Pointer types
|
||||||
ty::Ref(region, ty0, ..) => {
|
ty::Ref(region, ty0, ..) => {
|
||||||
// [U3mut]u3refI<element-type>E as vendor extended type qualifier and type
|
// [U3mut]u3refI<element-type>E as vendor extended type qualifier and type
|
||||||
@ -739,7 +754,12 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
|||||||
let mut ty = ty;
|
let mut ty = ty;
|
||||||
|
|
||||||
match ty.kind() {
|
match ty.kind() {
|
||||||
ty::Float(..) | ty::Char | ty::Str | ty::Never | ty::Foreign(..) => {}
|
ty::Float(..)
|
||||||
|
| ty::Char
|
||||||
|
| ty::Str
|
||||||
|
| ty::Never
|
||||||
|
| ty::Foreign(..)
|
||||||
|
| ty::GeneratorWitness(..) => {}
|
||||||
|
|
||||||
ty::Bool => {
|
ty::Bool => {
|
||||||
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
|
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
|
||||||
@ -922,7 +942,6 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
|||||||
|
|
||||||
ty::Bound(..)
|
ty::Bound(..)
|
||||||
| ty::Error(..)
|
| ty::Error(..)
|
||||||
| ty::GeneratorWitness(..)
|
|
||||||
| ty::GeneratorWitnessMIR(..)
|
| ty::GeneratorWitnessMIR(..)
|
||||||
| ty::Infer(..)
|
| ty::Infer(..)
|
||||||
| ty::Alias(..)
|
| ty::Alias(..)
|
||||||
|
17
tests/ui/sanitize/issue-111184-generator-witness.rs
Normal file
17
tests/ui/sanitize/issue-111184-generator-witness.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Regression test for issue 111184, where ty::GeneratorWitness were not expected to occur in
|
||||||
|
// encode_ty and caused the compiler to ICE.
|
||||||
|
//
|
||||||
|
// needs-sanitizer-cfi
|
||||||
|
// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021
|
||||||
|
// no-prefer-dynamic
|
||||||
|
// only-x86_64-unknown-linux-gnu
|
||||||
|
// run-pass
|
||||||
|
|
||||||
|
use std::future::Future;
|
||||||
|
|
||||||
|
async fn foo() {}
|
||||||
|
fn bar<T>(_: impl Future<Output = T>) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
bar(foo());
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user