From 875d534de48cb4d7a469c62ae29d275353302a42 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 30 Nov 2023 14:30:37 +0800 Subject: [PATCH] ast: Use `{filename}:{row}:{col}` for location output --- nac3ast/src/location.rs | 2 +- nac3core/src/toplevel/test.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nac3ast/src/location.rs b/nac3ast/src/location.rs index 880b824a..2d658d5b 100644 --- a/nac3ast/src/location.rs +++ b/nac3ast/src/location.rs @@ -26,7 +26,7 @@ pub struct Location { impl fmt::Display for Location { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}: line {} column {}", self.file.0, self.row, self.column) + write!(f, "{}:{}:{}", self.file.0, self.row, self.column) } } diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs index 49400711..55507d92 100644 --- a/nac3core/src/toplevel/test.rs +++ b/nac3core/src/toplevel/test.rs @@ -361,7 +361,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s pass "} ], - vec!["application of type vars to generic class is not currently supported (at unknown: line 4 column 24)"]; + vec!["application of type vars to generic class is not currently supported (at unknown:4:24)"]; "err no type var in generic app" )] #[test_case( @@ -417,7 +417,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s def __init__(): pass "}], - vec!["__init__ method must have a `self` parameter (at unknown: line 2 column 5)"]; + vec!["__init__ method must have a `self` parameter (at unknown:2:5)"]; "err no self_1" )] #[test_case( @@ -439,7 +439,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s "} ], - vec!["a class definition can only have at most one base class declaration and one generic declaration (at unknown: line 1 column 24)"]; + vec!["a class definition can only have at most one base class declaration and one generic declaration (at unknown:1:24)"]; "err multiple inheritance" )] #[test_case( @@ -507,7 +507,7 @@ fn test_simple_function_analyze(source: Vec<&str>, tys: Vec<&str>, names: Vec<&s pass "} ], - vec!["duplicate definition of class `A` (at unknown: line 1 column 1)"]; + vec!["duplicate definition of class `A` (at unknown:1:1)"]; "class same name" )] fn test_analyze(source: Vec<&str>, res: Vec<&str>) { -- 2.44.2