]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/coherence/mod.rs
Remove interior mutability from TraitDef by turning fields into queries.
[rust.git] / src / librustc_typeck / coherence / mod.rs
index b385ddc49c1ee094432220d0af1472ef610b837b..165be49f7603de1d73ff00a03519187585980996 100644 (file)
 // mappings. That mapping code resides here.
 
 use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
-use rustc::ty::{self, TyCtxt, TypeFoldable};
+use rustc::ty::{TyCtxt, TypeFoldable};
 use rustc::ty::maps::Providers;
 
 use syntax::ast;
-use syntax_pos::DUMMY_SP;
 
 mod builtin;
 mod inherent_impls;
@@ -47,8 +46,6 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
         }
 
         enforce_trait_manually_implementable(tcx, impl_def_id, trait_ref.def_id);
-        let trait_def = tcx.lookup_trait_def(trait_ref.def_id);
-        trait_def.record_local_impl(tcx, impl_def_id, trait_ref);
     }
 }
 
@@ -63,7 +60,7 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d
                          span,
                          E0322,
                          "explicit impls for the `Sized` trait are not permitted")
-            .span_label(span, &format!("impl of 'Sized' not allowed"))
+            .span_label(span, "impl of 'Sized' not allowed")
             .emit();
         return;
     }
@@ -118,8 +115,6 @@ pub fn provide(providers: &mut Providers) {
 
 fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                             (_, def_id): (CrateNum, DefId)) {
-    tcx.populate_implementations_for_trait_if_necessary(def_id);
-
     let impls = tcx.hir.trait_impls(def_id);
     for &impl_id in impls {
         check_impl(tcx, impl_id);
@@ -132,7 +127,7 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
 pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
     for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
-        ty::queries::coherent_trait::get(tcx, DUMMY_SP, (LOCAL_CRATE, trait_def_id));
+        tcx.coherent_trait((LOCAL_CRATE, trait_def_id));
     }
 
     unsafety::check(tcx);
@@ -140,6 +135,6 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
     overlap::check_default_impls(tcx);
 
     // these queries are executed for side-effects (error reporting):
-    ty::queries::crate_inherent_impls::get(tcx, DUMMY_SP, LOCAL_CRATE);
-    ty::queries::crate_inherent_impls_overlap_check::get(tcx, DUMMY_SP, LOCAL_CRATE);
+    tcx.crate_inherent_impls(LOCAL_CRATE);
+    tcx.crate_inherent_impls_overlap_check(LOCAL_CRATE);
 }