@@ -18,7 +18,7 @@ use crate::translation::{to_fluent_args, Translate};
18
18
use crate :: {
19
19
diagnostic:: DiagnosticLocation , CodeSuggestion , Diagnostic , DiagnosticId , DiagnosticMessage ,
20
20
FluentBundle , Handler , LazyFallbackBundle , Level , MultiSpan , SubDiagnostic ,
21
- SubstitutionHighlight , SuggestionStyle ,
21
+ SubstitutionHighlight , SuggestionStyle , TerminalUrl ,
22
22
} ;
23
23
use rustc_lint_defs:: pluralize;
24
24
@@ -66,6 +66,7 @@ impl HumanReadableErrorType {
66
66
diagnostic_width : Option < usize > ,
67
67
macro_backtrace : bool ,
68
68
track_diagnostics : bool ,
69
+ terminal_url : TerminalUrl ,
69
70
) -> EmitterWriter {
70
71
let ( short, color_config) = self . unzip ( ) ;
71
72
let color = color_config. suggests_using_colors ( ) ;
@@ -80,6 +81,7 @@ impl HumanReadableErrorType {
80
81
diagnostic_width,
81
82
macro_backtrace,
82
83
track_diagnostics,
84
+ terminal_url,
83
85
)
84
86
}
85
87
}
@@ -652,6 +654,7 @@ pub struct EmitterWriter {
652
654
653
655
macro_backtrace : bool ,
654
656
track_diagnostics : bool ,
657
+ terminal_url : TerminalUrl ,
655
658
}
656
659
657
660
#[ derive( Debug ) ]
@@ -672,6 +675,7 @@ impl EmitterWriter {
672
675
diagnostic_width : Option < usize > ,
673
676
macro_backtrace : bool ,
674
677
track_diagnostics : bool ,
678
+ terminal_url : TerminalUrl ,
675
679
) -> EmitterWriter {
676
680
let dst = Destination :: from_stderr ( color_config) ;
677
681
EmitterWriter {
@@ -685,6 +689,7 @@ impl EmitterWriter {
685
689
diagnostic_width,
686
690
macro_backtrace,
687
691
track_diagnostics,
692
+ terminal_url,
688
693
}
689
694
}
690
695
@@ -699,6 +704,7 @@ impl EmitterWriter {
699
704
diagnostic_width : Option < usize > ,
700
705
macro_backtrace : bool ,
701
706
track_diagnostics : bool ,
707
+ terminal_url : TerminalUrl ,
702
708
) -> EmitterWriter {
703
709
EmitterWriter {
704
710
dst : Raw ( dst, colored) ,
@@ -711,6 +717,7 @@ impl EmitterWriter {
711
717
diagnostic_width,
712
718
macro_backtrace,
713
719
track_diagnostics,
720
+ terminal_url,
714
721
}
715
722
}
716
723
@@ -1378,7 +1385,13 @@ impl EmitterWriter {
1378
1385
// only render error codes, not lint codes
1379
1386
if let Some ( DiagnosticId :: Error ( ref code) ) = * code {
1380
1387
buffer. append ( 0 , "[" , Style :: Level ( * level) ) ;
1381
- buffer. append ( 0 , code, Style :: Level ( * level) ) ;
1388
+ let code = if let TerminalUrl :: Yes = self . terminal_url {
1389
+ let path = "https://doc.rust-lang.org/error_codes" ;
1390
+ format ! ( "\x1b ]8;;{path}/{code}.html\x07 {code}\x1b ]8;;\x07 " )
1391
+ } else {
1392
+ code. clone ( )
1393
+ } ;
1394
+ buffer. append ( 0 , & code, Style :: Level ( * level) ) ;
1382
1395
buffer. append ( 0 , "]" , Style :: Level ( * level) ) ;
1383
1396
label_width += 2 + code. len ( ) ;
1384
1397
}
0 commit comments