diff --git a/Cargo.lock b/Cargo.lock index 7f89f16c1..4d4c1d57b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,7 +563,7 @@ dependencies = [ [[package]] name = "cairo-lang-casm" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-utils", "indoc", @@ -579,7 +579,7 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-lang-defs", @@ -600,7 +600,7 @@ dependencies = [ [[package]] name = "cairo-lang-debug" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-utils", ] @@ -608,7 +608,7 @@ dependencies = [ [[package]] name = "cairo-lang-defs" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -624,7 +624,7 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -635,7 +635,7 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-utils", "good_lp", @@ -644,7 +644,7 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -657,7 +657,7 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -671,12 +671,13 @@ dependencies = [ "salsa", "serde", "smol_str", + "thiserror", ] [[package]] name = "cairo-lang-language-server" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -705,7 +706,7 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -729,7 +730,7 @@ dependencies = [ [[package]] name = "cairo-lang-parser" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -748,7 +749,7 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -766,7 +767,7 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "quote", @@ -776,7 +777,7 @@ dependencies = [ [[package]] name = "cairo-lang-project" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -789,7 +790,7 @@ dependencies = [ [[package]] name = "cairo-lang-runner" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "ark-ff", "ark-secp256k1", @@ -816,7 +817,7 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -840,7 +841,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-lang-utils", @@ -864,7 +865,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -877,7 +878,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -890,7 +891,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -912,7 +913,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "assert_matches", "cairo-felt", @@ -932,7 +933,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -941,7 +942,7 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-felt", @@ -976,7 +977,7 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -991,7 +992,7 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "genco", "xshell", @@ -1000,7 +1001,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-felt", @@ -1026,7 +1027,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "anyhow", "cairo-felt", @@ -1047,7 +1048,7 @@ dependencies = [ [[package]] name = "cairo-lang-utils" version = "2.3.1" -source = "git+https://github.com/starkware-libs/cairo.git?rev=a4e7753f73b9731fe08c50a2f3af2b39e11ae657#a4e7753f73b9731fe08c50a2f3af2b39e11ae657" +source = "git+https://github.com/maciektr/cairo.git?rev=dc55ecd69ffb87a524008e6daa7fec788471e3b5#dc55ecd69ffb87a524008e6daa7fec788471e3b5" dependencies = [ "env_logger", "indexmap 2.1.0", diff --git a/Cargo.toml b/Cargo.toml index cbad884ea..aabcb9e90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,26 +31,26 @@ assert_fs = "1" async-trait = "0.1" axum = { version = "0.6", features = ["http2"] } cairo-felt = "0.9" -cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-language-server = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-project = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo.git", rev = "a4e7753f73b9731fe08c50a2f3af2b39e11ae657", features = ["env_logger"] } +cairo-lang-casm = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-compiler = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-diagnostics = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-debug = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-defs = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-filesystem = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-formatter = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-language-server = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-lowering = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-project = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-runner = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-semantic = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-sierra = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-sierra-generator = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-sierra-to-casm = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-starknet = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-syntax = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-test-plugin = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-test-runner = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5" } +cairo-lang-utils = { git = "https://github.com/maciektr/cairo.git", rev = "dc55ecd69ffb87a524008e6daa7fec788471e3b5", features = ["env_logger"] } camino = { version = "1", features = ["serde1"] } cargo_metadata = ">=0.18" clap = { version = "4", features = ["derive", "env", "string"] } diff --git a/scarb/src/ops/fmt.rs b/scarb/src/ops/fmt.rs index b1d29c650..85085e5cf 100644 --- a/scarb/src/ops/fmt.rs +++ b/scarb/src/ops/fmt.rs @@ -3,6 +3,8 @@ use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use anyhow::Result; +use cairo_lang_diagnostics::Severity; +use cairo_lang_formatter::cairo_formatter::FormattingError; use cairo_lang_formatter::{CairoFormatter, FormatOutcome, FormatterConfig}; use clap::ValueEnum; use ignore::WalkState::{Continue, Skip}; @@ -108,15 +110,25 @@ fn print_diff(ws: &Workspace<'_>, path: &Path, diff: impl Display) { .print(format!("Diff in file {}:\n {}", path.display(), diff)); } -fn print_error(ws: &Workspace<'_>, path: &Path, error: anyhow::Error) { - let error_msg = error.to_string(); - ws.config().ui().error(format!( - "{}Error writing files: cannot parse {}", - // TODO(maciektr): Fix this with proper upstream changes. - // The slice is a hacky way of avoiding duplicated "error: " prefix. - &error_msg[7..], - path.display() - )); +fn print_error(ws: &Workspace<'_>, path: &Path, error: FormattingError) { + match error { + FormattingError::ParsingError(error) => { + for entry in error.iter() { + let msg = entry + .message() + .strip_suffix('\n') + .unwrap_or(entry.message()); + match entry.severity() { + Severity::Error => ws.config().ui().error(msg), + Severity::Warning => ws.config().ui().warn(msg), + }; + } + } + FormattingError::Error(error) => { + let error = error.context(format!("cannot format file {}", path.display())); + ws.config().ui().error(error.to_string()); + } + } } fn check_file_formatting( diff --git a/scarb/tests/fmt.rs b/scarb/tests/fmt.rs index dee0bedb4..40352593a 100644 --- a/scarb/tests/fmt.rs +++ b/scarb/tests/fmt.rs @@ -132,7 +132,6 @@ fn simple_format_with_parsing_error() { fn main() -> { 42 } ^ - Error writing files: cannot parse [..]lib.cairo "#}); }