diff options
| author | 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> | 2025-02-28 22:29:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-28 22:29:56 +0800 |
| commit | 0cb9827d706dea0afdbdf3701aa3ff78b16b5a4b (patch) | |
| tree | 3e0b62c065bc5e5a9ee663fb01ca9ed93bb5ff81 /compiler/rustc_ty_utils/src | |
| parent | 9e1ead64928a7039c20bd095b7fdc9d258bf2aef (diff) | |
| parent | b67b6c05032e98a5984ebb39f581125e7d0b48b9 (diff) | |
| download | rust-0cb9827d706dea0afdbdf3701aa3ff78b16b5a4b.tar.gz rust-0cb9827d706dea0afdbdf3701aa3ff78b16b5a4b.zip | |
Rollup merge of #137770 - compiler-errors:unsafe-binder-sized-crit, r=oli-obk
Fix sized constraint for unsafe binder Fixes #137705 r? oli-obk
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 8ed45b4e541..8610c30ab70 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -37,8 +37,6 @@ fn sized_constraint_for_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<' | Never | Dynamic(_, _, ty::DynStar) => None, - UnsafeBinder(_) => todo!(), - // these are never sized Str | Slice(..) | Dynamic(_, _, ty::Dyn) | Foreign(..) => Some(ty), @@ -52,9 +50,14 @@ fn sized_constraint_for_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Ty<' sized_constraint_for_ty(tcx, ty) }), - // these can be sized or unsized + // these can be sized or unsized. Param(..) | Alias(..) | Error(_) => Some(ty), + // We cannot instantiate the binder, so just return the *original* type back, + // but only if the inner type has a sized constraint. Thus we skip the binder, + // but don't actually use the result from `sized_constraint_for_ty`. + UnsafeBinder(inner_ty) => sized_constraint_for_ty(tcx, inner_ty.skip_binder()).map(|_| ty), + Placeholder(..) | Bound(..) | Infer(..) => { bug!("unexpected type `{ty:?}` in sized_constraint_for_ty") } |
