Skip to content

Commit 836427d

Browse files
committed
Label, static closure, trait alias, foreign type
Added: * Label's instead of lifetimes for annotating loops/breaks/continue's * Static closures * Parsing trait aliases * Foreign items that are abstract types Updated: * Updated all tests * Removed DefaultImpl (superseded by auto trait)
1 parent 94f64ba commit 836427d

File tree

12 files changed

+223
-155
lines changed

12 files changed

+223
-155
lines changed

sample-sources/attributes.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ trait Trait {
146146
foo!();
147147
}
148148

149-
#[defaultimpl_outer]
150-
impl Trait for .. { }
151-
152149

153150
#[impl_outer]
154151
impl Impls {

sample-sources/expressions.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ fn main() {
1616
if let y = true { };
1717
while true { }
1818
'l: while true { }
19-
while let y = true { continue; }
20-
'l: while let y = true { continue 'l; }
19+
while let None = None { continue; }
20+
'l: while let None = None { continue 'l; }
2121
for i in 1.. { }
2222
'l: for i in 1..10 { }
2323
loop { break; }
2424
'l: loop { break 'l 1; }
2525
match x { _ => () }
2626
let x = move |a,b,c| { a + b + c };
27+
let x = static move |a,b,c| { a + b + c };
2728
let f = |_||x, y| x+y;
29+
let f = static |_||x, y| x+y;
2830
let x = { 1 };
2931
let x = unsafe { 1 };
3032
a = 1;
@@ -45,6 +47,8 @@ fn main() {
4547
let x = do catch { 1 };
4648
return 0;
4749
return;
50+
yield 0;
51+
yield;
4852

4953
match true {
5054
true => move | | { 1 },

sample-sources/items.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod bar {
1919
fn foo<T>(x: int) -> int;
2020
static x: int;
2121
static mut x: *mut int;
22+
type C;
2223
}
2324

2425
type Foo = Bar<u8>;
@@ -51,14 +52,14 @@ mod bar {
5152
foo!{}
5253
}
5354

55+
trait Foo = Bar + Baz;
56+
5457
fn foo<T: ?Sized>(x: &T) { }
5558
struct Foo<T: Send + ?Sized + Sync> { field: Box<T> }
5659
trait Bar { type Baz: ?Sized; }
5760

5861
struct Bleh<T, U> where T: Copy, U: Sized;
5962

60-
impl Trait for .. {}
61-
impl Trait<T> for .. {}
6263
impl<A> Foo<A> {
6364
const ID: i32 = 1;
6465
fn area(&self) -> f64 { 1f64 }

sample-sources/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fn main() {
1717
let x: T;
1818
let x: <Vec<T> as SomeTrait>::SomeType;
1919
let x: Bound1 + Bound2 + 'static;
20+
let x: dyn Bound1 + Bound2 + 'static;
2021
let x: (i32);
2122
let x: typeof(1i32);
2223
let x: _;

src/Language/Rust/Parser/Internal.y

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ import qualified Data.List.NonEmpty as N
208208
where { Spanned (IdentTok "where") _ }
209209
while { Spanned (IdentTok "while") _ }
210210
do { Spanned (IdentTok "do") _ }
211+
yield { Spanned (IdentTok "yield") _ }
212+
dyn { Spanned (IdentTok "dyn") _ }
211213

212214
-- Keywords reserved for future use
213215
abstract { Spanned (IdentTok "abstract") _ }
@@ -224,7 +226,6 @@ import qualified Data.List.NonEmpty as N
224226
typeof { Spanned (IdentTok "typeof") _ }
225227
unsized { Spanned (IdentTok "unsized") _ }
226228
virtual { Spanned (IdentTok "virtual") _ }
227-
yield { Spanned (IdentTok "yield") _ }
228229

229230
-- Weak keywords, have special meaning only in specific contexts.
230231
default { Spanned (IdentTok "default") _ }
@@ -280,7 +281,11 @@ import qualified Data.List.NonEmpty as N
280281
%nonassoc IDENT ntIdent default union catch self auto
281282

282283
-- These are all very low precedence unary operators
283-
%nonassoc box return break continue IMPLTRAIT LAMBDA
284+
%nonassoc box return yield break continue IMPLTRAIT LAMBDA
285+
286+
-- 'static' needs to have higher precedenc than 'LAMBDA' so that statements starting in static get
287+
-- considered as static items, and not a static lambda
288+
%nonassoc static
284289

285290
-- These are the usual arithmetic precedences. 'UNARY' is introduced here for '*', '!', '-', '&'
286291
%right '=' '>>=' '<<=' '-=' '+=' '*=' '/=' '^=' '|=' '&=' '%='
@@ -331,6 +336,7 @@ ident :: { Spanned Ident }
331336
| default { toIdent $1 }
332337
| catch { toIdent $1 }
333338
| auto { toIdent $1 }
339+
| dyn { toIdent $1 }
334340
| IDENT { toIdent $1 }
335341

336342
-- This should precede any '>' token which could be absorbed in a '>>', '>=', or '>>=' token. Its
@@ -638,6 +644,7 @@ for_ty_no_plus :: { Ty Span }
638644

639645
impl_ty :: { Ty Span }
640646
: impl sep_by1(ty_param_bound_mod,'+') %prec IMPLTRAIT { ImplTrait (toNonEmpty $2) ($1 # $2) }
647+
-- | dyn sep_by1(ty_param_bound_mod,'+') %prec IMPLTRAIT { TraitObject (toNonEmpty $2) ($1 # $2) }
641648

642649
-- An optional lifetime followed by an optional mutability
643650
lifetime_mut :: { (Maybe (Lifetime Span), Mutability) }
@@ -916,17 +923,23 @@ gen_expression(lhs,rhs,rhs2) :: { Expr Span }
916923
-- low precedence prefix expressions
917924
| return { Ret [] Nothing (spanOf $1) }
918925
| return rhs { Ret [] (Just $2) ($1 # $2) }
926+
| yield { Yield [] Nothing (spanOf $1) }
927+
| yield rhs { Yield [] (Just $2) ($1 # $2) }
919928
| continue { Continue [] Nothing (spanOf $1) }
920-
| continue lifetime { Continue [] (Just $2) ($1 # $2) }
929+
| continue label { Continue [] (Just $2) ($1 # $2) }
921930
| break { Break [] Nothing Nothing (spanOf $1) }
922-
| break rhs { Break [] Nothing (Just $2) ($1 # $2) }
923-
| break lifetime { Break [] (Just $2) Nothing ($1 # $2) }
924-
| break lifetime rhs %prec break { Break [] (Just $2) (Just $3) ($1 # $3) }
931+
| break rhs { Break [] Nothing (Just $2) ($1 # $2) }
932+
| break label { Break [] (Just $2) Nothing ($1 # $2) }
933+
| break label rhs %prec break { Break [] (Just $2) (Just $3) ($1 # $3) }
925934
-- lambda expressions
926-
| move lambda_args rhs %prec LAMBDA
927-
{ Closure [] Value (FnDecl (unspan $2) Nothing False (spanOf $2)) $> ($1 # $>) }
928-
| lambda_args rhs %prec LAMBDA
929-
{ Closure [] Ref (FnDecl (unspan $1) Nothing False (spanOf $1)) $> ($1 # $>) }
935+
| static move lambda_args rhs %prec LAMBDA
936+
{ Closure [] Immovable Value (FnDecl (unspan $3) Nothing False (spanOf $3)) $> ($1 # $>) }
937+
| move lambda_args rhs %prec LAMBDA
938+
{ Closure [] Movable Value (FnDecl (unspan $2) Nothing False (spanOf $2)) $> ($1 # $>) }
939+
| static lambda_args rhs %prec LAMBDA
940+
{ Closure [] Immovable Ref (FnDecl (unspan $2) Nothing False (spanOf $2)) $> ($1 # $>) }
941+
| lambda_args rhs %prec LAMBDA
942+
{ Closure [] Movable Ref (FnDecl (unspan $1) Nothing False (spanOf $1)) $> ($1 # $>) }
930943

931944
-- Variant of 'gen_expression' which only constructs expressions starting with another expression.
932945
left_gen_expression(lhs,rhs,rhs2) :: { Expr Span }
@@ -1084,6 +1097,10 @@ blockpostfix_expr :: { Expr Span }
10841097

10851098
-- Finally, what remains is the more mundane definitions of particular types of expressions.
10861099

1100+
-- labels on loops
1101+
label :: { Label Span }
1102+
: LIFETIME { let Spanned (LifetimeTok (Ident l _)) s = $1 in Label l s }
1103+
10871104
-- Literal expressions (composed of just literals)
10881105
lit_expr :: { Expr Span }
10891106
: lit { Lit [] $1 (spanOf $1) }
@@ -1098,21 +1115,21 @@ block_expr :: { Expr Span }
10981115

10991116
-- Any expression ending in a '{ ... }' block except a block itself.
11001117
block_like_expr :: { Expr Span }
1101-
: if_expr { $1 }
1102-
| loop inner_attrs_block { let (as,b) = $> in Loop as b Nothing ($1 # b) }
1103-
| lifetime ':' loop inner_attrs_block { let (as,b) = $> in Loop as b (Just $1) ($1 # b) }
1104-
| for pat in nostruct_expr inner_attrs_block { let (as,b) = $> in ForLoop as $2 $4 b Nothing ($1 # b) }
1105-
| lifetime ':' for pat in nostruct_expr inner_attrs_block { let (as,b) = $> in ForLoop as $4 $6 b (Just $1) ($1 # b) }
1106-
| while nostruct_expr inner_attrs_block { let (as,b) = $> in While as $2 b Nothing ($1 # b) }
1107-
| lifetime ':' while nostruct_expr inner_attrs_block { let (as,b) = $> in While as $4 b (Just $1) ($1 # b) }
1108-
| while let pat '=' nostruct_expr inner_attrs_block { let (as,b) = $> in WhileLet as $3 $5 b Nothing ($1 # b) }
1109-
| lifetime ':' while let pat '=' nostruct_expr inner_attrs_block { let (as,b) = $> in WhileLet as $5 $7 b (Just $1) ($1 # b) }
1110-
| match nostruct_expr '{' '}' { Match [] $2 [] ($1 # $>) }
1111-
| match nostruct_expr '{' inner_attrs '}' { Match (toList $4) $2 [] ($1 # $>) }
1112-
| match nostruct_expr '{' arms '}' { Match [] $2 $4 ($1 # $>) }
1113-
| match nostruct_expr '{' inner_attrs arms '}' { Match (toList $4) $2 $5 ($1 # $>) }
1114-
| expr_path '!' '{' token_stream '}' { MacExpr [] (Mac $1 $4 ($1 # $>)) ($1 # $>) }
1115-
| do catch inner_attrs_block { let (as,b) = $> in Catch as b ($1 # b) }
1118+
: if_expr { $1 }
1119+
| loop inner_attrs_block { let (as,b) = $> in Loop as b Nothing ($1 # b) }
1120+
| label ':' loop inner_attrs_block { let (as,b) = $> in Loop as b (Just $1) ($1 # b) }
1121+
| for pat in nostruct_expr inner_attrs_block { let (as,b) = $> in ForLoop as $2 $4 b Nothing ($1 # b) }
1122+
| label ':' for pat in nostruct_expr inner_attrs_block { let (as,b) = $> in ForLoop as $4 $6 b (Just $1) ($1 # b) }
1123+
| while nostruct_expr inner_attrs_block { let (as,b) = $> in While as $2 b Nothing ($1 # b) }
1124+
| label ':' while nostruct_expr inner_attrs_block { let (as,b) = $> in While as $4 b (Just $1) ($1 # b) }
1125+
| while let pat '=' nostruct_expr inner_attrs_block { let (as,b) = $> in WhileLet as $3 $5 b Nothing ($1 # b) }
1126+
| label ':' while let pat '=' nostruct_expr inner_attrs_block { let (as,b) = $> in WhileLet as $5 $7 b (Just $1) ($1 # b) }
1127+
| match nostruct_expr '{' '}' { Match [] $2 [] ($1 # $>) }
1128+
| match nostruct_expr '{' inner_attrs '}' { Match (toList $4) $2 [] ($1 # $>) }
1129+
| match nostruct_expr '{' arms '}' { Match [] $2 $4 ($1 # $>) }
1130+
| match nostruct_expr '{' inner_attrs arms '}' { Match (toList $4) $2 $5 ($1 # $>) }
1131+
| expr_path '!' '{' token_stream '}' { MacExpr [] (Mac $1 $4 ($1 # $>)) ($1 # $>) }
1132+
| do catch inner_attrs_block { let (as,b) = $> in Catch as b ($1 # b) }
11161133

11171134
-- 'if' expressions are a bit special since they can have an arbitrary number of 'else if' chains.
11181135
if_expr :: { Expr Span }
@@ -1168,10 +1185,14 @@ paren_expr :: { Expr Span }
11681185

11691186
-- Closure ending in blocks
11701187
lambda_expr_block :: { Expr Span }
1171-
: move lambda_args '->' ty_no_plus block
1172-
{ Closure [] Value (FnDecl (unspan $2) (Just $4) False (spanOf $2)) (BlockExpr [] $> (spanOf $>)) ($1 # $>) }
1173-
| lambda_args '->' ty_no_plus block
1174-
{ Closure [] Ref (FnDecl (unspan $1) (Just $3) False (spanOf $1)) (BlockExpr [] $> (spanOf $>)) ($1 # $>) }
1188+
: static move lambda_args '->' ty_no_plus block
1189+
{ Closure [] Immovable Value (FnDecl (unspan $3) (Just $5) False (spanOf $3)) (BlockExpr [] $> (spanOf $>)) ($1 # $>) }
1190+
| move lambda_args '->' ty_no_plus block
1191+
{ Closure [] Movable Value (FnDecl (unspan $2) (Just $4) False (spanOf $2)) (BlockExpr [] $> (spanOf $>)) ($1 # $>) }
1192+
| static lambda_args '->' ty_no_plus block
1193+
{ Closure [] Immovable Ref (FnDecl (unspan $2) (Just $4) False (spanOf $2)) (BlockExpr [] $> (spanOf $>)) ($1 # $>) }
1194+
| lambda_args '->' ty_no_plus block
1195+
{ Closure [] Movable Ref (FnDecl (unspan $1) (Just $3) False (spanOf $1)) (BlockExpr [] $> (spanOf $>)) ($1 # $>) }
11751196

11761197
-- Lambda expression arguments block
11771198
lambda_args :: { Spanned [Arg Span] }
@@ -1317,8 +1338,8 @@ gen_item(vis) :: { Item Span }
13171338
{ Trait $1 (unspan $2) (unspan $6) True (unspan $3) ($7 `withWhere` $10) (toList $9) $12 ($1 # $2 # $3 # $5 # $>) }
13181339
| many(outer_attribute) vis safety auto trait ident generics where_clause '{' many(trait_item) '}'
13191340
{ Trait $1 (unspan $2) (unspan $6) True (unspan $3) ($7 `withWhere` $8) [] $10 ($1 # $2 # $3 # $5 # $>) }
1320-
-- | many(outer_attribute) vis trait ident generics '=' sep_by1T(ty_param_bound,'+') ';'
1321-
-- { TraitAlias $1 (unspan $2) (unspan $4) $5 (toNonEmpty $7) ($1 # $2 # $3 # $>) }
1341+
| many(outer_attribute) vis safety trait ident generics '=' sep_by1T(ty_param_bound,'+') ';'
1342+
{% noSafety $3 (TraitAlias $1 (unspan $2) (unspan $5) $6 (toNonEmpty $8) ($1 # $2 # $3 # $>)) }
13221343
| many(outer_attribute) vis safety impl generics ty_prim where_clause '{' impl_items '}'
13231344
{ Impl ($1 ++ fst $9) (unspan $2) Final (unspan $3) Positive ($5 `withWhere` $7) Nothing $6 (snd $9) ($1 # $2 # $3 # $4 # $5 # $>) }
13241345
| many(outer_attribute) vis default safety impl generics ty_prim where_clause '{' impl_items '}'
@@ -1335,11 +1356,6 @@ gen_item(vis) :: { Item Span }
13351356
{ Impl ($1 ++ fst $11) (unspan $2) Final (unspan $3) Positive ($5 `withWhere` $9) (Just $6) $8 (snd $11) ($1 # $2 # $3 # $4 # $5 # $>) }
13361357
| many(outer_attribute) vis default safety impl generics trait_ref for ty where_clause '{' impl_items '}'
13371358
{ Impl ($1 ++ fst $12) (unspan $2) Default (unspan $4) Positive ($6 `withWhere` $10) (Just $7) $9 (snd $12) ($1 # $2 # $3 # $4 # $5 # $>) }
1338-
| many(outer_attribute) vis safety impl generics trait_ref for '..' '{' '}'
1339-
{% case $5 of
1340-
Generics [] [] _ _ -> pure $ AutoImpl $1 (unspan $2) (unspan $3) $6 ($1 # $2 # $3 # $4 # $>)
1341-
_ -> fail "non-empty generics are no allowed on default implementations"
1342-
}
13431359
13441360
-- Most general type of item
13451361
mod_item :: { Item Span }
@@ -1365,6 +1381,8 @@ foreign_item :: { ForeignItem Span }
13651381
{ ForeignStatic $1 (unspan $2) (unspan $5) $7 Mutable ($1 # $2 # $>) }
13661382
| many(outer_attribute) vis fn ident generics fn_decl(arg_named) where_clause ';'
13671383
{ ForeignFn $1 (unspan $2) (unspan $4) $6 ($5 `withWhere` $7) ($1 # $2 # $>) }
1384+
| many(outer_attribute) vis type ident ';'
1385+
{ ForeignTy $1 (unspan $2) (unspan $4) ($1 # $2 # $>) }
13681386
13691387
-- parse_generics
13701388
-- Leaves the WhereClause empty
@@ -1599,6 +1617,7 @@ token :: { Spanned Token }
15991617
| pub { $1 }
16001618
| ref { $1 }
16011619
| return { $1 }
1620+
| yield { $1 }
16021621
| Self { $1 }
16031622
| self { $1 }
16041623
| static { $1 }
@@ -1627,7 +1646,6 @@ token :: { Spanned Token }
16271646
| typeof { $1 }
16281647
| unsized { $1 }
16291648
| virtual { $1 }
1630-
| yield { $1 }
16311649
-- Weak keywords, have special meaning only in specific contexts.
16321650
| default { $1 }
16331651
| union { $1 }
@@ -1804,7 +1822,7 @@ addAttrs as (WhileLet as' p e b l s) = WhileLet (as ++ as') p e b l s
18041822
addAttrs as (ForLoop as' p e b l s) = ForLoop (as ++ as') p e b l s
18051823
addAttrs as (Loop as' b l s) = Loop (as ++ as') b l s
18061824
addAttrs as (Match as' e a s) = Match (as ++ as') e a s
1807-
addAttrs as (Closure as' c f e s) = Closure (as ++ as') c f e s
1825+
addAttrs as (Closure as' m c f e s) = Closure (as ++ as') m c f e s
18081826
addAttrs as (BlockExpr as' b s) = BlockExpr (as ++ as') b s
18091827
addAttrs as (Catch as' b s) = Catch (as ++ as') b s
18101828
addAttrs as (Assign as' e1 e2 s) = Assign (as ++ as') e1 e2 s
@@ -1823,6 +1841,7 @@ addAttrs as (Struct as' p f e a) = Struct (as ++ as') p f e a
18231841
addAttrs as (Repeat as' e1 e2 s) = Repeat (as ++ as') e1 e2 s
18241842
addAttrs as (ParenExpr as' e s) = ParenExpr (as ++ as') e s
18251843
addAttrs as (Try as' e s) = Try (as ++ as') e s
1844+
addAttrs as (Yield as' e s) = Yield (as ++ as') e s
18261845

18271846

18281847
-- | Given a 'LitTok' token that is expected to result in a valid literal, construct the associated

src/Language/Rust/Pretty/Internal.hs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ printExprOuterAttrStyle expr isInline = glue (printEitherAttrs (expressionAttrs
379379
ForLoop as pat e blk lbl x -> annotate x (hsep [ printLbl lbl, "for", printPat pat, "in", printExpr e, printBlockWithAttrs True blk as ])
380380
Loop as blk lbl x -> annotate x (hsep [ printLbl lbl, "loop", printBlockWithAttrs True blk as ])
381381
Match as e arms x -> annotate x (hsep [ "match", printExpr e, block Brace False "," (printInnerAttrs as) (printArm `map` arms) ])
382-
Closure _ cap decl body x -> annotate x (when (cap == Value) "move" <+> printFnBlockArgs decl <+> printExpr body)
382+
Closure _ s cap decl body x -> annotate x (hsep [ when (s == Immovable) "static"
383+
, when (cap == Value) "move"
384+
, printFnBlockArgs decl <+> printExpr body])
383385
BlockExpr attrs blk x -> annotate x (printBlockWithAttrs True blk attrs)
384386
Catch attrs blk x -> annotate x ("do catch" <+> printBlockWithAttrs True blk attrs)
385387
Assign _ lhs rhs x -> annotate x (hsep [ printExpr lhs, "=", printExpr rhs ])
@@ -391,9 +393,10 @@ printExprOuterAttrStyle expr isInline = glue (printEitherAttrs (expressionAttrs
391393
PathExpr _ Nothing path x -> annotate x (printPath path True)
392394
PathExpr _ (Just qs) path x -> annotate x (printQPath path qs True)
393395
AddrOf _ mut e x -> annotate x ("&" <> printMutability mut <+> printExpr e)
394-
Break _ brk e x -> annotate x ("break" <+> perhaps printLifetime brk <+> perhaps printExpr e)
395-
Continue _ cont x -> annotate x ("continue" <+> perhaps printLifetime cont)
396+
Break _ brk e x -> annotate x ("break" <+> printLbl' brk <+> perhaps printExpr e)
397+
Continue _ cont x -> annotate x ("continue" <+> printLbl' cont)
396398
Ret _ result x -> annotate x ("return" <+> perhaps printExpr result)
399+
Yield _ result x -> annotate x ("yield" <+> perhaps printExpr result)
397400
MacExpr _ m x -> annotate x (printMac Paren m)
398401
Struct as p fs Nothing x -> annotate x (printPath p True <+> block Brace True "," (printInnerAttrs as) (printField `map` fs))
399402
Struct as p fs (Just d) x -> let body = [ printField f <> "," | f <- fs ] ++ [ ".." <> printExpr d ]
@@ -402,7 +405,8 @@ printExprOuterAttrStyle expr isInline = glue (printEitherAttrs (expressionAttrs
402405
ParenExpr attrs e x -> annotate x (parens (printInnerAttrs attrs <+> printExpr e))
403406
Try{} -> chainedMethodCalls expr False id
404407
where
405-
printLbl = perhaps (\i -> printLifetime i <> ":")
408+
printLbl = perhaps (\(Label n x) -> annotate x ("'" <> printName n) <> ":")
409+
printLbl' = perhaps (\(Label n x) -> annotate x ("'" <> printName n))
406410
glue = if isInline then (<+>) else (</>)
407411

408412
-- | From an expression, seperate the first non-method-call from the list of method call suffixes
@@ -462,7 +466,7 @@ expressionAttrs (WhileLet as _ _ _ _ _) = as
462466
expressionAttrs (ForLoop as _ _ _ _ _) = as
463467
expressionAttrs (Loop as _ _ _) = as
464468
expressionAttrs (Match as _ _ _) = as
465-
expressionAttrs (Closure as _ _ _ _) = as
469+
expressionAttrs (Closure as _ _ _ _ _) = as
466470
expressionAttrs (BlockExpr as _ _) = as
467471
expressionAttrs (Catch as _ _) = as
468472
expressionAttrs (Assign as _ _ _) = as
@@ -481,6 +485,7 @@ expressionAttrs (Struct as _ _ _ _) = as
481485
expressionAttrs (Repeat as _ _ _) = as
482486
expressionAttrs (ParenExpr as _ _) = as
483487
expressionAttrs (Try as _ _) = as
488+
expressionAttrs (Yield as _ _) = as
484489

485490
-- | Print a field
486491
printField :: Field a -> Doc a
@@ -644,11 +649,7 @@ printItem (Trait as vis ident a u g tys i x) = annotate x $ align $ printOuterAt
644649

645650
printItem (TraitAlias as vis ident g bds x) = annotate x $ align $ printOuterAttrs as <#>
646651
let leading = printVis vis <+> "trait" <+> printIdent ident <> printGenerics g
647-
in group (leading <+> "=" <#> indent n (printBounds "=" (toList bds)))
648-
649-
650-
printItem (AutoImpl as vis u t x) = annotate x $ align $ printOuterAttrs as <#>
651-
hsep [ printVis vis, printUnsafety u, "impl", printTraitRef t, "for", "..", "{ }" ]
652+
in group (leading <#> indent n (printBounds "=" (toList bds)) <> ";")
652653

653654
printItem (Impl as vis d u p g t ty i x) = annotate x $ align $ printOuterAttrs as <#>
654655
let generics = case g of { Generics [] [] _ _ -> mempty; _ -> printGenerics g }
@@ -747,6 +748,8 @@ printForeignItem (ForeignFn attrs vis ident decl generics x) = annotate x $
747748
printOuterAttrs attrs <#> printFn decl Normal NotConst Rust (Just ident) generics vis Nothing
748749
printForeignItem (ForeignStatic attrs vis ident ty mut x) = annotate x $
749750
printOuterAttrs attrs <#> printVis vis <+> "static" <+> printMutability mut <+> printIdent ident <> ":" <+> printType ty <> ";"
751+
printForeignItem (ForeignTy attrs vis ident x) = annotate x $
752+
printOuterAttrs attrs <#> printVis vis <+> "type" <+> printIdent ident <> ";"
750753

751754
-- | Print a struct definition (@print_struct@)
752755
printStruct :: VariantData a -> Generics a -> Ident -> Bool -> Bool -> Doc a

0 commit comments

Comments
 (0)