about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-09-27 18:42:30 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-09-28 09:56:28 -0700
commitc861e24e7251fcbf0cbb8b85c676afe6b901f8af (patch)
tree356e89555f13f2be614c00e9c5e2288c1df340a2 /src
parentae51953e8034a8f02a12c32a839f9be74cc0ca1c (diff)
downloadrust-c861e24e7251fcbf0cbb8b85c676afe6b901f8af.tar.gz
rust-c861e24e7251fcbf0cbb8b85c676afe6b901f8af.zip
clean up
Diffstat (limited to 'src')
-rw-r--r--src/librustc/hir/map/mod.rs4
-rw-r--r--src/librustc_typeck/check/coercion.rs11
-rw-r--r--src/librustc_typeck/check/mod.rs16
3 files changed, 15 insertions, 16 deletions
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index ce09ea8a5d6..a1011697ef1 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -830,11 +830,11 @@ impl<'hir> Map<'hir> {
                 Node::ForeignItem(_) |
                 Node::TraitItem(_) |
                 Node::ImplItem(_) => break,
-                Node::Expr(expr) => match expr.node {
+                Node::Expr(expr) => match expr.kind {
                     ExprKind::Match(_, _, _) => return Some(expr),
                     _ => {}
                 },
-                Node::Stmt(stmt) => match stmt.node {
+                Node::Stmt(stmt) => match stmt.kind {
                     StmtKind::Local(_) => break,
                     _ => {}
                 }
diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs
index 1c7b765b746..56962d53a64 100644
--- a/src/librustc_typeck/check/coercion.rs
+++ b/src/librustc_typeck/check/coercion.rs
@@ -51,7 +51,7 @@
 //! we may want to adjust precisely when coercions occur.
 
 use crate::check::{FnCtxt, Needs};
-use errors::{Applicability, DiagnosticBuilder};
+use errors::DiagnosticBuilder;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc::hir::ptr::P;
@@ -1311,13 +1311,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
                 pointing_at_return_type,
             ) {
                 if match_expr.span.desugaring_kind().is_none() {
-                    err.span_laber(match_expr.span, "expected this to be `()`");
-                    err.span_suggestion_short(
-                        match_expr.span.shrink_to_hi(),
-                        "consider using a semicolon here",
-                        ";".to_string(),
-                        Applicability::MachineApplicable,
-                    );
+                    err.span_label(match_expr.span, "expected this to be `()`");
+                    fcx.suggest_semicolon_at_end(match_expr.span, &mut err);
                 }
             }
             fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 610f32cc8f8..7560a72c890 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3858,6 +3858,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         }
     }
 
+    fn suggest_semicolon_at_end(&self, span: Span, err: &mut DiagnosticBuilder<'_>) {
+        err.span_suggestion_short(
+            span.shrink_to_hi(),
+            "consider using a semicolon here",
+            ";".to_string(),
+            Applicability::MachineApplicable,
+        );
+    }
+
     pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) {
         // Don't do all the complex logic below for `DeclItem`.
         match stmt.kind {
@@ -3883,12 +3892,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 // Check with expected type of `()`.
 
                 self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
-                    err.span_suggestion_short(
-                        expr.span.shrink_to_hi(),
-                        "consider using a semicolon here",
-                        ";".to_string(),
-                        Applicability::MachineApplicable,
-                    );
+                    self.suggest_semicolon_at_end(expr.span, err);
                 });
             }
             hir::StmtKind::Semi(ref expr) => {