Skip to content

Commit e4d2f94

Browse files
committed
Auto merge of rust-lang#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`
2 parents 11c831d + 6d544a8 commit e4d2f94

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/base.rs

+4
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ fn codegen_stmt<'tcx>(
701701
let operand = codegen_operand(fx, operand);
702702
operand.unsize_value(fx, lval);
703703
}
704+
Rvalue::Cast(CastKind::DynStar, _, _) => {
705+
// FIXME(dyn-star)
706+
unimplemented!()
707+
}
704708
Rvalue::Discriminant(place) => {
705709
let place = codegen_place(fx, place);
706710
let value = place.to_cvalue(fx);

src/value_and_place.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,8 @@ pub(crate) fn assert_assignable<'tcx>(
815815
);
816816
// fn(&T) -> for<'l> fn(&'l T) is allowed
817817
}
818-
(&ty::Dynamic(from_traits, _), &ty::Dynamic(to_traits, _)) => {
818+
(&ty::Dynamic(from_traits, _, _from_kind), &ty::Dynamic(to_traits, _, _to_kind)) => {
819+
// FIXME(dyn-star): Do the right thing with DynKinds
819820
for (from, to) in from_traits.iter().zip(to_traits) {
820821
let from =
821822
fx.tcx.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), from);

0 commit comments

Comments
 (0)