@@ -329,6 +329,7 @@ impl Ident {
329329 sess. symbol_gallery . insert ( sym, span) ;
330330 Ident { sym, is_raw, span }
331331 }
332+
332333 fn dollar_crate ( span : Span ) -> Ident {
333334 // `$crate` is accepted as an ident only if it comes from the compiler.
334335 Ident { sym : kw:: DollarCrate , is_raw : false , span }
@@ -403,6 +404,7 @@ impl server::TokenStream for Rustc<'_, '_> {
403404 fn is_empty ( & mut self , stream : & Self :: TokenStream ) -> bool {
404405 stream. is_empty ( )
405406 }
407+
406408 fn from_str ( & mut self , src : & str ) -> Self :: TokenStream {
407409 parse_stream_from_source_str (
408410 FileName :: proc_macro_source_code ( src) ,
@@ -411,9 +413,11 @@ impl server::TokenStream for Rustc<'_, '_> {
411413 Some ( self . call_site ) ,
412414 )
413415 }
416+
414417 fn to_string ( & mut self , stream : & Self :: TokenStream ) -> String {
415418 pprust:: tts_to_string ( stream)
416419 }
420+
417421 fn expand_expr ( & mut self , stream : & Self :: TokenStream ) -> Result < Self :: TokenStream , ( ) > {
418422 // Parse the expression from our tokenstream.
419423 let expr: PResult < ' _ , _ > = try {
@@ -464,12 +468,14 @@ impl server::TokenStream for Rustc<'_, '_> {
464468 _ => Err ( ( ) ) ,
465469 }
466470 }
471+
467472 fn from_token_tree (
468473 & mut self ,
469474 tree : TokenTree < Self :: Group , Self :: Punct , Self :: Ident , Self :: Literal > ,
470475 ) -> Self :: TokenStream {
471476 tree. to_internal ( )
472477 }
478+
473479 fn concat_trees (
474480 & mut self ,
475481 base : Option < Self :: TokenStream > ,
@@ -484,6 +490,7 @@ impl server::TokenStream for Rustc<'_, '_> {
484490 }
485491 builder. build ( )
486492 }
493+
487494 fn concat_streams (
488495 & mut self ,
489496 base : Option < Self :: TokenStream > ,
@@ -498,6 +505,7 @@ impl server::TokenStream for Rustc<'_, '_> {
498505 }
499506 builder. build ( )
500507 }
508+
501509 fn into_trees (
502510 & mut self ,
503511 stream : Self :: TokenStream ,
@@ -543,21 +551,27 @@ impl server::Group for Rustc<'_, '_> {
543551 flatten : false ,
544552 }
545553 }
554+
546555 fn delimiter ( & mut self , group : & Self :: Group ) -> Delimiter {
547556 group. delimiter
548557 }
558+
549559 fn stream ( & mut self , group : & Self :: Group ) -> Self :: TokenStream {
550560 group. stream . clone ( )
551561 }
562+
552563 fn span ( & mut self , group : & Self :: Group ) -> Self :: Span {
553564 group. span . entire ( )
554565 }
566+
555567 fn span_open ( & mut self , group : & Self :: Group ) -> Self :: Span {
556568 group. span . open
557569 }
570+
558571 fn span_close ( & mut self , group : & Self :: Group ) -> Self :: Span {
559572 group. span . close
560573 }
574+
561575 fn set_span ( & mut self , group : & mut Self :: Group , span : Self :: Span ) {
562576 group. span = DelimSpan :: from_single ( span) ;
563577 }
@@ -567,15 +581,19 @@ impl server::Punct for Rustc<'_, '_> {
567581 fn new ( & mut self , ch : char , spacing : Spacing ) -> Self :: Punct {
568582 Punct :: new ( ch, spacing == Spacing :: Joint , server:: Span :: call_site ( self ) )
569583 }
584+
570585 fn as_char ( & mut self , punct : Self :: Punct ) -> char {
571586 punct. ch
572587 }
588+
573589 fn spacing ( & mut self , punct : Self :: Punct ) -> Spacing {
574590 if punct. joint { Spacing :: Joint } else { Spacing :: Alone }
575591 }
592+
576593 fn span ( & mut self , punct : Self :: Punct ) -> Self :: Span {
577594 punct. span
578595 }
596+
579597 fn with_span ( & mut self , punct : Self :: Punct , span : Self :: Span ) -> Self :: Punct {
580598 Punct { span, ..punct }
581599 }
@@ -585,9 +603,11 @@ impl server::Ident for Rustc<'_, '_> {
585603 fn new ( & mut self , string : & str , span : Self :: Span , is_raw : bool ) -> Self :: Ident {
586604 Ident :: new ( self . sess ( ) , Symbol :: intern ( string) , is_raw, span)
587605 }
606+
588607 fn span ( & mut self , ident : Self :: Ident ) -> Self :: Span {
589608 ident. span
590609 }
610+
591611 fn with_span ( & mut self , ident : Self :: Ident , span : Self :: Span ) -> Self :: Ident {
592612 Ident { span, ..ident }
593613 }
@@ -639,45 +659,57 @@ impl server::Literal for Rustc<'_, '_> {
639659
640660 Ok ( Literal { lit, span : self . call_site } )
641661 }
662+
642663 fn to_string ( & mut self , literal : & Self :: Literal ) -> String {
643664 literal. lit . to_string ( )
644665 }
666+
645667 fn debug_kind ( & mut self , literal : & Self :: Literal ) -> String {
646668 format ! ( "{:?}" , literal. lit. kind)
647669 }
670+
648671 fn symbol ( & mut self , literal : & Self :: Literal ) -> String {
649672 literal. lit . symbol . to_string ( )
650673 }
674+
651675 fn suffix ( & mut self , literal : & Self :: Literal ) -> Option < String > {
652676 literal. lit . suffix . as_ref ( ) . map ( Symbol :: to_string)
653677 }
678+
654679 fn integer ( & mut self , n : & str ) -> Self :: Literal {
655680 self . lit ( token:: Integer , Symbol :: intern ( n) , None )
656681 }
682+
657683 fn typed_integer ( & mut self , n : & str , kind : & str ) -> Self :: Literal {
658684 self . lit ( token:: Integer , Symbol :: intern ( n) , Some ( Symbol :: intern ( kind) ) )
659685 }
686+
660687 fn float ( & mut self , n : & str ) -> Self :: Literal {
661688 self . lit ( token:: Float , Symbol :: intern ( n) , None )
662689 }
690+
663691 fn f32 ( & mut self , n : & str ) -> Self :: Literal {
664692 self . lit ( token:: Float , Symbol :: intern ( n) , Some ( sym:: f32) )
665693 }
694+
666695 fn f64 ( & mut self , n : & str ) -> Self :: Literal {
667696 self . lit ( token:: Float , Symbol :: intern ( n) , Some ( sym:: f64) )
668697 }
698+
669699 fn string ( & mut self , string : & str ) -> Self :: Literal {
670700 let quoted = format ! ( "{:?}" , string) ;
671701 assert ! ( quoted. starts_with( '"' ) && quoted. ends_with( '"' ) ) ;
672702 let symbol = & quoted[ 1 ..quoted. len ( ) - 1 ] ;
673703 self . lit ( token:: Str , Symbol :: intern ( symbol) , None )
674704 }
705+
675706 fn character ( & mut self , ch : char ) -> Self :: Literal {
676707 let quoted = format ! ( "{:?}" , ch) ;
677708 assert ! ( quoted. starts_with( '\'' ) && quoted. ends_with( '\'' ) ) ;
678709 let symbol = & quoted[ 1 ..quoted. len ( ) - 1 ] ;
679710 self . lit ( token:: Char , Symbol :: intern ( symbol) , None )
680711 }
712+
681713 fn byte_string ( & mut self , bytes : & [ u8 ] ) -> Self :: Literal {
682714 let string = bytes
683715 . iter ( )
@@ -687,12 +719,15 @@ impl server::Literal for Rustc<'_, '_> {
687719 . collect :: < String > ( ) ;
688720 self . lit ( token:: ByteStr , Symbol :: intern ( & string) , None )
689721 }
722+
690723 fn span ( & mut self , literal : & Self :: Literal ) -> Self :: Span {
691724 literal. span
692725 }
726+
693727 fn set_span ( & mut self , literal : & mut Self :: Literal , span : Self :: Span ) {
694728 literal. span = span;
695729 }
730+
696731 fn subspan (
697732 & mut self ,
698733 literal : & Self :: Literal ,
@@ -735,6 +770,7 @@ impl server::SourceFile for Rustc<'_, '_> {
735770 fn eq ( & mut self , file1 : & Self :: SourceFile , file2 : & Self :: SourceFile ) -> bool {
736771 Lrc :: ptr_eq ( file1, file2)
737772 }
773+
738774 fn path ( & mut self , file : & Self :: SourceFile ) -> String {
739775 match file. name {
740776 FileName :: Real ( ref name) => name
@@ -746,6 +782,7 @@ impl server::SourceFile for Rustc<'_, '_> {
746782 _ => file. name . prefer_local ( ) . to_string ( ) ,
747783 }
748784 }
785+
749786 fn is_real ( & mut self , file : & Self :: SourceFile ) -> bool {
750787 file. is_real_file ( )
751788 }
@@ -755,6 +792,7 @@ impl server::MultiSpan for Rustc<'_, '_> {
755792 fn new ( & mut self ) -> Self :: MultiSpan {
756793 vec ! [ ]
757794 }
795+
758796 fn push ( & mut self , spans : & mut Self :: MultiSpan , span : Self :: Span ) {
759797 spans. push ( span)
760798 }
@@ -766,6 +804,7 @@ impl server::Diagnostic for Rustc<'_, '_> {
766804 diag. set_span ( MultiSpan :: from_spans ( spans) ) ;
767805 diag
768806 }
807+
769808 fn sub (
770809 & mut self ,
771810 diag : & mut Self :: Diagnostic ,
@@ -775,6 +814,7 @@ impl server::Diagnostic for Rustc<'_, '_> {
775814 ) {
776815 diag. sub ( level. to_internal ( ) , msg, MultiSpan :: from_spans ( spans) , None ) ;
777816 }
817+
778818 fn emit ( & mut self , mut diag : Self :: Diagnostic ) {
779819 self . sess ( ) . span_diagnostic . emit_diagnostic ( & mut diag) ;
780820 }
@@ -788,38 +828,49 @@ impl server::Span for Rustc<'_, '_> {
788828 format ! ( "{:?} bytes({}..{})" , span. ctxt( ) , span. lo( ) . 0 , span. hi( ) . 0 )
789829 }
790830 }
831+
791832 fn def_site ( & mut self ) -> Self :: Span {
792833 self . def_site
793834 }
835+
794836 fn call_site ( & mut self ) -> Self :: Span {
795837 self . call_site
796838 }
839+
797840 fn mixed_site ( & mut self ) -> Self :: Span {
798841 self . mixed_site
799842 }
843+
800844 fn source_file ( & mut self , span : Self :: Span ) -> Self :: SourceFile {
801845 self . sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) . file
802846 }
847+
803848 fn parent ( & mut self , span : Self :: Span ) -> Option < Self :: Span > {
804849 span. parent_callsite ( )
805850 }
851+
806852 fn source ( & mut self , span : Self :: Span ) -> Self :: Span {
807853 span. source_callsite ( )
808854 }
855+
809856 fn start ( & mut self , span : Self :: Span ) -> LineColumn {
810857 let loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
811858 LineColumn { line : loc. line , column : loc. col . to_usize ( ) }
812859 }
860+
813861 fn end ( & mut self , span : Self :: Span ) -> LineColumn {
814862 let loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( span. hi ( ) ) ;
815863 LineColumn { line : loc. line , column : loc. col . to_usize ( ) }
816864 }
865+
817866 fn before ( & mut self , span : Self :: Span ) -> Self :: Span {
818867 span. shrink_to_lo ( )
819868 }
869+
820870 fn after ( & mut self , span : Self :: Span ) -> Self :: Span {
821871 span. shrink_to_hi ( )
822872 }
873+
823874 fn join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
824875 let self_loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( first. lo ( ) ) ;
825876 let other_loc = self . sess ( ) . source_map ( ) . lookup_char_pos ( second. lo ( ) ) ;
@@ -830,9 +881,11 @@ impl server::Span for Rustc<'_, '_> {
830881
831882 Some ( first. to ( second) )
832883 }
884+
833885 fn resolved_at ( & mut self , span : Self :: Span , at : Self :: Span ) -> Self :: Span {
834886 span. with_ctxt ( at. ctxt ( ) )
835887 }
888+
836889 fn source_text ( & mut self , span : Self :: Span ) -> Option < String > {
837890 self . sess ( ) . source_map ( ) . span_to_snippet ( span) . ok ( )
838891 }
@@ -863,6 +916,7 @@ impl server::Span for Rustc<'_, '_> {
863916 fn save_span ( & mut self , span : Self :: Span ) -> usize {
864917 self . sess ( ) . save_proc_macro_span ( span)
865918 }
919+
866920 fn recover_proc_macro_span ( & mut self , id : usize ) -> Self :: Span {
867921 let ( resolver, krate, def_site) = ( & * self . ecx . resolver , self . krate , self . def_site ) ;
868922 * self . rebased_spans . entry ( id) . or_insert_with ( || {
0 commit comments