@@ -6,7 +6,7 @@ use rustc_ast::tokenstream::{self, Spacing::*, TokenStream};
6
6
use rustc_ast_pretty:: pprust;
7
7
use rustc_data_structures:: fx:: FxHashMap ;
8
8
use rustc_data_structures:: sync:: Lrc ;
9
- use rustc_errors:: { Diagnostic , MultiSpan , PResult } ;
9
+ use rustc_errors:: { MultiSpan , PResult } ;
10
10
use rustc_parse:: lexer:: nfc_normalize;
11
11
use rustc_parse:: parse_stream_from_source_str;
12
12
use rustc_session:: parse:: ParseSess ;
@@ -15,7 +15,7 @@ use rustc_span::symbol::{self, sym, Symbol};
15
15
use rustc_span:: { BytePos , FileName , Pos , SourceFile , Span } ;
16
16
17
17
use pm:: bridge:: {
18
- server, DelimSpan , ExpnGlobals , Group , Ident , LitKind , Literal , Punct , TokenTree ,
18
+ server, DelimSpan , Diagnostic , ExpnGlobals , Group , Ident , LitKind , Literal , Punct , TokenTree ,
19
19
} ;
20
20
use pm:: { Delimiter , Level , LineColumn } ;
21
21
use std:: ops:: Bound ;
@@ -368,8 +368,6 @@ impl server::Types for Rustc<'_, '_> {
368
368
type FreeFunctions = FreeFunctions ;
369
369
type TokenStream = TokenStream ;
370
370
type SourceFile = Lrc < SourceFile > ;
371
- type MultiSpan = Vec < Span > ;
372
- type Diagnostic = Diagnostic ;
373
371
type Span = Span ;
374
372
type Symbol = Symbol ;
375
373
}
@@ -436,6 +434,21 @@ impl server::FreeFunctions for Rustc<'_, '_> {
436
434
span : self . call_site ,
437
435
} )
438
436
}
437
+
438
+ fn emit_diagnostic ( & mut self , diagnostic : Diagnostic < Self :: Span > ) {
439
+ let mut diag =
440
+ rustc_errors:: Diagnostic :: new ( diagnostic. level . to_internal ( ) , diagnostic. message ) ;
441
+ diag. set_span ( MultiSpan :: from_spans ( diagnostic. spans ) ) ;
442
+ for child in diagnostic. children {
443
+ diag. sub (
444
+ child. level . to_internal ( ) ,
445
+ child. message ,
446
+ MultiSpan :: from_spans ( child. spans ) ,
447
+ None ,
448
+ ) ;
449
+ }
450
+ self . sess ( ) . span_diagnostic . emit_diagnostic ( & mut diag) ;
451
+ }
439
452
}
440
453
441
454
impl server:: TokenStream for Rustc < ' _ , ' _ > {
@@ -577,38 +590,6 @@ impl server::SourceFile for Rustc<'_, '_> {
577
590
}
578
591
}
579
592
580
- impl server:: MultiSpan for Rustc < ' _ , ' _ > {
581
- fn new ( & mut self ) -> Self :: MultiSpan {
582
- vec ! [ ]
583
- }
584
-
585
- fn push ( & mut self , spans : & mut Self :: MultiSpan , span : Self :: Span ) {
586
- spans. push ( span)
587
- }
588
- }
589
-
590
- impl server:: Diagnostic for Rustc < ' _ , ' _ > {
591
- fn new ( & mut self , level : Level , msg : & str , spans : Self :: MultiSpan ) -> Self :: Diagnostic {
592
- let mut diag = Diagnostic :: new ( level. to_internal ( ) , msg) ;
593
- diag. set_span ( MultiSpan :: from_spans ( spans) ) ;
594
- diag
595
- }
596
-
597
- fn sub (
598
- & mut self ,
599
- diag : & mut Self :: Diagnostic ,
600
- level : Level ,
601
- msg : & str ,
602
- spans : Self :: MultiSpan ,
603
- ) {
604
- diag. sub ( level. to_internal ( ) , msg, MultiSpan :: from_spans ( spans) , None ) ;
605
- }
606
-
607
- fn emit ( & mut self , mut diag : Self :: Diagnostic ) {
608
- self . sess ( ) . span_diagnostic . emit_diagnostic ( & mut diag) ;
609
- }
610
- }
611
-
612
593
impl server:: Span for Rustc < ' _ , ' _ > {
613
594
fn debug ( & mut self , span : Self :: Span ) -> String {
614
595
if self . ecx . ecfg . span_debug {
0 commit comments