Auto merge of #101212 - eholk:dyn-star, r=compiler-errors
Initial implementation of dyn* This PR adds extremely basic and incomplete support for [dyn*](https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/). The goal is to get something in tree behind a flag to make collaboration easier, and also to make sure the implementation so far is not unreasonable. This PR does quite a few things: * Introduce `dyn_star` feature flag * Adds parsing for `dyn* Trait` types * Defines `dyn* Trait` as a sized type * Adds support for explicit casts, like `42usize as dyn* Debug` * Including const evaluation of such casts * Adds codegen for drop glue so things are cleaned up properly when a `dyn* Trait` object goes out of scope * Adds codegen for method calls, at least for methods that take `&self` Quite a bit is still missing, but this gives us a starting point. Note that this is never intended to become stable surface syntax for Rust, but rather `dyn*` is planned to be used as an implementation detail for async functions in dyn traits. Joint work with `@nikomatsakis` and `@compiler-errors.` r? `@bjorn3`
This commit is contained in:
commit
6153d3cbe6
69 changed files with 617 additions and 104 deletions
|
@ -1028,9 +1028,11 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> {
|
|||
ty::Array(typ, sz) => ty::Array(typ.try_fold_with(folder)?, sz.try_fold_with(folder)?),
|
||||
ty::Slice(typ) => ty::Slice(typ.try_fold_with(folder)?),
|
||||
ty::Adt(tid, substs) => ty::Adt(tid, substs.try_fold_with(folder)?),
|
||||
ty::Dynamic(trait_ty, region) => {
|
||||
ty::Dynamic(trait_ty.try_fold_with(folder)?, region.try_fold_with(folder)?)
|
||||
}
|
||||
ty::Dynamic(trait_ty, region, representation) => ty::Dynamic(
|
||||
trait_ty.try_fold_with(folder)?,
|
||||
region.try_fold_with(folder)?,
|
||||
representation,
|
||||
),
|
||||
ty::Tuple(ts) => ty::Tuple(ts.try_fold_with(folder)?),
|
||||
ty::FnDef(def_id, substs) => ty::FnDef(def_id, substs.try_fold_with(folder)?),
|
||||
ty::FnPtr(f) => ty::FnPtr(f.try_fold_with(folder)?),
|
||||
|
@ -1074,7 +1076,7 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> {
|
|||
}
|
||||
ty::Slice(typ) => typ.visit_with(visitor),
|
||||
ty::Adt(_, substs) => substs.visit_with(visitor),
|
||||
ty::Dynamic(ref trait_ty, ref reg) => {
|
||||
ty::Dynamic(ref trait_ty, ref reg, _) => {
|
||||
trait_ty.visit_with(visitor)?;
|
||||
reg.visit_with(visitor)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue