@@ -431,8 +431,6 @@ impl ToInternal<rustc_errors::Level> for Level {
431431 }
432432}
433433
434- pub ( crate ) struct FreeFunctions ;
435-
436434pub ( crate ) struct Rustc < ' a , ' b > {
437435 ecx : & ' a mut ExtCtxt < ' b > ,
438436 def_site : Span ,
@@ -461,13 +459,28 @@ impl<'a, 'b> Rustc<'a, 'b> {
461459}
462460
463461impl server:: Types for Rustc < ' _ , ' _ > {
464- type FreeFunctions = FreeFunctions ;
465462 type TokenStream = TokenStream ;
466463 type Span = Span ;
467464 type Symbol = Symbol ;
468465}
469466
470- impl server:: FreeFunctions for Rustc < ' _ , ' _ > {
467+ impl server:: Server for Rustc < ' _ , ' _ > {
468+ fn globals ( & mut self ) -> ExpnGlobals < Self :: Span > {
469+ ExpnGlobals {
470+ def_site : self . def_site ,
471+ call_site : self . call_site ,
472+ mixed_site : self . mixed_site ,
473+ }
474+ }
475+
476+ fn intern_symbol ( string : & str ) -> Self :: Symbol {
477+ Symbol :: intern ( string)
478+ }
479+
480+ fn with_symbol_string ( symbol : & Self :: Symbol , f : impl FnOnce ( & str ) ) {
481+ f ( symbol. as_str ( ) )
482+ }
483+
471484 fn injected_env_var ( & mut self , var : & str ) -> Option < String > {
472485 self . ecx . sess . opts . logical_env . get ( var) . cloned ( )
473486 }
@@ -552,14 +565,20 @@ impl server::FreeFunctions for Rustc<'_, '_> {
552565 }
553566 diag. emit ( ) ;
554567 }
555- }
556568
557- impl server:: TokenStream for Rustc < ' _ , ' _ > {
558- fn is_empty ( & mut self , stream : & Self :: TokenStream ) -> bool {
569+ fn ts_drop ( & mut self , stream : Self :: TokenStream ) {
570+ drop ( stream) ;
571+ }
572+
573+ fn ts_clone ( & mut self , stream : & Self :: TokenStream ) -> Self :: TokenStream {
574+ stream. clone ( )
575+ }
576+
577+ fn ts_is_empty ( & mut self , stream : & Self :: TokenStream ) -> bool {
559578 stream. is_empty ( )
560579 }
561580
562- fn from_str ( & mut self , src : & str ) -> Self :: TokenStream {
581+ fn ts_from_str ( & mut self , src : & str ) -> Self :: TokenStream {
563582 unwrap_or_emit_fatal ( source_str_to_stream (
564583 self . psess ( ) ,
565584 FileName :: proc_macro_source_code ( src) ,
@@ -568,11 +587,11 @@ impl server::TokenStream for Rustc<'_, '_> {
568587 ) )
569588 }
570589
571- fn to_string ( & mut self , stream : & Self :: TokenStream ) -> String {
590+ fn ts_to_string ( & mut self , stream : & Self :: TokenStream ) -> String {
572591 pprust:: tts_to_string ( stream)
573592 }
574593
575- fn expand_expr ( & mut self , stream : & Self :: TokenStream ) -> Result < Self :: TokenStream , ( ) > {
594+ fn ts_expand_expr ( & mut self , stream : & Self :: TokenStream ) -> Result < Self :: TokenStream , ( ) > {
576595 // Parse the expression from our tokenstream.
577596 let expr: PResult < ' _ , _ > = try {
578597 let mut p = Parser :: new ( self . psess ( ) , stream. clone ( ) , Some ( "proc_macro expand expr" ) ) ;
@@ -633,14 +652,14 @@ impl server::TokenStream for Rustc<'_, '_> {
633652 }
634653 }
635654
636- fn from_token_tree (
655+ fn ts_from_token_tree (
637656 & mut self ,
638657 tree : TokenTree < Self :: TokenStream , Self :: Span , Self :: Symbol > ,
639658 ) -> Self :: TokenStream {
640659 Self :: TokenStream :: new ( ( tree, & mut * self ) . to_internal ( ) . into_iter ( ) . collect :: < Vec < _ > > ( ) )
641660 }
642661
643- fn concat_trees (
662+ fn ts_concat_trees (
644663 & mut self ,
645664 base : Option < Self :: TokenStream > ,
646665 trees : Vec < TokenTree < Self :: TokenStream , Self :: Span , Self :: Symbol > > ,
@@ -654,7 +673,7 @@ impl server::TokenStream for Rustc<'_, '_> {
654673 stream
655674 }
656675
657- fn concat_streams (
676+ fn ts_concat_streams (
658677 & mut self ,
659678 base : Option < Self :: TokenStream > ,
660679 streams : Vec < Self :: TokenStream > ,
@@ -666,24 +685,22 @@ impl server::TokenStream for Rustc<'_, '_> {
666685 stream
667686 }
668687
669- fn into_trees (
688+ fn ts_into_trees (
670689 & mut self ,
671690 stream : Self :: TokenStream ,
672691 ) -> Vec < TokenTree < Self :: TokenStream , Self :: Span , Self :: Symbol > > {
673692 FromInternal :: from_internal ( ( stream, self ) )
674693 }
675- }
676694
677- impl server:: Span for Rustc < ' _ , ' _ > {
678- fn debug ( & mut self , span : Self :: Span ) -> String {
695+ fn span_debug ( & mut self , span : Self :: Span ) -> String {
679696 if self . ecx . ecfg . span_debug {
680697 format ! ( "{span:?}" )
681698 } else {
682699 format ! ( "{:?} bytes({}..{})" , span. ctxt( ) , span. lo( ) . 0 , span. hi( ) . 0 )
683700 }
684701 }
685702
686- fn file ( & mut self , span : Self :: Span ) -> String {
703+ fn span_file ( & mut self , span : Self :: Span ) -> String {
687704 self . psess ( )
688705 . source_map ( )
689706 . lookup_char_pos ( span. lo ( ) )
@@ -693,7 +710,7 @@ impl server::Span for Rustc<'_, '_> {
693710 . to_string ( )
694711 }
695712
696- fn local_file ( & mut self , span : Self :: Span ) -> Option < String > {
713+ fn span_local_file ( & mut self , span : Self :: Span ) -> Option < String > {
697714 self . psess ( )
698715 . source_map ( )
699716 . lookup_char_pos ( span. lo ( ) )
@@ -708,41 +725,41 @@ impl server::Span for Rustc<'_, '_> {
708725 } )
709726 }
710727
711- fn parent ( & mut self , span : Self :: Span ) -> Option < Self :: Span > {
728+ fn span_parent ( & mut self , span : Self :: Span ) -> Option < Self :: Span > {
712729 span. parent_callsite ( )
713730 }
714731
715- fn source ( & mut self , span : Self :: Span ) -> Self :: Span {
732+ fn span_source ( & mut self , span : Self :: Span ) -> Self :: Span {
716733 span. source_callsite ( )
717734 }
718735
719- fn byte_range ( & mut self , span : Self :: Span ) -> Range < usize > {
736+ fn span_byte_range ( & mut self , span : Self :: Span ) -> Range < usize > {
720737 let source_map = self . psess ( ) . source_map ( ) ;
721738
722739 let relative_start_pos = source_map. lookup_byte_offset ( span. lo ( ) ) . pos ;
723740 let relative_end_pos = source_map. lookup_byte_offset ( span. hi ( ) ) . pos ;
724741
725742 Range { start : relative_start_pos. 0 as usize , end : relative_end_pos. 0 as usize }
726743 }
727- fn start ( & mut self , span : Self :: Span ) -> Self :: Span {
744+ fn span_start ( & mut self , span : Self :: Span ) -> Self :: Span {
728745 span. shrink_to_lo ( )
729746 }
730747
731- fn end ( & mut self , span : Self :: Span ) -> Self :: Span {
748+ fn span_end ( & mut self , span : Self :: Span ) -> Self :: Span {
732749 span. shrink_to_hi ( )
733750 }
734751
735- fn line ( & mut self , span : Self :: Span ) -> usize {
752+ fn span_line ( & mut self , span : Self :: Span ) -> usize {
736753 let loc = self . psess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
737754 loc. line
738755 }
739756
740- fn column ( & mut self , span : Self :: Span ) -> usize {
757+ fn span_column ( & mut self , span : Self :: Span ) -> usize {
741758 let loc = self . psess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
742759 loc. col . to_usize ( ) + 1
743760 }
744761
745- fn join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
762+ fn span_join ( & mut self , first : Self :: Span , second : Self :: Span ) -> Option < Self :: Span > {
746763 let self_loc = self . psess ( ) . source_map ( ) . lookup_char_pos ( first. lo ( ) ) ;
747764 let other_loc = self . psess ( ) . source_map ( ) . lookup_char_pos ( second. lo ( ) ) ;
748765
@@ -753,7 +770,7 @@ impl server::Span for Rustc<'_, '_> {
753770 Some ( first. to ( second) )
754771 }
755772
756- fn subspan (
773+ fn span_subspan (
757774 & mut self ,
758775 span : Self :: Span ,
759776 start : Bound < usize > ,
@@ -789,11 +806,11 @@ impl server::Span for Rustc<'_, '_> {
789806 Some ( span. with_lo ( new_lo) . with_hi ( new_hi) )
790807 }
791808
792- fn resolved_at ( & mut self , span : Self :: Span , at : Self :: Span ) -> Self :: Span {
809+ fn span_resolved_at ( & mut self , span : Self :: Span , at : Self :: Span ) -> Self :: Span {
793810 span. with_ctxt ( at. ctxt ( ) )
794811 }
795812
796- fn source_text ( & mut self , span : Self :: Span ) -> Option < String > {
813+ fn span_source_text ( & mut self , span : Self :: Span ) -> Option < String > {
797814 self . psess ( ) . source_map ( ) . span_to_snippet ( span) . ok ( )
798815 }
799816
@@ -821,41 +838,21 @@ impl server::Span for Rustc<'_, '_> {
821838 /// span from the metadata of `my_proc_macro` (which we have access to,
822839 /// since we've loaded `my_proc_macro` from disk in order to execute it).
823840 /// In this way, we have obtained a span pointing into `my_proc_macro`
824- fn save_span ( & mut self , span : Self :: Span ) -> usize {
841+ fn span_save_span ( & mut self , span : Self :: Span ) -> usize {
825842 self . psess ( ) . save_proc_macro_span ( span)
826843 }
827844
828- fn recover_proc_macro_span ( & mut self , id : usize ) -> Self :: Span {
845+ fn span_recover_proc_macro_span ( & mut self , id : usize ) -> Self :: Span {
829846 let ( resolver, krate, def_site) = ( & * self . ecx . resolver , self . krate , self . def_site ) ;
830847 * self . rebased_spans . entry ( id) . or_insert_with ( || {
831848 // FIXME: `SyntaxContext` for spans from proc macro crates is lost during encoding,
832849 // replace it with a def-site context until we are encoding it properly.
833850 resolver. get_proc_macro_quoted_span ( krate, id) . with_ctxt ( def_site. ctxt ( ) )
834851 } )
835852 }
836- }
837853
838- impl server:: Symbol for Rustc < ' _ , ' _ > {
839- fn normalize_and_validate_ident ( & mut self , string : & str ) -> Result < Self :: Symbol , ( ) > {
854+ fn symbol_normalize_and_validate_ident ( & mut self , string : & str ) -> Result < Self :: Symbol , ( ) > {
840855 let sym = nfc_normalize ( string) ;
841856 if rustc_lexer:: is_ident ( sym. as_str ( ) ) { Ok ( sym) } else { Err ( ( ) ) }
842857 }
843858}
844-
845- impl server:: Server for Rustc < ' _ , ' _ > {
846- fn globals ( & mut self ) -> ExpnGlobals < Self :: Span > {
847- ExpnGlobals {
848- def_site : self . def_site ,
849- call_site : self . call_site ,
850- mixed_site : self . mixed_site ,
851- }
852- }
853-
854- fn intern_symbol ( string : & str ) -> Self :: Symbol {
855- Symbol :: intern ( string)
856- }
857-
858- fn with_symbol_string ( symbol : & Self :: Symbol , f : impl FnOnce ( & str ) ) {
859- f ( symbol. as_str ( ) )
860- }
861- }
0 commit comments