aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2020-03-18 14:02:01 -0700
committerDavid Tolnay <dtolnay@gmail.com>2020-03-18 15:17:37 -0700
commite2e7bc3c9ed932dfd08a589ab782f591fd8d80b7 (patch)
tree66d74672694967c921bbae90e8292ea501c76267
parent6dfa3b0a7c9471bf23fd51c5e21b25b77d2b81e1 (diff)
downloadcxx-e2e7bc3c9ed932dfd08a589ab782f591fd8d80b7.tar.gz
Update to codespan-reporting 0.9
-rw-r--r--BUCK2
-rw-r--r--BUILD2
-rw-r--r--Cargo.toml3
-rw-r--r--cmd/Cargo.toml3
-rw-r--r--gen/error.rs28
-rw-r--r--third-party/BUCK10
-rw-r--r--third-party/BUILD10
-rw-r--r--third-party/Cargo.lock16
8 files changed, 19 insertions, 55 deletions
diff --git a/BUCK b/BUCK
index 2f80c9b0..4357dd69 100644
--- a/BUCK
+++ b/BUCK
@@ -7,7 +7,6 @@ rust_library(
":macro",
"//third-party:anyhow",
"//third-party:cc",
- "//third-party:codespan",
"//third-party:codespan-reporting",
"//third-party:link-cplusplus",
"//third-party:proc-macro2",
@@ -26,7 +25,6 @@ rust_binary(
},
deps = [
"//third-party:anyhow",
- "//third-party:codespan",
"//third-party:codespan-reporting",
"//third-party:proc-macro2",
"//third-party:quote",
diff --git a/BUILD b/BUILD
index db222037..59ac9fc7 100644
--- a/BUILD
+++ b/BUILD
@@ -10,7 +10,6 @@ rust_library(
":cxxbridge-macro",
"//third-party:anyhow",
"//third-party:cc",
- "//third-party:codespan",
"//third-party:codespan-reporting",
"//third-party:link-cplusplus",
"//third-party:proc-macro2",
@@ -27,7 +26,6 @@ rust_binary(
visibility = ["//visibility:public"],
deps = [
"//third-party:anyhow",
- "//third-party:codespan",
"//third-party:codespan-reporting",
"//third-party:proc-macro2",
"//third-party:quote",
diff --git a/Cargo.toml b/Cargo.toml
index 8432bc70..63a3a94a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,8 +17,7 @@ travis-ci = { repository = "dtolnay/cxx" }
[dependencies]
anyhow = "1.0"
cc = "1.0.49"
-codespan = "0.7"
-codespan-reporting = "0.7"
+codespan-reporting = "0.9"
cxxbridge-macro = { version = "=0.2.0", path = "macro" }
link-cplusplus = "1.0"
proc-macro2 = { version = "1.0", features = ["span-locations"] }
diff --git a/cmd/Cargo.toml b/cmd/Cargo.toml
index 7ee974cd..aef31f62 100644
--- a/cmd/Cargo.toml
+++ b/cmd/Cargo.toml
@@ -16,8 +16,7 @@ travis-ci = { repository = "dtolnay/cxx" }
[dependencies]
anyhow = "1.0"
-codespan = "0.7"
-codespan-reporting = "0.7"
+codespan-reporting = "0.9"
proc-macro2 = { version = "1.0", features = ["span-locations"] }
quote = "1.0"
structopt = "0.3"
diff --git a/gen/error.rs b/gen/error.rs
index b8ac337f..ca78acb0 100644
--- a/gen/error.rs
+++ b/gen/error.rs
@@ -1,8 +1,8 @@
use crate::gen::Error;
use crate::syntax;
use anyhow::anyhow;
-use codespan::{FileId, Files};
use codespan_reporting::diagnostic::{Diagnostic, Label};
+use codespan_reporting::files::SimpleFiles;
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream, WriteColor};
use codespan_reporting::term::{self, Config};
use std::io::Write;
@@ -46,32 +46,30 @@ fn display_syn_error(stderr: &mut dyn WriteColor, path: &Path, source: &str, err
}
end_offset += end.column;
- let mut files = Files::new();
+ let mut files = SimpleFiles::new();
let file = files.add(path.to_string_lossy(), source);
- let range = start_offset as u32..end_offset as u32;
- let diagnostic = diagnose(file, range, error);
+ let diagnostic = diagnose(file, start_offset..end_offset, error);
let config = Config::default();
let _ = term::emit(stderr, &config, &files, &diagnostic);
}
-fn diagnose(file: FileId, range: Range<u32>, error: syn::Error) -> Diagnostic {
+fn diagnose(file: usize, range: Range<usize>, error: syn::Error) -> Diagnostic<usize> {
let message = error.to_string();
let info = syntax::error::ERRORS
.iter()
.find(|e| message.contains(e.msg));
- let mut diagnostic = if let Some(info) = info {
- let label = Label::new(file, range, info.label.unwrap_or(&message));
- let mut diagnostic = Diagnostic::new_error(&message, label);
- if let Some(note) = info.note {
- diagnostic = diagnostic.with_notes(vec![note.to_owned()]);
- }
- diagnostic
+ let mut diagnostic = Diagnostic::error().with_message(&message);
+ let mut label = Label::primary(file, range);
+ if let Some(info) = info {
+ label.message = info.label.map_or(message, str::to_owned);
+ diagnostic.labels.push(label);
+ diagnostic.notes.extend(info.note.map(str::to_owned));
} else {
- let label = Label::new(file, range, &message);
- Diagnostic::new_error(&message, label)
- };
+ label.message = message;
+ diagnostic.labels.push(label);
+ }
diagnostic.code = Some("cxxbridge".to_owned());
diagnostic
}
diff --git a/third-party/BUCK b/third-party/BUCK
index ccb2107d..14f25425 100644
--- a/third-party/BUCK
+++ b/third-party/BUCK
@@ -30,18 +30,10 @@ rust_library(
)
rust_library(
- name = "codespan",
- srcs = glob(["vendor/codespan-0.7.0/src/**"]),
- visibility = ["PUBLIC"],
- deps = [":unicode-segmentation"],
-)
-
-rust_library(
name = "codespan-reporting",
- srcs = glob(["vendor/codespan-reporting-0.7.0/src/**"]),
+ srcs = glob(["vendor/codespan-reporting-0.9.0/src/**"]),
visibility = ["PUBLIC"],
deps = [
- ":codespan",
":termcolor",
":unicode-width",
],
diff --git a/third-party/BUILD b/third-party/BUILD
index ad779fdd..daf9ea14 100644
--- a/third-party/BUILD
+++ b/third-party/BUILD
@@ -35,18 +35,10 @@ rust_library(
)
rust_library(
- name = "codespan",
- srcs = glob(["vendor/codespan-0.7.0/src/**"]),
- visibility = ["//visibility:public"],
- deps = [":unicode-segmentation"],
-)
-
-rust_library(
name = "codespan-reporting",
- srcs = glob(["vendor/codespan-reporting-0.7.0/src/**"]),
+ srcs = glob(["vendor/codespan-reporting-0.9.0/src/**"]),
visibility = ["//visibility:public"],
deps = [
- ":codespan",
":termcolor",
":unicode-width",
],
diff --git a/third-party/Cargo.lock b/third-party/Cargo.lock
index d8c5cb0a..e76c8311 100644
--- a/third-party/Cargo.lock
+++ b/third-party/Cargo.lock
@@ -54,21 +54,11 @@ dependencies = [
]
[[package]]
-name = "codespan"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21094c000d5db8035900662bbfddec754e79f795324254ac0817f36e5ccfc3f5"
-dependencies = [
- "unicode-segmentation",
-]
-
-[[package]]
name = "codespan-reporting"
-version = "0.7.0"
+version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "657b2c99e1f17bc3e5153808d9f704c8ba6171c3fe45e69fde26e2876156938b"
+checksum = "7606d610349258b637bb639f7565bb7ee5fd6114130d2af59d0f39154e92426a"
dependencies = [
- "codespan",
"termcolor",
"unicode-width",
]
@@ -79,7 +69,6 @@ version = "0.2.0"
dependencies = [
"anyhow",
"cc",
- "codespan",
"codespan-reporting",
"cxx-test-suite",
"cxxbridge-macro",
@@ -104,7 +93,6 @@ name = "cxxbridge-cmd"
version = "0.2.0"
dependencies = [
"anyhow",
- "codespan",
"codespan-reporting",
"proc-macro2",
"quote",