about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/session/mod.rs2
-rw-r--r--src/librustc_errors/json.rs (renamed from src/libsyntax/json.rs)16
-rw-r--r--src/librustc_errors/json/tests.rs (renamed from src/libsyntax/json/tests.rs)14
-rw-r--r--src/librustc_errors/lib.rs1
-rw-r--r--src/librustdoc/core.rs2
-rw-r--r--src/libsyntax/lib.rs2
-rw-r--r--src/tools/compiletest/src/json.rs2
7 files changed, 22 insertions, 17 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index a69584cb90a..4fbc8da9cbf 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -22,7 +22,7 @@ use errors::emitter::HumanReadableErrorType;
 use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
 use syntax::edition::Edition;
 use syntax::feature_gate::{self, AttributeType};
-use syntax::json::JsonEmitter;
+use errors::json::JsonEmitter;
 use syntax::source_map;
 use syntax::sess::{ParseSess, ProcessCfgMod};
 use syntax::symbol::Symbol;
diff --git a/src/libsyntax/json.rs b/src/librustc_errors/json.rs
index 6096a930acf..ebbd49bd84a 100644
--- a/src/libsyntax/json.rs
+++ b/src/librustc_errors/json.rs
@@ -9,15 +9,15 @@
 
 // FIXME: spec the JSON output properly.
 
-use crate::source_map::{SourceMap, FilePathMapping};
+use syntax_pos::source_map::{SourceMap, FilePathMapping};
 
-use errors::registry::Registry;
-use errors::{SubDiagnostic, CodeSuggestion};
-use errors::{DiagnosticId, Applicability};
-use errors::emitter::{Emitter, HumanReadableErrorType};
+use crate::registry::Registry;
+use crate::{SubDiagnostic, CodeSuggestion};
+use crate::{DiagnosticId, Applicability};
+use crate::emitter::{Emitter, HumanReadableErrorType};
 
 use syntax_pos::{MacroBacktrace, Span, SpanLabel, MultiSpan};
-use rustc_data_structures::sync::{self, Lrc};
+use rustc_data_structures::sync::Lrc;
 use std::io::{self, Write};
 use std::path::Path;
 use std::vec;
@@ -92,7 +92,7 @@ impl JsonEmitter {
 }
 
 impl Emitter for JsonEmitter {
-    fn emit_diagnostic(&mut self, diag: &errors::Diagnostic) {
+    fn emit_diagnostic(&mut self, diag: &crate::Diagnostic) {
         let data = Diagnostic::from_errors_diagnostic(diag, self);
         let result = if self.pretty {
             writeln!(&mut self.dst, "{}", as_pretty_json(&data))
@@ -212,7 +212,7 @@ struct ArtifactNotification<'a> {
 }
 
 impl Diagnostic {
-    fn from_errors_diagnostic(diag: &errors::Diagnostic,
+    fn from_errors_diagnostic(diag: &crate::Diagnostic,
                                je: &JsonEmitter)
                                -> Diagnostic {
         let sugg = diag.suggestions.iter().map(|sugg| {
diff --git a/src/libsyntax/json/tests.rs b/src/librustc_errors/json/tests.rs
index 1edefd5bc4b..4ab5cd21b0b 100644
--- a/src/libsyntax/json/tests.rs
+++ b/src/librustc_errors/json/tests.rs
@@ -1,11 +1,10 @@
 use super::*;
 
 use crate::json::JsonEmitter;
-use crate::source_map::{FilePathMapping, SourceMap};
-use crate::with_default_globals;
+use syntax_pos::source_map::{FilePathMapping, SourceMap};
 
-use errors::emitter::{ColorConfig, HumanReadableErrorType};
-use errors::Handler;
+use crate::emitter::{ColorConfig, HumanReadableErrorType};
+use crate::Handler;
 use rustc_serialize::json::decode;
 use syntax_pos::{BytePos, Span};
 
@@ -40,6 +39,13 @@ impl<T: Write> Write for Shared<T> {
     }
 }
 
+fn with_default_globals(f: impl FnOnce()) {
+    let globals = syntax_pos::Globals::new(syntax_pos::edition::DEFAULT_EDITION);
+    syntax_pos::GLOBALS.set(&globals, || {
+        syntax_pos::GLOBALS.set(&globals, f)
+    })
+}
+
 /// Test the span yields correct positions in JSON.
 fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
     let expected_output = TestData { spans: vec![expected_output] };
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 1a6ac328a47..17765ef9dee 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -37,6 +37,7 @@ mod snippet;
 pub mod registry;
 mod styled_buffer;
 mod lock;
+pub mod json;
 
 pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a>>;
 
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index a40325448b1..507732a9107 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -18,7 +18,7 @@ use syntax::ast::CRATE_NODE_ID;
 use syntax::source_map;
 use syntax::attr;
 use syntax::feature_gate::UnstableFeatures;
-use syntax::json::JsonEmitter;
+use errors::json::JsonEmitter;
 use syntax::symbol::sym;
 use syntax_pos::DUMMY_SP;
 use errors;
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index a1de0a2c9e4..e3eca75dfe7 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -87,8 +87,6 @@ pub mod util {
     pub mod map_in_place;
 }
 
-pub mod json;
-
 pub mod ast;
 pub mod attr;
 pub mod expand;
diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs
index 02b09e21ff0..7930d1249e7 100644
--- a/src/tools/compiletest/src/json.rs
+++ b/src/tools/compiletest/src/json.rs
@@ -1,4 +1,4 @@
-//! These structs are a subset of the ones found in `syntax::json`.
+//! These structs are a subset of the ones found in `rustc_errors::json`.
 //! They are only used for deserialization of JSON output provided by libtest.
 
 use crate::errors::{Error, ErrorKind};