From c05132fb95de4b64313d72e1f6755ca97c0f7ad7 Mon Sep 17 00:00:00 2001 From: maciektr Date: Wed, 15 Jan 2025 12:56:18 +0100 Subject: [PATCH] Proc macro diagnostics Cairo update (#1881) --- Cargo.lock | 68 +++++++++---------- Cargo.toml | 64 ++++++++--------- scarb/src/compiler/plugin/proc_macro/types.rs | 22 +++--- scarb/tests/proc_macro_expand.rs | 4 +- 4 files changed, 82 insertions(+), 76 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8dfe5173..1ebcf01d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,7 +583,7 @@ dependencies = [ [[package]] name = "cairo-lang-casm" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-utils", "indoc", @@ -596,7 +596,7 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-defs", @@ -621,7 +621,7 @@ dependencies = [ [[package]] name = "cairo-lang-debug" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-utils", ] @@ -629,7 +629,7 @@ dependencies = [ [[package]] name = "cairo-lang-defs" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -645,7 +645,7 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -656,7 +656,7 @@ dependencies = [ [[package]] name = "cairo-lang-doc" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -676,7 +676,7 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-utils", "good_lp", @@ -685,7 +685,7 @@ dependencies = [ [[package]] name = "cairo-lang-executable" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-casm", @@ -709,7 +709,7 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -724,7 +724,7 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -743,7 +743,7 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -823,7 +823,7 @@ checksum = "c49906d6b1c215e5814be7c5c65ecf2328898b335bee8c2409ec07cfb5530daf" [[package]] name = "cairo-lang-parser" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -842,7 +842,7 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -866,12 +866,12 @@ checksum = "123ac0ecadf31bacae77436d72b88fa9caef2b8e92c89ce63a125ae911a12fae" [[package]] name = "cairo-lang-primitive-token" version = "1.0.0" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" [[package]] name = "cairo-lang-proc-macros" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "quote", @@ -881,7 +881,7 @@ dependencies = [ [[package]] name = "cairo-lang-project" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -901,7 +901,7 @@ dependencies = [ [[package]] name = "cairo-lang-runnable-utils" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -918,7 +918,7 @@ dependencies = [ [[package]] name = "cairo-lang-runner" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "ark-ff", "ark-secp256k1", @@ -947,7 +947,7 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -973,7 +973,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-utils", @@ -999,7 +999,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1014,7 +1014,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1029,7 +1029,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1052,7 +1052,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -1072,7 +1072,7 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1081,7 +1081,7 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1110,7 +1110,7 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -1132,11 +1132,11 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", - "cairo-lang-primitive-token 1.0.0 (git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692)", + "cairo-lang-primitive-token 1.0.0 (git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305)", "cairo-lang-utils", "num-bigint", "num-traits 0.2.19", @@ -1148,7 +1148,7 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "genco", "xshell", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1183,7 +1183,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-runner" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -1205,7 +1205,7 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -1217,7 +1217,7 @@ dependencies = [ [[package]] name = "cairo-lang-utils" version = "2.9.2" -source = "git+https://github.com/starkware-libs/cairo?rev=03944ce36c4b37ef954d7f462d23edce8669e692#03944ce36c4b37ef954d7f462d23edce8669e692" +source = "git+https://github.com/starkware-libs/cairo?rev=9ac17df38f28f267e03a6522d12031976a66d305#9ac17df38f28f267e03a6522d12031976a66d305" dependencies = [ "env_logger", "hashbrown 0.14.5", diff --git a/Cargo.toml b/Cargo.toml index ad6e6230d..97f7873c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,38 +165,38 @@ zstd = "0.13" # on some of them directly. # This ensures no duplicate instances of Cairo crates are pulled in by mistake. [patch.crates-io] -cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-doc = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-eq-solver = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-executable = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-parser = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-proc-macros = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-runnable-utils = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-sierra-ap-change = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-sierra-gas = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-sierra-type-size = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-syntax-codegen = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "03944ce36c4b37ef954d7f462d23edce8669e692" } +cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-doc = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-eq-solver = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-executable = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-parser = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-proc-macros = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-runnable-utils = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-sierra-ap-change = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-sierra-gas = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-sierra-type-size = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-syntax-codegen = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } +cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "9ac17df38f28f267e03a6522d12031976a66d305" } cairo-language-server = { git = "https://github.com/software-mansion/cairols", rev = "6432886fea7564816078ed140434addf50bbaa23" } cairo-lint-core = { git = "https://github.com/software-mansion/cairo-lint", rev = "b95a1949b932e89179c052efdbf4e21002ce6777" } diff --git a/scarb/src/compiler/plugin/proc_macro/types.rs b/scarb/src/compiler/plugin/proc_macro/types.rs index ca4090484..f45b63383 100644 --- a/scarb/src/compiler/plugin/proc_macro/types.rs +++ b/scarb/src/compiler/plugin/proc_macro/types.rs @@ -47,11 +47,13 @@ impl<'a> TokenStreamBuilder<'a> { pub fn token_from_syntax_node(&self, node: SyntaxNode, ctx: &AllocationContext) -> Token { let span = node.span(self.db); let text = node.get_text(self.db); - let span = TextSpan { - // We skip the whitespace prefix, so that diagnostics start where the actual token contents is. - start: span.start.as_u32() + whitespace_prefix_len(&text), - end: span.end.as_u32(), - }; + // We skip the whitespace prefix, so that diagnostics start where the actual token contents is. + let start = span.start.as_u32() + whitespace_prefix_len(&text); + // Then we also skip the whitespace suffix, for the same reason. + let end = span.end.as_u32() - whitespace_suffix_len(&text); + // This handles the case of a whitespace only string. + let end = if end < start { start } else { end }; + let span = TextSpan { start, end }; Token::new_in(text, span, ctx) } } @@ -60,6 +62,10 @@ fn whitespace_prefix_len(s: &str) -> u32 { s.chars().take_while(|c| c.is_whitespace()).count() as u32 } +fn whitespace_suffix_len(s: &str) -> u32 { + s.chars().rev().take_while(|c| c.is_whitespace()).count() as u32 +} + #[cfg(test)] mod tests { use crate::compiler::plugin::proc_macro::TokenStreamBuilder; @@ -88,13 +94,13 @@ mod tests { }; let token = token_at(&token_stream, 4); assert_eq!(token.content.as_ref(), "{\n"); - assert_eq!(token.span, TextSpan { start: 10, end: 12 }); + assert_eq!(token.span, TextSpan { start: 10, end: 11 }); let token = token_at(&token_stream, 5); assert_eq!(token.content.as_ref(), " let "); // Note we skip 4 whitespaces characters in the span. - assert_eq!(token.span, TextSpan { start: 16, end: 20 }); + assert_eq!(token.span, TextSpan { start: 16, end: 19 }); let token = token_at(&token_stream, 6); assert_eq!(token.content.as_ref(), "x "); - assert_eq!(token.span, TextSpan { start: 20, end: 22 }); + assert_eq!(token.span, TextSpan { start: 20, end: 21 }); } } diff --git a/scarb/tests/proc_macro_expand.rs b/scarb/tests/proc_macro_expand.rs index 46bad039b..6d69c9e66 100644 --- a/scarb/tests/proc_macro_expand.rs +++ b/scarb/tests/proc_macro_expand.rs @@ -1516,9 +1516,9 @@ fn code_mappings_preserve_attribute_error_locations() { [..] Compiling some v1.0.0 ([..]Scarb.toml) [..] Compiling hello v1.0.0 ([..]Scarb.toml) error: Cannot assign to an immutable variable. - --> [..]lib.cairo[proc_some]:3:5 + --> [..]lib.cairo:4:5 x = 2; - ^^^^^ + ^^^^^^ note: this error originates in the attribute macro: `some` error: could not compile `hello` due to previous error