Rollup merge of #118719 - rcvalle:rust-cfi-normalize-integers-118032, r=compiler-errors
CFI: Add char to CFI integer normalization Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
This commit is contained in:
commit
71812d7eb0
2 changed files with 29 additions and 63 deletions
|
@ -773,12 +773,7 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
|||
let mut ty = ty;
|
||||
|
||||
match ty.kind() {
|
||||
ty::Float(..)
|
||||
| ty::Char
|
||||
| ty::Str
|
||||
| ty::Never
|
||||
| ty::Foreign(..)
|
||||
| ty::CoroutineWitness(..) => {}
|
||||
ty::Float(..) | ty::Str | ty::Never | ty::Foreign(..) | ty::CoroutineWitness(..) => {}
|
||||
|
||||
ty::Bool => {
|
||||
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
|
||||
|
@ -792,6 +787,14 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
|
|||
}
|
||||
}
|
||||
|
||||
ty::Char => {
|
||||
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
|
||||
// Since #118032, char is guaranteed to have the same size, alignment, and function
|
||||
// call ABI as u32 on all platforms.
|
||||
ty = tcx.types.u32;
|
||||
}
|
||||
}
|
||||
|
||||
ty::Int(..) | ty::Uint(..) => {
|
||||
if options.contains(EncodeTyOptions::NORMALIZE_INTEGERS) {
|
||||
// Note: C99 7.18.2.4 requires uintptr_t and intptr_t to be at least 16-bit wide.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue