about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2019-11-11 22:46:56 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2019-11-14 13:05:42 +0100
commit798e389e578a0199f734c79424fa39e440910979 (patch)
treee4ac66567e6bb0de6e170fe5f3a7de40a533d4e0
parent3816fce76c04b0be2e06ee188b4aad45accf6479 (diff)
downloadrust-798e389e578a0199f734c79424fa39e440910979.tar.gz
rust-798e389e578a0199f734c79424fa39e440910979.zip
Update to use new librustc_error_codes library
-rw-r--r--src/librustc/Cargo.toml2
-rw-r--r--src/librustc/hir/check_attr.rs2
-rw-r--r--src/librustc/hir/lowering.rs2
-rw-r--r--src/librustc/hir/lowering/expr.rs2
-rw-r--r--src/librustc/hir/lowering/item.rs2
-rw-r--r--src/librustc/infer/error_reporting/mod.rs2
-rw-r--r--src/librustc/infer/error_reporting/need_type_info.rs2
-rw-r--r--src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs2
-rw-r--r--src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs2
-rw-r--r--src/librustc/infer/error_reporting/note.rs2
-rw-r--r--src/librustc/infer/opaque_types/mod.rs2
-rw-r--r--src/librustc/lib.rs2
-rw-r--r--src/librustc/lint/context.rs2
-rw-r--r--src/librustc/lint/levels.rs2
-rw-r--r--src/librustc/middle/lang_items.rs2
-rw-r--r--src/librustc/middle/resolve_lifetime.rs2
-rw-r--r--src/librustc/middle/stability.rs3
-rw-r--r--src/librustc/middle/weak_lang_items.rs2
-rw-r--r--src/librustc/mir/interpret/error.rs2
-rw-r--r--src/librustc/traits/error_reporting.rs2
-rw-r--r--src/librustc/traits/on_unimplemented.rs2
-rw-r--r--src/librustc/traits/query/dropck_outlives.rs2
-rw-r--r--src/librustc/traits/specialize/mod.rs2
-rw-r--r--src/librustc/ty/query/plumbing.rs2
-rw-r--r--src/librustc_codegen_ssa/Cargo.toml1
-rw-r--r--src/librustc_codegen_ssa/common.rs2
-rw-r--r--src/librustc_codegen_ssa/lib.rs2
-rw-r--r--src/librustc_codegen_ssa/mir/statement.rs2
-rw-r--r--src/librustc_interface/Cargo.toml1
-rw-r--r--src/librustc_interface/util.rs17
-rw-r--r--src/librustc_lint/Cargo.toml1
-rw-r--r--src/librustc_lint/lib.rs1
-rw-r--r--src/librustc_metadata/Cargo.toml1
-rw-r--r--src/librustc_metadata/creader.rs2
-rw-r--r--src/librustc_metadata/lib.rs2
-rw-r--r--src/librustc_metadata/locator.rs2
-rw-r--r--src/librustc_metadata/native_libs.rs2
-rw-r--r--src/librustc_mir/Cargo.toml1
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs2
-rw-r--r--src/librustc_mir/hair/pattern/check_match.rs2
-rw-r--r--src/librustc_mir/hair/pattern/mod.rs2
-rw-r--r--src/librustc_mir/lib.rs2
-rw-r--r--src/librustc_mir/transform/check_consts/ops.rs2
-rw-r--r--src/librustc_mir/transform/check_unsafety.rs2
-rw-r--r--src/librustc_mir/transform/qualify_consts.rs2
-rw-r--r--src/librustc_mir/util/borrowck_errors.rs2
-rw-r--r--src/librustc_parse/Cargo.toml1
-rw-r--r--src/librustc_parse/lib.rs1
-rw-r--r--src/librustc_parse/parser/diagnostics.rs2
-rw-r--r--src/librustc_parse/parser/mod.rs2
-rw-r--r--src/librustc_parse/parser/ty.rs2
-rw-r--r--src/librustc_passes/Cargo.toml1
-rw-r--r--src/librustc_passes/ast_validation.rs2
-rw-r--r--src/librustc_passes/entry.rs2
-rw-r--r--src/librustc_passes/intrinsicck.rs2
-rw-r--r--src/librustc_passes/lib.rs2
-rw-r--r--src/librustc_passes/loops.rs2
-rw-r--r--src/librustc_plugin/Cargo.toml1
-rw-r--r--src/librustc_plugin/lib.rs1
-rw-r--r--src/librustc_plugin/load.rs2
-rw-r--r--src/librustc_privacy/Cargo.toml1
-rw-r--r--src/librustc_privacy/lib.rs2
-rw-r--r--src/librustc_resolve/Cargo.toml1
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs2
-rw-r--r--src/librustc_resolve/diagnostics.rs2
-rw-r--r--src/librustc_resolve/late.rs2
-rw-r--r--src/librustc_resolve/late/diagnostics.rs2
-rw-r--r--src/librustc_resolve/lib.rs3
-rw-r--r--src/librustc_resolve/resolve_imports.rs2
-rw-r--r--src/librustc_typeck/Cargo.toml1
-rw-r--r--src/librustc_typeck/astconv.rs2
-rw-r--r--src/librustc_typeck/check/autoderef.rs2
-rw-r--r--src/librustc_typeck/check/callee.rs2
-rw-r--r--src/librustc_typeck/check/cast.rs2
-rw-r--r--src/librustc_typeck/check/coercion.rs2
-rw-r--r--src/librustc_typeck/check/compare_method.rs2
-rw-r--r--src/librustc_typeck/check/dropck.rs2
-rw-r--r--src/librustc_typeck/check/expr.rs2
-rw-r--r--src/librustc_typeck/check/intrinsic.rs2
-rw-r--r--src/librustc_typeck/check/method/probe.rs2
-rw-r--r--src/librustc_typeck/check/method/suggest.rs2
-rw-r--r--src/librustc_typeck/check/mod.rs2
-rw-r--r--src/librustc_typeck/check/op.rs2
-rw-r--r--src/librustc_typeck/check/pat.rs2
-rw-r--r--src/librustc_typeck/check/wfcheck.rs2
-rw-r--r--src/librustc_typeck/coherence/builtin.rs2
-rw-r--r--src/librustc_typeck/coherence/inherent_impls.rs2
-rw-r--r--src/librustc_typeck/coherence/inherent_impls_overlap.rs2
-rw-r--r--src/librustc_typeck/coherence/mod.rs2
-rw-r--r--src/librustc_typeck/coherence/orphan.rs2
-rw-r--r--src/librustc_typeck/coherence/unsafety.rs2
-rw-r--r--src/librustc_typeck/collect.rs2
-rw-r--r--src/librustc_typeck/impl_wf_check.rs2
-rw-r--r--src/librustc_typeck/lib.rs4
-rw-r--r--src/librustc_typeck/outlives/test.rs2
-rw-r--r--src/librustc_typeck/structured_errors.rs2
-rw-r--r--src/librustc_typeck/variance/test.rs2
-rw-r--r--src/libsyntax/Cargo.toml1
-rw-r--r--src/libsyntax/attr/builtin.rs2
-rw-r--r--src/libsyntax/diagnostics/macros.rs24
-rw-r--r--src/libsyntax/feature_gate/check.rs3
-rw-r--r--src/libsyntax/lib.rs2
-rw-r--r--src/libsyntax_ext/Cargo.toml1
-rw-r--r--src/libsyntax_ext/asm.rs2
-rw-r--r--src/libsyntax_ext/deriving/default.rs2
-rw-r--r--src/libsyntax_ext/lib.rs2
106 files changed, 179 insertions, 59 deletions
diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml
index bcbe765b850..adf58d6471b 100644
--- a/src/librustc/Cargo.toml
+++ b/src/librustc/Cargo.toml
@@ -40,3 +40,5 @@ byteorder = { version = "1.3" }
 chalk-engine = { version = "0.9.0", default-features=false }
 rustc_fs_util = { path = "../librustc_fs_util" }
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
+measureme = "0.4"
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs
index 96562002aa0..ea1c585176d 100644
--- a/src/librustc/hir/check_attr.rs
+++ b/src/librustc/hir/check_attr.rs
@@ -16,6 +16,8 @@ use std::fmt::{self, Display};
 use syntax::{attr, symbol::sym};
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 #[derive(Copy, Clone, PartialEq)]
 pub(crate) enum MethodKind {
     Trait { body: bool },
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs
index 2c8e14f2add..9c09ce99486 100644
--- a/src/librustc/hir/lowering.rs
+++ b/src/librustc/hir/lowering.rs
@@ -74,6 +74,8 @@ use syntax::visit::{self, Visitor};
 use syntax_pos::hygiene::ExpnId;
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;
 
 pub struct LoweringContext<'a> {
diff --git a/src/librustc/hir/lowering/expr.rs b/src/librustc/hir/lowering/expr.rs
index 62f3eaef244..d5d3ff0db2e 100644
--- a/src/librustc/hir/lowering/expr.rs
+++ b/src/librustc/hir/lowering/expr.rs
@@ -11,6 +11,8 @@ use syntax::ast::*;
 use syntax::source_map::{respan, DesugaringKind, Span, Spanned};
 use syntax::symbol::{sym, Symbol};
 
+use rustc_error_codes::*;
+
 impl LoweringContext<'_> {
     fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> HirVec<hir::Expr> {
         exprs.iter().map(|x| self.lower_expr(x)).collect()
diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs
index aafdd78e3e8..137d21c3580 100644
--- a/src/librustc/hir/lowering/item.rs
+++ b/src/librustc/hir/lowering/item.rs
@@ -23,6 +23,8 @@ use syntax::source_map::{respan, DesugaringKind};
 use syntax::symbol::{kw, sym};
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 pub(super) struct ItemLowerer<'tcx, 'interner> {
     pub(super) lctx: &'tcx mut LoweringContext<'interner>,
 }
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index 38edef50c96..d0f6a8a434d 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -63,6 +63,8 @@ use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
 use std::{cmp, fmt};
 use syntax_pos::{Pos, Span};
 
+use rustc_error_codes::*;
+
 mod note;
 
 mod need_type_info;
diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs
index b89731273f7..32eecdf01a3 100644
--- a/src/librustc/infer/error_reporting/need_type_info.rs
+++ b/src/librustc/infer/error_reporting/need_type_info.rs
@@ -9,6 +9,8 @@ use syntax::source_map::DesugaringKind;
 use syntax_pos::Span;
 use errors::{Applicability, DiagnosticBuilder};
 
+use rustc_error_codes::*;
+
 struct FindLocalByTypeVisitor<'a, 'tcx> {
     infcx: &'a InferCtxt<'a, 'tcx>,
     target_ty: Ty<'tcx>,
diff --git a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs
index 979815fa7f1..d7cba87e6b1 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs
@@ -5,6 +5,8 @@ use crate::infer::error_reporting::nice_region_error::NiceRegionError;
 use crate::infer::error_reporting::nice_region_error::util::AnonymousParamInfo;
 use crate::util::common::ErrorReported;
 
+use rustc_error_codes::*;
+
 impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
     /// Print the error message for lifetime errors when both the concerned regions are anonymous.
     ///
diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
index a9a2c15d7d9..36131849191 100644
--- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
+++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs
@@ -5,6 +5,8 @@ use crate::hir::{FunctionRetTy, TyKind};
 use crate::ty;
 use errors::{Applicability, DiagnosticBuilder};
 
+use rustc_error_codes::*;
+
 impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
     /// When given a `ConcreteFailure` for a function with parameters containing a named region and
     /// an anonymous region, emit an descriptive diagnostic error.
diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs
index 115ffea97bf..c1f840ad678 100644
--- a/src/librustc/infer/error_reporting/note.rs
+++ b/src/librustc/infer/error_reporting/note.rs
@@ -4,6 +4,8 @@ use crate::ty::{self, Region};
 use crate::ty::error::TypeError;
 use errors::DiagnosticBuilder;
 
+use rustc_error_codes::*;
+
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     pub(super) fn note_region_origin(&self,
                                      err: &mut DiagnosticBuilder<'_>,
diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs
index dc54a273ed0..9ed60b1f0c1 100644
--- a/src/librustc/infer/opaque_types/mod.rs
+++ b/src/librustc/infer/opaque_types/mod.rs
@@ -15,6 +15,8 @@ use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::sync::Lrc;
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
 
 /// Information about the opaque types whose values we
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 7dbacfd133f..82994f9170f 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -83,8 +83,6 @@ mod tests;
 #[macro_use]
 mod macros;
 
-pub mod error_codes;
-
 #[macro_use]
 pub mod query;
 
diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs
index dc3bc5fa0ce..2f865f1f8b5 100644
--- a/src/librustc/lint/context.rs
+++ b/src/librustc/lint/context.rs
@@ -40,6 +40,8 @@ use syntax::util::lev_distance::find_best_match_for_name;
 use syntax::visit as ast_visit;
 use syntax_pos::{MultiSpan, Span, symbol::Symbol};
 
+use rustc_error_codes::*;
+
 /// Information about the registered lints.
 ///
 /// This is basically the subset of `Context` that we can
diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs
index e470dbdf323..27bf9649324 100644
--- a/src/librustc/lint/levels.rs
+++ b/src/librustc/lint/levels.rs
@@ -16,6 +16,8 @@ use syntax::print::pprust;
 use syntax::source_map::MultiSpan;
 use syntax::symbol::{Symbol, sym};
 
+use rustc_error_codes::*;
+
 pub struct LintLevelSets {
     list: Vec<LintSet>,
     lint_cap: Level,
diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs
index 41f02a876f5..f6cd9b1c7ec 100644
--- a/src/librustc/middle/lang_items.rs
+++ b/src/librustc/middle/lang_items.rs
@@ -23,6 +23,8 @@ use rustc_macros::HashStable;
 use crate::hir::itemlikevisit::ItemLikeVisitor;
 use crate::hir;
 
+use rustc_error_codes::*;
+
 // The actual lang items defined come at the end of this file in one handy table.
 // So you probably just want to nip down to the end.
 macro_rules! language_item_table {
diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs
index f37d9b2827b..a70fe2be96c 100644
--- a/src/librustc/middle/resolve_lifetime.rs
+++ b/src/librustc/middle/resolve_lifetime.rs
@@ -30,6 +30,8 @@ use syntax_pos::Span;
 use crate::hir::intravisit::{self, NestedVisitorMap, Visitor};
 use crate::hir::{self, GenericParamKind, LifetimeParamKind};
 
+use rustc_error_codes::*;
+
 /// The origin of a named lifetime definition.
 ///
 /// This is used to prevent the usage of in-band lifetimes in `Fn`/`fn` syntax.
diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs
index fabb0a59da8..8f8b4ed98bd 100644
--- a/src/librustc/middle/stability.rs
+++ b/src/librustc/middle/stability.rs
@@ -26,6 +26,9 @@ use std::cmp::Ordering;
 use std::mem::replace;
 use std::num::NonZeroU32;
 
+use rustc_error_codes::*;
+
+
 #[derive(PartialEq, Clone, Copy, Debug)]
 pub enum StabilityLevel {
     Unstable,
diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs
index fa5fa2257db..48c1226232f 100644
--- a/src/librustc/middle/weak_lang_items.rs
+++ b/src/librustc/middle/weak_lang_items.rs
@@ -14,6 +14,8 @@ use crate::hir::intravisit;
 use crate::hir;
 use crate::ty::TyCtxt;
 
+use rustc_error_codes::*;
+
 macro_rules! weak_lang_items {
     ($($name:ident, $item:ident, $sym:ident;)*) => (
 
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index d918b9ee673..5f605756438 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -16,6 +16,8 @@ use syntax::symbol::Symbol;
 
 use std::{fmt, env};
 
+use rustc_error_codes::*;
+
 #[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
 pub enum ErrorHandled {
     /// Already reported a lint or an error for this evaluation.
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs
index f77db962135..82631ce7435 100644
--- a/src/librustc/traits/error_reporting.rs
+++ b/src/librustc/traits/error_reporting.rs
@@ -39,6 +39,8 @@ use syntax::ast;
 use syntax::symbol::{sym, kw};
 use syntax_pos::{DUMMY_SP, Span, ExpnKind, MultiSpan};
 
+use rustc_error_codes::*;
+
 impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
     pub fn report_fulfillment_errors(
         &self,
diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs
index b64e44b6a5a..59aa0810975 100644
--- a/src/librustc/traits/on_unimplemented.rs
+++ b/src/librustc/traits/on_unimplemented.rs
@@ -10,6 +10,8 @@ use syntax::attr;
 use syntax::symbol::{Symbol, kw, sym};
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 #[derive(Clone, Debug)]
 pub struct OnUnimplementedFormatString(Symbol);
 
diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs
index eaf5971e459..9a9c8e9d0d3 100644
--- a/src/librustc/traits/query/dropck_outlives.rs
+++ b/src/librustc/traits/query/dropck_outlives.rs
@@ -6,6 +6,8 @@ use syntax::source_map::Span;
 use crate::ty::subst::GenericArg;
 use crate::ty::{self, Ty, TyCtxt};
 
+use rustc_error_codes::*;
+
 impl<'cx, 'tcx> At<'cx, 'tcx> {
     /// Given a type `ty` of some value being dropped, computes a set
     /// of "kinds" (types, regions) that must be outlive the execution
diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs
index c1c6eb850f5..475037f54ba 100644
--- a/src/librustc/traits/specialize/mod.rs
+++ b/src/librustc/traits/specialize/mod.rs
@@ -24,6 +24,8 @@ use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
 use super::{SelectionContext, FulfillmentContext};
 use super::util::impl_trait_ref_and_oblig;
 
+use rustc_error_codes::*;
+
 /// Information pertinent to an overlapping impl error.
 #[derive(Debug)]
 pub struct OverlapError {
diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs
index 1c15b7d5f35..214de35b6d0 100644
--- a/src/librustc/ty/query/plumbing.rs
+++ b/src/librustc/ty/query/plumbing.rs
@@ -26,6 +26,8 @@ use std::collections::hash_map::Entry;
 use syntax_pos::Span;
 use syntax::source_map::DUMMY_SP;
 
+use rustc_error_codes::*;
+
 pub struct QueryCache<'tcx, D: QueryConfig<'tcx> + ?Sized> {
     pub(super) results: FxHashMap<D::Key, QueryValue<D::Value>>,
     pub(super) active: FxHashMap<D::Key, QueryResult<'tcx>>,
diff --git a/src/librustc_codegen_ssa/Cargo.toml b/src/librustc_codegen_ssa/Cargo.toml
index 2eaae505916..478c3a9084c 100644
--- a/src/librustc_codegen_ssa/Cargo.toml
+++ b/src/librustc_codegen_ssa/Cargo.toml
@@ -31,3 +31,4 @@ rustc_fs_util = { path = "../librustc_fs_util" }
 rustc_incremental = { path = "../librustc_incremental" }
 rustc_index = { path = "../librustc_index" }
 rustc_target = { path = "../librustc_target" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_codegen_ssa/common.rs b/src/librustc_codegen_ssa/common.rs
index ac39ca98476..9bebca93964 100644
--- a/src/librustc_codegen_ssa/common.rs
+++ b/src/librustc_codegen_ssa/common.rs
@@ -12,6 +12,8 @@ use crate::traits::*;
 use rustc::hir;
 use crate::traits::BuilderMethods;
 
+use rustc_error_codes::*;
+
 pub enum IntPredicate {
     IntEQ,
     IntNE,
diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs
index 81e7ef64e97..9784d870b31 100644
--- a/src/librustc_codegen_ssa/lib.rs
+++ b/src/librustc_codegen_ssa/lib.rs
@@ -35,8 +35,6 @@ use rustc::middle::cstore::{LibSource, CrateSource, NativeLibrary};
 use rustc::middle::dependency_format::Dependencies;
 use syntax_pos::symbol::Symbol;
 
-mod error_codes;
-
 pub mod common;
 pub mod traits;
 pub mod mir;
diff --git a/src/librustc_codegen_ssa/mir/statement.rs b/src/librustc_codegen_ssa/mir/statement.rs
index d11601be0b4..0b82edea157 100644
--- a/src/librustc_codegen_ssa/mir/statement.rs
+++ b/src/librustc_codegen_ssa/mir/statement.rs
@@ -6,6 +6,8 @@ use super::LocalRef;
 use super::OperandValue;
 use crate::traits::*;
 
+use rustc_error_codes::*;
+
 impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
     pub fn codegen_statement(
         &mut self,
diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml
index de59882bbdf..b16cfe9efa7 100644
--- a/src/librustc_interface/Cargo.toml
+++ b/src/librustc_interface/Cargo.toml
@@ -34,6 +34,7 @@ rustc_errors = { path = "../librustc_errors" }
 rustc_plugin = { path = "../librustc_plugin", package = "rustc_plugin_impl" }
 rustc_privacy = { path = "../librustc_privacy" }
 rustc_resolve = { path = "../librustc_resolve" }
+rustc_error_codes = { path = "../librustc_error_codes" }
 tempfile = "3.0.5"
 once_cell = "1"
 
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
index 6b9d708cefa..a5653a21b31 100644
--- a/src/librustc_interface/util.rs
+++ b/src/librustc_interface/util.rs
@@ -14,12 +14,8 @@ use rustc_data_structures::thin_vec::ThinVec;
 use rustc_data_structures::fx::{FxHashSet, FxHashMap};
 use rustc_errors::registry::Registry;
 use rustc_metadata::dynamic_lib::DynamicLibrary;
-use rustc_mir;
-use rustc_passes;
-use rustc_plugin;
-use rustc_privacy;
 use rustc_resolve::{self, Resolver};
-use rustc_typeck;
+use rustc_error_codes;
 use std::env;
 use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
 use std::io::{self, Write};
@@ -43,18 +39,9 @@ use std::{thread, panic};
 
 pub fn diagnostics_registry() -> Registry {
     let mut all_errors = Vec::new();
-    all_errors.extend_from_slice(&rustc::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_typeck::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_resolve::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_privacy::error_codes::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_error_codes::DIAGNOSTICS);
     // FIXME: need to figure out a way to get these back in here
     // all_errors.extend_from_slice(get_codegen_backend(sess).diagnostics());
-    all_errors.extend_from_slice(&rustc_metadata::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_parse::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_passes::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_plugin::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&rustc_mir::error_codes::DIAGNOSTICS);
-    all_errors.extend_from_slice(&syntax::error_codes::DIAGNOSTICS);
 
     Registry::new(&all_errors)
 }
diff --git a/src/librustc_lint/Cargo.toml b/src/librustc_lint/Cargo.toml
index a61a314d549..d26d8791f66 100644
--- a/src/librustc_lint/Cargo.toml
+++ b/src/librustc_lint/Cargo.toml
@@ -16,3 +16,4 @@ syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc_data_structures = { path = "../librustc_data_structures" }
 rustc_index = { path = "../librustc_index" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index a1e50018f8a..7e8dc1d1679 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -23,7 +23,6 @@
 extern crate rustc;
 
 mod array_into_iter;
-mod error_codes;
 mod nonstandard_style;
 mod redundant_semicolon;
 pub mod builtin;
diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml
index b1431563f21..b70cc529386 100644
--- a/src/librustc_metadata/Cargo.toml
+++ b/src/librustc_metadata/Cargo.toml
@@ -25,3 +25,4 @@ syntax = { path = "../libsyntax" }
 syntax_expand = { path = "../libsyntax_expand" }
 rustc_parse = { path = "../librustc_parse" }
 syntax_pos = { path = "../libsyntax_pos" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs
index b4dea19d3dc..6dfb2409775 100644
--- a/src/librustc_metadata/creader.rs
+++ b/src/librustc_metadata/creader.rs
@@ -32,6 +32,8 @@ use syntax_pos::{Span, DUMMY_SP};
 use log::{debug, info, log_enabled};
 use proc_macro::bridge::client::ProcMacro;
 
+use rustc_error_codes::*;
+
 crate struct Library {
     pub source: CrateSource,
     pub metadata: MetadataBlob,
diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs
index ac9d78e9a51..35ac7686647 100644
--- a/src/librustc_metadata/lib.rs
+++ b/src/librustc_metadata/lib.rs
@@ -24,8 +24,6 @@ extern crate rustc;
 #[macro_use]
 extern crate rustc_data_structures;
 
-pub mod error_codes;
-
 mod dependency_format;
 mod foreign_modules;
 mod link_args;
diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs
index 88d7595b063..582602138e5 100644
--- a/src/librustc_metadata/locator.rs
+++ b/src/librustc_metadata/locator.rs
@@ -246,6 +246,8 @@ use rustc_data_structures::owning_ref::OwningRef;
 
 use log::{debug, info, warn};
 
+use rustc_error_codes::*;
+
 #[derive(Clone)]
 crate struct CrateMismatch {
     path: PathBuf,
diff --git a/src/librustc_metadata/native_libs.rs b/src/librustc_metadata/native_libs.rs
index c9de66a5c87..e577b238c86 100644
--- a/src/librustc_metadata/native_libs.rs
+++ b/src/librustc_metadata/native_libs.rs
@@ -11,6 +11,8 @@ use syntax::feature_gate::{self, GateIssue};
 use syntax::symbol::{kw, sym, Symbol};
 use syntax::{span_err, struct_span_err};
 
+use rustc_error_codes::*;
+
 crate fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
     let mut collector = Collector {
         tcx,
diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml
index 8c62640353a..daa2617bd9e 100644
--- a/src/librustc_mir/Cargo.toml
+++ b/src/librustc_mir/Cargo.toml
@@ -27,3 +27,4 @@ syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc_apfloat = { path = "../librustc_apfloat" }
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
index cdfbca65e7e..6e9e8abbeff 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -51,6 +51,8 @@ use std::rc::Rc;
 use std::{fmt, iter, mem};
 use syntax_pos::{Span, DUMMY_SP};
 
+use rustc_error_codes::*;
+
 macro_rules! span_mirbug {
     ($context:expr, $elem:expr, $($message:tt)*) => ({
         $crate::borrow_check::nll::type_check::mirbug(
diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs
index ffb3ae44ae1..30586e95acf 100644
--- a/src/librustc_mir/hair/pattern/check_match.rs
+++ b/src/librustc_mir/hair/pattern/check_match.rs
@@ -20,6 +20,8 @@ use std::slice;
 
 use syntax_pos::{MultiSpan, Span};
 
+use rustc_error_codes::*;
+
 crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) {
     let body_id = match tcx.hir().as_local_hir_id(def_id) {
         None => return,
diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs
index 3d97ed6bf9b..92c7178da53 100644
--- a/src/librustc_mir/hair/pattern/mod.rs
+++ b/src/librustc_mir/hair/pattern/mod.rs
@@ -28,6 +28,8 @@ use std::fmt;
 use syntax::ast;
 use syntax_pos::{Span, DUMMY_SP};
 
+use rustc_error_codes::*;
+
 #[derive(Clone, Debug)]
 pub enum PatternError {
     AssocConstInPattern(Span),
diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs
index be3bbf46f1c..6408c896e93 100644
--- a/src/librustc_mir/lib.rs
+++ b/src/librustc_mir/lib.rs
@@ -35,8 +35,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
 #[macro_use] extern crate rustc_data_structures;
 #[macro_use] extern crate syntax;
 
-pub mod error_codes;
-
 mod borrow_check;
 mod build;
 pub mod dataflow;
diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs
index 4b374cff809..303c3984f7c 100644
--- a/src/librustc_mir/transform/check_consts/ops.rs
+++ b/src/librustc_mir/transform/check_consts/ops.rs
@@ -10,6 +10,8 @@ use syntax_pos::{Span, Symbol};
 
 use super::{ConstKind, Item};
 
+use rustc_error_codes::*;
+
 /// An operation that is not *always* allowed in a const context.
 pub trait NonConstOp: std::fmt::Debug {
     /// Whether this operation can be evaluated by miri.
diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs
index e29239a4536..9374109c82e 100644
--- a/src/librustc_mir/transform/check_unsafety.rs
+++ b/src/librustc_mir/transform/check_unsafety.rs
@@ -18,6 +18,8 @@ use std::ops::Bound;
 
 use crate::util;
 
+use rustc_error_codes::*;
+
 pub struct UnsafetyChecker<'a, 'tcx> {
     body: &'a Body<'tcx>,
     const_context: bool,
diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs
index fd30be807b9..185a499bf48 100644
--- a/src/librustc_mir/transform/qualify_consts.rs
+++ b/src/librustc_mir/transform/qualify_consts.rs
@@ -31,6 +31,8 @@ use rustc::hir::HirId;
 use crate::transform::{MirPass, MirSource};
 use crate::transform::check_consts::ops::{self, NonConstOp};
 
+use rustc_error_codes::*;
+
 /// What kind of item we are in.
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 enum Mode {
diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs
index bf01ad1a023..9004b5e7237 100644
--- a/src/librustc_mir/util/borrowck_errors.rs
+++ b/src/librustc_mir/util/borrowck_errors.rs
@@ -2,6 +2,8 @@ use rustc::ty::{self, Ty, TyCtxt};
 use rustc_errors::{DiagnosticBuilder, DiagnosticId};
 use syntax_pos::{MultiSpan, Span};
 
+use rustc_error_codes::*;
+
 impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
     crate fn cannot_move_when_borrowed(
         &self,
diff --git a/src/librustc_parse/Cargo.toml b/src/librustc_parse/Cargo.toml
index 4579f9d472d..a9175487a75 100644
--- a/src/librustc_parse/Cargo.toml
+++ b/src/librustc_parse/Cargo.toml
@@ -19,3 +19,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
 rustc_lexer = { path = "../librustc_lexer" }
 rustc_target = { path = "../librustc_target" }
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_parse/lib.rs b/src/librustc_parse/lib.rs
index 9f507d5319e..3a983404220 100644
--- a/src/librustc_parse/lib.rs
+++ b/src/librustc_parse/lib.rs
@@ -25,7 +25,6 @@ pub mod parser;
 use parser::{Parser, emit_unclosed_delims, make_unclosed_delims_error};
 pub mod lexer;
 pub mod validate_attr;
-pub mod error_codes;
 
 #[derive(Clone)]
 pub struct Directory<'a> {
diff --git a/src/librustc_parse/parser/diagnostics.rs b/src/librustc_parse/parser/diagnostics.rs
index 38eae008537..b477a0d73c0 100644
--- a/src/librustc_parse/parser/diagnostics.rs
+++ b/src/librustc_parse/parser/diagnostics.rs
@@ -18,6 +18,8 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan, SpanSnippetError};
 use log::{debug, trace};
 use std::mem;
 
+use rustc_error_codes::*;
+
 const TURBOFISH: &'static str = "use `::<...>` instead of `<...>` to specify type arguments";
 
 /// Creates a placeholder argument.
diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs
index d5d8604be85..22aa6b80ab7 100644
--- a/src/librustc_parse/parser/mod.rs
+++ b/src/librustc_parse/parser/mod.rs
@@ -37,6 +37,8 @@ use std::borrow::Cow;
 use std::{cmp, mem, slice};
 use std::path::PathBuf;
 
+use rustc_error_codes::*;
+
 bitflags::bitflags! {
     struct Restrictions: u8 {
         const STMT_EXPR         = 1 << 0;
diff --git a/src/librustc_parse/parser/ty.rs b/src/librustc_parse/parser/ty.rs
index fccabee2404..4c7d1006183 100644
--- a/src/librustc_parse/parser/ty.rs
+++ b/src/librustc_parse/parser/ty.rs
@@ -14,6 +14,8 @@ use syntax_pos::symbol::kw;
 
 use errors::{PResult, Applicability, pluralize};
 
+use rustc_error_codes::*;
+
 /// Returns `true` if `IDENT t` can start a type -- `IDENT::a::b`, `IDENT<u8, u8>`,
 /// `IDENT<<u8 as Trait>::AssocTy>`.
 ///
diff --git a/src/librustc_passes/Cargo.toml b/src/librustc_passes/Cargo.toml
index 556189208f1..7a98734bdbe 100644
--- a/src/librustc_passes/Cargo.toml
+++ b/src/librustc_passes/Cargo.toml
@@ -18,3 +18,4 @@ rustc_target = { path = "../librustc_target" }
 syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
 errors = { path = "../librustc_errors", package = "rustc_errors" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs
index ec5572914d8..c48d2c61e65 100644
--- a/src/librustc_passes/ast_validation.rs
+++ b/src/librustc_passes/ast_validation.rs
@@ -23,6 +23,8 @@ use syntax::{span_err, struct_span_err, walk_list};
 use syntax_pos::{Span, MultiSpan};
 use errors::{Applicability, FatalError};
 
+use rustc_error_codes::*;
+
 struct AstValidator<'a> {
     session: &'a Session,
     has_proc_macro_decls: bool,
diff --git a/src/librustc_passes/entry.rs b/src/librustc_passes/entry.rs
index 66004719060..d0cedc08162 100644
--- a/src/librustc_passes/entry.rs
+++ b/src/librustc_passes/entry.rs
@@ -11,6 +11,8 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
 use rustc::ty::TyCtxt;
 use rustc::ty::query::Providers;
 
+use rustc_error_codes::*;
+
 struct EntryContext<'a, 'tcx> {
     session: &'a Session,
 
diff --git a/src/librustc_passes/intrinsicck.rs b/src/librustc_passes/intrinsicck.rs
index 91a7e9f5d7f..96071b721b9 100644
--- a/src/librustc_passes/intrinsicck.rs
+++ b/src/librustc_passes/intrinsicck.rs
@@ -10,6 +10,8 @@ use syntax_pos::{Span, sym};
 use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
 use rustc::hir;
 
+use rustc_error_codes::*;
+
 fn check_mod_intrinsics(tcx: TyCtxt<'_>, module_def_id: DefId) {
     tcx.hir().visit_item_likes_in_module(
         module_def_id,
diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs
index 1cbe6a652af..81f06a14d95 100644
--- a/src/librustc_passes/lib.rs
+++ b/src/librustc_passes/lib.rs
@@ -20,8 +20,6 @@ extern crate syntax;
 
 use rustc::ty::query::Providers;
 
-pub mod error_codes;
-
 pub mod ast_validation;
 mod check_const;
 pub mod hir_stats;
diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs
index 60525ba6b39..6140d0438d8 100644
--- a/src/librustc_passes/loops.rs
+++ b/src/librustc_passes/loops.rs
@@ -12,6 +12,8 @@ use syntax::struct_span_err;
 use syntax_pos::Span;
 use errors::Applicability;
 
+use rustc_error_codes::*;
+
 #[derive(Clone, Copy, Debug, PartialEq)]
 enum Context {
     Normal,
diff --git a/src/librustc_plugin/Cargo.toml b/src/librustc_plugin/Cargo.toml
index e8bf4e7ea8f..c57b32fb2b6 100644
--- a/src/librustc_plugin/Cargo.toml
+++ b/src/librustc_plugin/Cargo.toml
@@ -16,3 +16,4 @@ rustc_metadata = { path = "../librustc_metadata" }
 syntax = { path = "../libsyntax" }
 syntax_expand = { path = "../libsyntax_expand" }
 syntax_pos = { path = "../libsyntax_pos" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs
index 38738e20630..83e9ebeb935 100644
--- a/src/librustc_plugin/lib.rs
+++ b/src/librustc_plugin/lib.rs
@@ -59,7 +59,6 @@
 
 pub use registry::Registry;
 
-pub mod error_codes;
 pub mod registry;
 pub mod load;
 pub mod build;
diff --git a/src/librustc_plugin/load.rs b/src/librustc_plugin/load.rs
index 8ceb56b0fd2..31b3b07c3e1 100644
--- a/src/librustc_plugin/load.rs
+++ b/src/librustc_plugin/load.rs
@@ -14,6 +14,8 @@ use syntax::struct_span_err;
 use syntax::symbol::{Symbol, kw, sym};
 use syntax_pos::{Span, DUMMY_SP};
 
+use rustc_error_codes::*;
+
 /// Pointer to a registrar function.
 pub type PluginRegistrarFun =
     fn(&mut Registry<'_>);
diff --git a/src/librustc_privacy/Cargo.toml b/src/librustc_privacy/Cargo.toml
index 7cf3a5d6dcd..ef974c77aca 100644
--- a/src/librustc_privacy/Cargo.toml
+++ b/src/librustc_privacy/Cargo.toml
@@ -14,4 +14,5 @@ rustc_typeck = { path = "../librustc_typeck" }
 syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc_data_structures = { path = "../librustc_data_structures" }
+rustc_error_codes = { path = "../librustc_error_codes" }
 log = "0.4"
diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs
index 34cdec229af..8c4b4c16510 100644
--- a/src/librustc_privacy/lib.rs
+++ b/src/librustc_privacy/lib.rs
@@ -30,7 +30,7 @@ use syntax_pos::Span;
 use std::{cmp, fmt, mem};
 use std::marker::PhantomData;
 
-pub mod error_codes;
+use rustc_error_codes::*;
 
 ////////////////////////////////////////////////////////////////////////////////
 /// Generic infrastructure used to implement specific visitors below.
diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml
index 33b2bd36b7d..6cce893f8ec 100644
--- a/src/librustc_resolve/Cargo.toml
+++ b/src/librustc_resolve/Cargo.toml
@@ -21,4 +21,5 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc_data_structures = { path = "../librustc_data_structures" }
 rustc_metadata = { path = "../librustc_metadata" }
+rustc_error_codes = { path = "../librustc_error_codes" }
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 0fcac5aab62..fa7c2cdda68 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -46,6 +46,8 @@ use syntax_pos::{Span, DUMMY_SP};
 
 use log::debug;
 
+use rustc_error_codes::*;
+
 type Res = def::Res<NodeId>;
 
 impl<'a> ToNameBinding<'a> for (Module<'a>, ty::Visibility, Span, ExpnId) {
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 771519b86c1..bb13e9ce783 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -23,6 +23,8 @@ use crate::path_names_to_string;
 use crate::{BindingError, CrateLint, HasGenericParams, LegacyScope, Module, ModuleOrUniformRoot};
 use crate::{PathResult, ParentScope, ResolutionError, Resolver, Scope, ScopeSet, Segment};
 
+use rustc_error_codes::*;
+
 type Res = def::Res<ast::NodeId>;
 
 /// A vector of spans and replacements, a message and applicability.
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs
index 3340566a875..24d6331bbd3 100644
--- a/src/librustc_resolve/late.rs
+++ b/src/librustc_resolve/late.rs
@@ -30,6 +30,8 @@ use syntax_pos::Span;
 use std::collections::BTreeSet;
 use std::mem::replace;
 
+use rustc_error_codes::*;
+
 mod diagnostics;
 
 type Res = def::Res<NodeId>;
diff --git a/src/librustc_resolve/late/diagnostics.rs b/src/librustc_resolve/late/diagnostics.rs
index 0b9997386c8..3be033697d2 100644
--- a/src/librustc_resolve/late/diagnostics.rs
+++ b/src/librustc_resolve/late/diagnostics.rs
@@ -18,6 +18,8 @@ use syntax::util::lev_distance::find_best_match_for_name;
 use syntax_pos::hygiene::MacroKind;
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 type Res = def::Res<ast::NodeId>;
 
 /// A field or associated item from self type suggested in case of resolution failure.
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 88c675a6ce5..47e8cf80a05 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -64,9 +64,10 @@ use late::{HasGenericParams, PathSource, Rib, RibKind::*};
 use resolve_imports::{ImportDirective, ImportDirectiveSubclass, NameResolution, ImportResolver};
 use macros::{LegacyBinding, LegacyScope};
 
+use rustc_error_codes::*;
+
 type Res = def::Res<NodeId>;
 
-pub mod error_codes;
 mod diagnostics;
 mod late;
 mod macros;
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index 083b11daaa1..5c8e7909631 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -30,6 +30,8 @@ use syntax::{struct_span_err, unwrap_or};
 use syntax_pos::hygiene::ExpnId;
 use syntax_pos::{MultiSpan, Span};
 
+use rustc_error_codes::*;
+
 use log::*;
 
 use std::cell::Cell;
diff --git a/src/librustc_typeck/Cargo.toml b/src/librustc_typeck/Cargo.toml
index 60a7a2f4598..a78eba7c0b7 100644
--- a/src/librustc_typeck/Cargo.toml
+++ b/src/librustc_typeck/Cargo.toml
@@ -21,3 +21,4 @@ smallvec = { version = "1.0", features = ["union", "may_dangle"] }
 syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
 rustc_index = { path = "../librustc_index" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index ee3ebd691e4..c3bd916b9ce 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -36,6 +36,8 @@ use std::slice;
 
 use rustc_data_structures::fx::FxHashSet;
 
+use rustc_error_codes::*;
+
 #[derive(Debug)]
 pub struct PathSeg(pub DefId, pub usize);
 
diff --git a/src/librustc_typeck/check/autoderef.rs b/src/librustc_typeck/check/autoderef.rs
index ab5cabcaa4f..20c54e8f698 100644
--- a/src/librustc_typeck/check/autoderef.rs
+++ b/src/librustc_typeck/check/autoderef.rs
@@ -12,6 +12,8 @@ use rustc::ty::adjustment::{Adjustment, Adjust, OverloadedDeref};
 use syntax_pos::Span;
 use syntax::ast::Ident;
 
+use rustc_error_codes::*;
+
 use std::iter;
 
 #[derive(Copy, Clone, Debug)]
diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs
index c195e91a52b..1b3af48ea83 100644
--- a/src/librustc_typeck/check/callee.rs
+++ b/src/librustc_typeck/check/callee.rs
@@ -16,6 +16,8 @@ use syntax_pos::Span;
 
 use rustc::hir;
 
+use rustc_error_codes::*;
+
 /// Checks that it is legal to call methods of the trait corresponding
 /// to `trait_id` (this only cares about the trait, not the specific
 /// method that is called).
diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs
index 3245f2cca79..035ece23810 100644
--- a/src/librustc_typeck/check/cast.rs
+++ b/src/librustc_typeck/check/cast.rs
@@ -46,6 +46,8 @@ use syntax::ast;
 use syntax_pos::Span;
 use crate::util::common::ErrorReported;
 
+use rustc_error_codes::*;
+
 /// Reifies a cast check to be checked once we have full type information for
 /// a function context.
 pub struct CastCheck<'tcx> {
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index a105755ca9a..871acb2726a 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -73,6 +73,8 @@ use syntax::symbol::sym;
 use syntax_pos;
 use rustc_target::spec::abi::Abi;
 
+use rustc_error_codes::*;
+
 struct Coerce<'a, 'tcx> {
     fcx: &'a FnCtxt<'a, 'tcx>,
     cause: ObligationCause<'tcx>,
diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs
index 2f0b1c358f0..42414228522 100644
--- a/src/librustc_typeck/check/compare_method.rs
+++ b/src/librustc_typeck/check/compare_method.rs
@@ -14,6 +14,8 @@ use syntax::errors::pluralize;
 
 use super::{Inherited, FnCtxt, potentially_plural_count};
 
+use rustc_error_codes::*;
+
 /// Checks that a method from an impl conforms to the signature of
 /// the same method as declared in the trait.
 ///
diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs
index 0c8df9bad44..fba933ab0ce 100644
--- a/src/librustc_typeck/check/dropck.rs
+++ b/src/librustc_typeck/check/dropck.rs
@@ -12,6 +12,8 @@ use crate::util::common::ErrorReported;
 
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 /// This function confirms that the `Drop` implementation identified by
 /// `drop_impl_did` is not any more specialized than the type it is
 /// attached to (Issue #8142).
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index cfe36b57c2d..0ba56ba5b3a 100644
--- a/src/librustc_typeck/check/expr.rs
+++ b/src/librustc_typeck/check/expr.rs
@@ -42,6 +42,8 @@ use rustc::ty::TypeFoldable;
 use rustc::ty::subst::InternalSubsts;
 use rustc::traits::{self, ObligationCauseCode};
 
+use rustc_error_codes::*;
+
 use std::fmt::Display;
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs
index 84a15c6e4eb..9f034e65b6e 100644
--- a/src/librustc_typeck/check/intrinsic.rs
+++ b/src/librustc_typeck/check/intrinsic.rs
@@ -12,6 +12,8 @@ use syntax::symbol::Symbol;
 
 use rustc::hir;
 
+use rustc_error_codes::*;
+
 use std::iter;
 
 fn equate_intrinsic_type<'tcx>(
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs
index 7ea7dba5a28..9717190045a 100644
--- a/src/librustc_typeck/check/method/probe.rs
+++ b/src/librustc_typeck/check/method/probe.rs
@@ -35,6 +35,8 @@ use std::mem;
 use std::ops::Deref;
 use std::cmp::max;
 
+use rustc_error_codes::*;
+
 use smallvec::{smallvec, SmallVec};
 
 use self::CandidateKind::*;
diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs
index 0b1657c4494..6e37a1a47f0 100644
--- a/src/librustc_typeck/check/method/suggest.rs
+++ b/src/librustc_typeck/check/method/suggest.rs
@@ -18,6 +18,8 @@ use syntax_pos::{Span, FileName};
 use syntax::ast;
 use syntax::util::lev_distance;
 
+use rustc_error_codes::*;
+
 use std::cmp::Ordering;
 
 use super::{MethodError, NoMatchData, CandidateSource};
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 2363dbc5303..41c8fc02662 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -130,6 +130,8 @@ use syntax::source_map::{DUMMY_SP, original_sp};
 use syntax::symbol::{kw, sym, Ident};
 use syntax::util::parser::ExprPrecedence;
 
+use rustc_error_codes::*;
+
 use std::cell::{Cell, RefCell, Ref, RefMut};
 use std::collections::hash_map::Entry;
 use std::cmp;
diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs
index 81a31597905..28db09fe92b 100644
--- a/src/librustc_typeck/check/op.rs
+++ b/src/librustc_typeck/check/op.rs
@@ -11,6 +11,8 @@ use syntax_pos::Span;
 use syntax::ast::Ident;
 use rustc::hir;
 
+use rustc_error_codes::*;
+
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     /// Checks a `a <op>= b`
     pub fn check_binop_assign(
diff --git a/src/librustc_typeck/check/pat.rs b/src/librustc_typeck/check/pat.rs
index 9421dbc2b2c..b2250559506 100644
--- a/src/librustc_typeck/check/pat.rs
+++ b/src/librustc_typeck/check/pat.rs
@@ -14,6 +14,8 @@ use syntax::util::lev_distance::find_best_match_for_name;
 use syntax_pos::Span;
 use syntax_pos::hygiene::DesugaringKind;
 
+use rustc_error_codes::*;
+
 use std::collections::hash_map::Entry::{Occupied, Vacant};
 use std::cmp;
 
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index fd97493b591..a47dd122754 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -18,6 +18,8 @@ use errors::{DiagnosticBuilder, DiagnosticId};
 use rustc::hir::itemlikevisit::ParItemLikeVisitor;
 use rustc::hir;
 
+use rustc_error_codes::*;
+
 /// Helper type of a temporary returned by `.for_item(...)`.
 /// This is necessary because we can't write the following bound:
 ///
diff --git a/src/librustc_typeck/coherence/builtin.rs b/src/librustc_typeck/coherence/builtin.rs
index d613abc4352..d126a96014b 100644
--- a/src/librustc_typeck/coherence/builtin.rs
+++ b/src/librustc_typeck/coherence/builtin.rs
@@ -17,6 +17,8 @@ use rustc::hir::def_id::DefId;
 use hir::Node;
 use rustc::hir::{self, ItemKind};
 
+use rustc_error_codes::*;
+
 pub fn check_trait(tcx: TyCtxt<'_>, trait_def_id: DefId) {
     Checker { tcx, trait_def_id }
         .check(tcx.lang_items().drop_trait(), visit_implementation_of_drop)
diff --git a/src/librustc_typeck/coherence/inherent_impls.rs b/src/librustc_typeck/coherence/inherent_impls.rs
index 5daa8f5d319..1c228396b8c 100644
--- a/src/librustc_typeck/coherence/inherent_impls.rs
+++ b/src/librustc_typeck/coherence/inherent_impls.rs
@@ -15,6 +15,8 @@ use rustc::ty::{self, CrateInherentImpls, TyCtxt};
 use syntax::ast;
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 /// On-demand query: yields a map containing all types mapped to their inherent impls.
 pub fn crate_inherent_impls(
     tcx: TyCtxt<'_>,
diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs
index 0aae8fbe131..39ecfad89bc 100644
--- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs
+++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs
@@ -5,6 +5,8 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
 use rustc::traits::{self, IntercrateMode};
 use rustc::ty::TyCtxt;
 
+use rustc_error_codes::*;
+
 pub fn crate_inherent_impls_overlap_check(tcx: TyCtxt<'_>, crate_num: CrateNum) {
     assert_eq!(crate_num, LOCAL_CRATE);
     let krate = tcx.hir().krate();
diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs
index 8adf4bb94a8..eac8958bc3b 100644
--- a/src/librustc_typeck/coherence/mod.rs
+++ b/src/librustc_typeck/coherence/mod.rs
@@ -12,6 +12,8 @@ use rustc::ty::{self, TyCtxt, TypeFoldable};
 use rustc::ty::query::Providers;
 use rustc::util::common::time;
 
+use rustc_error_codes::*;
+
 mod builtin;
 mod inherent_impls;
 mod inherent_impls_overlap;
diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs
index 88fa09cc936..c5d9ef2030c 100644
--- a/src/librustc_typeck/coherence/orphan.rs
+++ b/src/librustc_typeck/coherence/orphan.rs
@@ -6,6 +6,8 @@ use rustc::ty::{self, TyCtxt};
 use rustc::hir::itemlikevisit::ItemLikeVisitor;
 use rustc::hir;
 
+use rustc_error_codes::*;
+
 pub fn check(tcx: TyCtxt<'_>) {
     let mut orphan = OrphanChecker { tcx };
     tcx.hir().krate().visit_all_item_likes(&mut orphan);
diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs
index b7cc6feee44..5bb44499968 100644
--- a/src/librustc_typeck/coherence/unsafety.rs
+++ b/src/librustc_typeck/coherence/unsafety.rs
@@ -5,6 +5,8 @@ use rustc::ty::TyCtxt;
 use rustc::hir::itemlikevisit::ItemLikeVisitor;
 use rustc::hir::{self, Unsafety};
 
+use rustc_error_codes::*;
+
 pub fn check(tcx: TyCtxt<'_>) {
     let mut unsafety = UnsafetyChecker { tcx };
     tcx.hir().krate().visit_all_item_likes(&mut unsafety);
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index 9c1da65c846..a487f34b1ec 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -48,6 +48,8 @@ use rustc::hir::{self, CodegenFnAttrFlags, CodegenFnAttrs, Unsafety};
 
 use errors::{Applicability, DiagnosticId, StashKey};
 
+use rustc_error_codes::*;
+
 struct OnlySelfBounds(bool);
 
 ///////////////////////////////////////////////////////////////////////////
diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs
index 2d188007712..28fc44dfad5 100644
--- a/src/librustc_typeck/impl_wf_check.rs
+++ b/src/librustc_typeck/impl_wf_check.rs
@@ -19,6 +19,8 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
 
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 /// Checks that all the type/lifetime parameters on an impl also
 /// appear in the trait ref or self type (or are constrained by a
 /// where-clause). These rules are needed to ensure that, given a
diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs
index a5a4cfa2bab..9289f3c7ef3 100644
--- a/src/librustc_typeck/lib.rs
+++ b/src/librustc_typeck/lib.rs
@@ -75,8 +75,6 @@ This API is completely unstable and subject to change.
 
 #[macro_use] extern crate rustc;
 
-pub mod error_codes;
-
 mod astconv;
 mod check;
 mod check_unused;
@@ -106,6 +104,8 @@ use rustc::util;
 use syntax_pos::{DUMMY_SP, Span};
 use util::common::time;
 
+use rustc_error_codes::*;
+
 use std::iter;
 
 use astconv::{AstConv, Bounds};
diff --git a/src/librustc_typeck/outlives/test.rs b/src/librustc_typeck/outlives/test.rs
index 3ae646b3ac7..aa5272fd4e0 100644
--- a/src/librustc_typeck/outlives/test.rs
+++ b/src/librustc_typeck/outlives/test.rs
@@ -3,6 +3,8 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
 use rustc::ty::TyCtxt;
 use syntax::symbol::sym;
 
+use rustc_error_codes::*;
+
 pub fn test_inferred_outlives(tcx: TyCtxt<'_>) {
     tcx.hir()
        .krate()
diff --git a/src/librustc_typeck/structured_errors.rs b/src/librustc_typeck/structured_errors.rs
index 273a36edc56..cedd6e6fdb2 100644
--- a/src/librustc_typeck/structured_errors.rs
+++ b/src/librustc_typeck/structured_errors.rs
@@ -3,6 +3,8 @@ use syntax_pos::Span;
 use errors::{Applicability, DiagnosticId, DiagnosticBuilder};
 use rustc::ty::{Ty, TypeFoldable};
 
+use rustc_error_codes::*;
+
 pub trait StructuredDiagnostic<'tcx> {
     fn session(&self) -> &Session;
 
diff --git a/src/librustc_typeck/variance/test.rs b/src/librustc_typeck/variance/test.rs
index 9f6266b316f..a7fadb5459e 100644
--- a/src/librustc_typeck/variance/test.rs
+++ b/src/librustc_typeck/variance/test.rs
@@ -3,6 +3,8 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
 use rustc::ty::TyCtxt;
 use syntax::symbol::sym;
 
+use rustc_error_codes::*;
+
 pub fn test_variance(tcx: TyCtxt<'_>) {
     tcx.hir().krate().visit_all_item_likes(&mut VarianceTest { tcx });
 }
diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml
index 3e17e7949ea..d96b5b7a3dd 100644
--- a/src/libsyntax/Cargo.toml
+++ b/src/libsyntax/Cargo.toml
@@ -21,3 +21,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
 rustc_index = { path = "../librustc_index" }
 rustc_lexer = { path = "../librustc_lexer" }
 smallvec = { version = "1.0", features = ["union", "may_dangle"] }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/libsyntax/attr/builtin.rs b/src/libsyntax/attr/builtin.rs
index 2b759c205f5..acf0dd1cabb 100644
--- a/src/libsyntax/attr/builtin.rs
+++ b/src/libsyntax/attr/builtin.rs
@@ -12,6 +12,8 @@ use syntax_pos::{symbol::Symbol, symbol::sym, Span};
 
 use super::{mark_used, MetaItemKind};
 
+use rustc_error_codes::*;
+
 enum AttrError {
     MultipleItem(String),
     UnknownMetaItem(String, &'static [&'static str]),
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index c95c5bd5d02..6679b4459a0 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -1,7 +1,7 @@
 #[macro_export]
 macro_rules! diagnostic_used {
     ($code:ident) => (
-        let _ = crate::error_codes::$code;
+        let _ = $code;
     )
 }
 
@@ -167,25 +167,3 @@ macro_rules! help {
         ($err).help(&format!($($message)*));
     })
 }
-
-#[macro_export]
-macro_rules! register_diagnostics {
-    ($($ecode:ident: $message:expr,)*) => (
-        $crate::register_diagnostics!{$($ecode:$message,)* ;}
-    );
-
-    ($($ecode:ident: $message:expr,)* ; $($code:ident,)*) => (
-        pub static DIAGNOSTICS: &[(&str, &str)] = &[
-            $( (stringify!($ecode), $message), )*
-        ];
-
-        $(
-            #[deny(unused)]
-            pub(crate) const $ecode: &str = $message;
-        )*
-        $(
-            #[deny(unused)]
-            pub(crate) const $code: () = ();
-        )*
-    )
-}
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs
index 3bf1e24bf12..d95dac9bf52 100644
--- a/src/libsyntax/feature_gate/check.rs
+++ b/src/libsyntax/feature_gate/check.rs
@@ -17,6 +17,9 @@ use rustc_data_structures::fx::FxHashMap;
 use syntax_pos::{Span, DUMMY_SP, MultiSpan};
 use log::debug;
 
+use rustc_error_codes::*;
+
+
 use std::env;
 use std::num::NonZeroU32;
 
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs
index 317fcf29389..6290b2137ea 100644
--- a/src/libsyntax/lib.rs
+++ b/src/libsyntax/lib.rs
@@ -77,8 +77,6 @@ pub mod diagnostics {
     pub mod macros;
 }
 
-pub mod error_codes;
-
 pub mod util {
     pub mod classify;
     pub mod comments;
diff --git a/src/libsyntax_ext/Cargo.toml b/src/libsyntax_ext/Cargo.toml
index 5ae8b3a3e0c..2ebdac8ef7c 100644
--- a/src/libsyntax_ext/Cargo.toml
+++ b/src/libsyntax_ext/Cargo.toml
@@ -20,3 +20,4 @@ smallvec = { version = "1.0", features = ["union", "may_dangle"] }
 syntax = { path = "../libsyntax" }
 syntax_expand = { path = "../libsyntax_expand" }
 syntax_pos = { path = "../libsyntax_pos" }
+rustc_error_codes = { path = "../librustc_error_codes" }
diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs
index 539d777105d..5fab101957a 100644
--- a/src/libsyntax_ext/asm.rs
+++ b/src/libsyntax_ext/asm.rs
@@ -16,6 +16,8 @@ use syntax_pos::Span;
 use syntax::tokenstream::{self, TokenStream};
 use syntax::{span_err, struct_span_err};
 
+use rustc_error_codes::*;
+
 enum State {
     Asm,
     Outputs,
diff --git a/src/libsyntax_ext/deriving/default.rs b/src/libsyntax_ext/deriving/default.rs
index cfc0f3cd6cb..ab57f395f6a 100644
--- a/src/libsyntax_ext/deriving/default.rs
+++ b/src/libsyntax_ext/deriving/default.rs
@@ -9,6 +9,8 @@ use syntax::symbol::{kw, sym};
 use syntax::span_err;
 use syntax_pos::Span;
 
+use rustc_error_codes::*;
+
 pub fn expand_deriving_default(cx: &mut ExtCtxt<'_>,
                                span: Span,
                                mitem: &MetaItem,
diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs
index 5516f276422..07fdec05046 100644
--- a/src/libsyntax_ext/lib.rs
+++ b/src/libsyntax_ext/lib.rs
@@ -19,8 +19,6 @@ use syntax::symbol::sym;
 use syntax_expand::base::{Resolver, SyntaxExtension, SyntaxExtensionKind, MacroExpanderFn};
 use syntax_expand::proc_macro::BangProcMacro;
 
-mod error_codes;
-
 mod asm;
 mod assert;
 mod cfg;