Account for character based offsets in proc-macro2
diff --git a/gen/build/Cargo.toml b/gen/build/Cargo.toml
index 98b3497..a5878b9 100644
--- a/gen/build/Cargo.toml
+++ b/gen/build/Cargo.toml
@@ -13,7 +13,7 @@
anyhow = "1.0"
cc = "1.0.49"
codespan-reporting = "0.9"
-proc-macro2 = { version = "1.0.12", features = ["span-locations"] }
+proc-macro2 = { version = "1.0.14", features = ["span-locations"] }
quote = "1.0"
syn = { version = "1.0.20", features = ["full"] }
diff --git a/gen/cmd/Cargo.toml b/gen/cmd/Cargo.toml
index ddf27c5..919d5c8 100644
--- a/gen/cmd/Cargo.toml
+++ b/gen/cmd/Cargo.toml
@@ -16,7 +16,7 @@
[dependencies]
anyhow = "1.0"
codespan-reporting = "0.9"
-proc-macro2 = { version = "1.0.12", features = ["span-locations"] }
+proc-macro2 = { version = "1.0.14", features = ["span-locations"] }
quote = "1.0"
structopt = "0.3"
syn = { version = "1.0.20", features = ["full"] }
diff --git a/gen/src/error.rs b/gen/src/error.rs
index b91c166..51dbbe7 100644
--- a/gen/src/error.rs
+++ b/gen/src/error.rs
@@ -88,17 +88,26 @@
for _ in 1..start.line {
start_offset += source[start_offset..].find('\n').unwrap() + 1;
}
- start_offset += start.column;
+ let start_column = source[start_offset..]
+ .chars()
+ .take(start.column)
+ .map(char::len_utf8)
+ .sum::<usize>();
+ start_offset += start_column;
let mut end_offset = start_offset;
if start.line == end.line {
- end_offset -= start.column;
+ end_offset -= start_column;
} else {
for _ in 0..end.line - start.line {
end_offset += source[end_offset..].find('\n').unwrap() + 1;
}
}
- end_offset += end.column;
+ end_offset += source[end_offset..]
+ .chars()
+ .take(end.column)
+ .map(char::len_utf8)
+ .sum::<usize>();
let mut files = SimpleFiles::new();
let file = files.add(path.to_string_lossy(), source);
diff --git a/third-party/BUCK b/third-party/BUCK
index 9641cd8..cc64883 100644
--- a/third-party/BUCK
+++ b/third-party/BUCK
@@ -83,7 +83,7 @@
rust_library(
name = "proc-macro2",
- srcs = glob(["vendor/proc-macro2-1.0.12/src/**"]),
+ srcs = glob(["vendor/proc-macro2-1.0.14/src/**"]),
visibility = ["PUBLIC"],
features = [
"proc-macro",
diff --git a/third-party/BUILD b/third-party/BUILD
index ec896ec..313481e 100644
--- a/third-party/BUILD
+++ b/third-party/BUILD
@@ -88,7 +88,7 @@
rust_library(
name = "proc-macro2",
- srcs = glob(["vendor/proc-macro2-1.0.12/src/**"]),
+ srcs = glob(["vendor/proc-macro2-1.0.14/src/**"]),
crate_features = [
"proc-macro",
"span-locations",
diff --git a/third-party/Cargo.lock b/third-party/Cargo.lock
index 75cfa84..6e3a5b9 100644
--- a/third-party/Cargo.lock
+++ b/third-party/Cargo.lock
@@ -211,9 +211,9 @@
[[package]]
name = "proc-macro2"
-version = "1.0.12"
+version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8872cf6f48eee44265156c111456a700ab3483686b3f96df4cf5481c89157319"
+checksum = "de40dd4ff82d9c9bab6dae29dbab1167e515f8df9ed17d2987cb6012db206933"
dependencies = [
"unicode-xid",
]