Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6153d3c

Browse files
committedSep 14, 2022
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`
2 parents a926696 + 0faafbf commit 6153d3c

File tree

69 files changed

+617
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+617
-104
lines changed
 

‎compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,7 @@ impl TyKind {
20722072
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
20732073
pub enum TraitObjectSyntax {
20742074
Dyn,
2075+
DynStar,
20752076
None,
20762077
}
20772078

‎compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
554554
ast::TyKind::Never => {
555555
gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental");
556556
}
557+
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::DynStar, ..) => {
558+
gate_feature_post!(&self, dyn_star, ty.span, "dyn* trait objects are unstable");
559+
}
557560
_ => {}
558561
}
559562
visit::walk_ty(self, ty)

0 commit comments

Comments
 (0)