File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
crates/formality-macros/src Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ pub(crate) fn upcast_impls(s: synstructure::Structure) -> Vec<TokenStream> {
13
13
. filter ( |v| num_variants == 1 || has_isa_attr ( v. ast ( ) . attrs ) )
14
14
. map ( |v : & VariantInfo < ' _ > | upcast_to_variant ( & s, v) )
15
15
. chain ( Some ( self_upcast ( & s) ) )
16
- . chain ( Some ( arc_upcast ( & s) ) )
16
+ . chain ( Some ( arc_cast ( & s) ) )
17
17
. collect ( )
18
18
}
19
19
@@ -29,13 +29,14 @@ fn self_upcast(s: &synstructure::Structure) -> TokenStream {
29
29
} )
30
30
}
31
31
32
- fn arc_upcast ( s : & synstructure:: Structure ) -> TokenStream {
32
+ fn arc_cast ( s : & synstructure:: Structure ) -> TokenStream {
33
33
let type_name = & s. ast ( ) . ident ;
34
34
let ( impl_generics, type_generics, where_clauses) = s. ast ( ) . generics . split_for_impl ( ) ;
35
35
36
36
quote_spanned ! { type_name. span( ) =>
37
37
const _: ( ) = {
38
38
use formality_core:: Upcast ;
39
+ use formality_core:: DowncastFrom ;
39
40
use std:: sync:: Arc ;
40
41
41
42
impl #impl_generics Upcast <Arc <Self >> for #type_name #type_generics
@@ -44,6 +45,14 @@ fn arc_upcast(s: &synstructure::Structure) -> TokenStream {
44
45
Arc :: new( self )
45
46
}
46
47
}
48
+
49
+
50
+ impl #impl_generics DowncastFrom <Arc <Self >> for #type_name #type_generics
51
+ #where_clauses {
52
+ fn downcast_from( t: & Arc <Self >) -> Option <Self > {
53
+ Some ( Self :: clone( t) )
54
+ }
55
+ }
47
56
} ;
48
57
}
49
58
}
You can’t perform that action at this time.
0 commit comments