@@ -11,6 +11,7 @@ pub fn full_parsing_error<'i>(
1111 renderer : & impl Render ,
1212) -> String {
1313 let ( problem, details) = generate_error_message ( error, renderer) ;
14+ let input = generate_filename ( filename) ;
1415 let offset = error. offset ( ) ;
1516 let width = error. width ( ) ;
1617
@@ -44,7 +45,7 @@ pub fn full_parsing_error<'i>(
4445{}
4546 "# ,
4647 "error" . bright_red( ) ,
47- filename . to_string_lossy ( ) ,
48+ input ,
4849 line,
4950 column,
5051 problem. bold( ) ,
@@ -71,6 +72,7 @@ pub fn concise_parsing_error<'i>(
7172 renderer : & impl Render ,
7273) -> String {
7374 let ( problem, _) = generate_error_message ( error, renderer) ;
75+ let input = generate_filename ( filename) ;
7476 let offset = error. offset ( ) ;
7577 let i = calculate_line_number ( source, offset) ;
7678 let j = calculate_column_number ( source, offset) ;
@@ -80,7 +82,7 @@ pub fn concise_parsing_error<'i>(
8082 format ! (
8183 "{}: {}:{}:{} {}" ,
8284 "error" . bright_red( ) ,
83- filename . to_string_lossy ( ) ,
85+ input ,
8486 line,
8587 column,
8688 problem. bold( ) ,
@@ -101,6 +103,16 @@ pub fn concise_loading_error<'i>(error: &LoadingError<'i>) -> String {
101103 )
102104}
103105
106+ fn generate_filename ( filename : & Path ) -> String {
107+ if filename. to_str ( ) == Some ( "-" ) {
108+ "<stdin>" . to_string ( )
109+ } else {
110+ filename
111+ . display ( )
112+ . to_string ( )
113+ }
114+ }
115+
104116// Helper functions for line/column calculation
105117pub fn calculate_line_number ( content : & str , offset : usize ) -> usize {
106118 content[ ..offset]
0 commit comments