File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -289,10 +289,10 @@ impl<'a> FmtVisitor<'a> {
289
289
290
290
arg_items = itemize_list ( self . codemap ,
291
291
arg_items,
292
- args[ min_args-1 ..] . iter ( ) ,
292
+ args[ min_args-1 ..] . iter ( ) . cloned ( ) ,
293
293
"," ,
294
294
")" ,
295
- |arg| arg . pat . span . lo ,
295
+ span_lo_for_arg ,
296
296
|arg| arg. ty . span . hi ,
297
297
|_| String :: new ( ) ,
298
298
comment_span_start,
@@ -780,9 +780,29 @@ impl<'a> FmtVisitor<'a> {
780
780
// TODO we farm this out, but this could spill over the column limit, so we
781
781
// ought to handle it properly.
782
782
fn rewrite_fn_input ( & self , arg : & ast:: Arg ) -> String {
783
- format ! ( "{}: {}" ,
784
- pprust:: pat_to_string( & arg. pat) ,
785
- pprust:: ty_to_string( & arg. ty) )
783
+ if is_named_arg ( arg) {
784
+ format ! ( "{}: {}" ,
785
+ pprust:: pat_to_string( & arg. pat) ,
786
+ pprust:: ty_to_string( & arg. ty) )
787
+ } else {
788
+ pprust:: ty_to_string ( & arg. ty )
789
+ }
790
+ }
791
+ }
792
+
793
+ fn span_lo_for_arg ( arg : & ast:: Arg ) -> BytePos {
794
+ if is_named_arg ( arg) {
795
+ arg. pat . span . lo
796
+ } else {
797
+ arg. ty . span . lo
798
+ }
799
+ }
800
+
801
+ fn is_named_arg ( arg : & ast:: Arg ) -> bool {
802
+ if let ast:: Pat_ :: PatIdent ( _, ident, _) = arg. pat . node {
803
+ ident. node != token:: special_idents:: invalid
804
+ } else {
805
+ true
786
806
}
787
807
}
788
808
Original file line number Diff line number Diff line change @@ -18,3 +18,7 @@ trait Foo {
18
18
fn read ( & mut self , x : BufReader < R > /* Used to be MemReader */ )
19
19
where R : Read ;
20
20
}
21
+
22
+ pub trait WriteMessage {
23
+ fn write_message ( & mut self , & FrontendMessage ) -> io:: Result < ( ) > ;
24
+ }
You can’t perform that action at this time.
0 commit comments