]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_typeck/coherence/mod.rs
Various minor/cosmetic improvements to code
[rust.git] / src / librustc_typeck / coherence / mod.rs
index 616ca97a7a75d99e751f000aef43cd8030159b9c..0360617be3c491776b5f3d94245367e74ff6108d 100644 (file)
@@ -29,7 +29,7 @@
 mod unsafety;
 
 fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
-    let impl_def_id = tcx.hir.local_def_id(node_id);
+    let impl_def_id = tcx.hir().local_def_id(node_id);
 
     // If there are no traits, then this implementation must have a
     // base type.
@@ -40,7 +40,7 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
                tcx.item_path_str(impl_def_id));
 
         // Skip impls where one of the self type is an error type.
-        // This occurs with e.g. resolve failures (#30589).
+        // This occurs with e.g., resolve failures (#30589).
         if trait_ref.references_error() {
             return;
         }
@@ -135,7 +135,7 @@ pub fn provide(providers: &mut Providers) {
 }
 
 fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
-    let impls = tcx.hir.trait_impls(def_id);
+    let impls = tcx.hir().trait_impls(def_id);
     for &impl_id in impls {
         check_impl(tcx, impl_id);
     }
@@ -146,7 +146,7 @@ fn coherent_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
 }
 
 pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
-    for &trait_def_id in tcx.hir.krate().trait_impls.keys() {
+    for &trait_def_id in tcx.hir().krate().trait_impls.keys() {
         ty::query::queries::coherent_trait::ensure(tcx, trait_def_id);
     }
 
@@ -162,7 +162,7 @@ pub fn check_coherence<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
 /// same type. Likewise, no two inherent impls for a given type
 /// constructor provide a method with the same name.
 fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
-    let impl_def_id = tcx.hir.local_def_id(node_id);
+    let impl_def_id = tcx.hir().local_def_id(node_id);
     let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
     let trait_def_id = trait_ref.def_id;
 
@@ -181,13 +181,12 @@ fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeI
         // This is something like impl Trait1 for Trait2. Illegal
         // if Trait1 is a supertrait of Trait2 or Trait2 is not object safe.
 
-        if data.principal().map_or(true, |p| !tcx.is_object_safe(p.def_id())) {
+        if !tcx.is_object_safe(data.principal().def_id()) {
             // This is an error, but it will be reported by wfcheck.  Ignore it here.
             // This is tested by `coherence-impl-trait-for-trait-object-safe.rs`.
         } else {
             let mut supertrait_def_ids =
-                traits::supertrait_def_ids(tcx,
-                                           data.principal().unwrap().def_id());
+                traits::supertrait_def_ids(tcx, data.principal().def_id());
             if supertrait_def_ids.any(|d| d == trait_def_id) {
                 let sp = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap());
                 struct_span_err!(tcx.sess,