@@ -61,38 +61,23 @@ pub struct ItemDiagnostics {
6161impl ItemDiagnostics {
6262 /// Print the diagnostics for a single source item in a compact format
6363 ///
64- /// The writer `f` can be stderr or a file handle, for example. The path to the file containing this source item
65- /// should be provided, as well as the current working directory where the command was launched from. This last
66- /// information is used to compute the relative path when possible.
64+ /// The writer `f` can be stderr or a file handle, for example. The `source_name` should be
65+ /// the display name for the file (typically a relative path from the working directory).
6766 pub fn print_compact (
6867 & self ,
6968 f : & mut impl io:: Write ,
70- path : impl AsRef < Path > ,
71- root_dir : impl AsRef < Path > ,
69+ source_name : & str ,
7270 ) -> std:: result:: Result < ( ) , io:: Error > {
73- fn inner (
74- this : & ItemDiagnostics ,
75- f : & mut impl io:: Write ,
76- path : & Path ,
77- root_dir : & Path ,
78- ) -> std:: result:: Result < ( ) , io:: Error > {
79- let source_name = match path. strip_prefix ( root_dir) {
80- Ok ( relative_path) => relative_path. to_string_lossy ( ) ,
81- Err ( _) => path. to_string_lossy ( ) ,
82- } ;
83- writeln ! ( f, "{source_name}:{}" , this. span. start) ?;
84- if let Some ( parent) = & this. parent {
85- writeln ! ( f, "{} {}.{}" , this. item_type, parent, this. name) ?;
86- } else {
87- writeln ! ( f, "{} {}" , this. item_type, this. name) ?;
88- }
89- for diag in & this. diags {
90- writeln ! ( f, " {}" , diag. message) ?;
91- }
92- writeln ! ( f) ?;
93- Ok ( ( ) )
71+ writeln ! ( f, "{source_name}:{}" , self . span. start) ?;
72+ if let Some ( parent) = & self . parent {
73+ writeln ! ( f, "{} {}.{}" , self . item_type, parent, self . name) ?;
74+ } else {
75+ writeln ! ( f, "{} {}" , self . item_type, self . name) ?;
76+ }
77+ for diag in & self . diags {
78+ writeln ! ( f, " {}" , diag. message) ?;
9479 }
95- inner ( self , f , path . as_ref ( ) , root_dir . as_ref ( ) )
80+ writeln ! ( f )
9681 }
9782}
9883
0 commit comments