Skip to content

Commit c861e24

Browse files
committed
clean up
1 parent ae51953 commit c861e24

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/librustc/hir/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -830,11 +830,11 @@ impl<'hir> Map<'hir> {
830830
Node::ForeignItem(_) |
831831
Node::TraitItem(_) |
832832
Node::ImplItem(_) => break,
833-
Node::Expr(expr) => match expr.node {
833+
Node::Expr(expr) => match expr.kind {
834834
ExprKind::Match(_, _, _) => return Some(expr),
835835
_ => {}
836836
},
837-
Node::Stmt(stmt) => match stmt.node {
837+
Node::Stmt(stmt) => match stmt.kind {
838838
StmtKind::Local(_) => break,
839839
_ => {}
840840
}

src/librustc_typeck/check/coercion.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//! we may want to adjust precisely when coercions occur.
5252
5353
use crate::check::{FnCtxt, Needs};
54-
use errors::{Applicability, DiagnosticBuilder};
54+
use errors::DiagnosticBuilder;
5555
use rustc::hir;
5656
use rustc::hir::def_id::DefId;
5757
use rustc::hir::ptr::P;
@@ -1311,13 +1311,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
13111311
pointing_at_return_type,
13121312
) {
13131313
if match_expr.span.desugaring_kind().is_none() {
1314-
err.span_laber(match_expr.span, "expected this to be `()`");
1315-
err.span_suggestion_short(
1316-
match_expr.span.shrink_to_hi(),
1317-
"consider using a semicolon here",
1318-
";".to_string(),
1319-
Applicability::MachineApplicable,
1320-
);
1314+
err.span_label(match_expr.span, "expected this to be `()`");
1315+
fcx.suggest_semicolon_at_end(match_expr.span, &mut err);
13211316
}
13221317
}
13231318
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))

src/librustc_typeck/check/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -3858,6 +3858,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
38583858
}
38593859
}
38603860

3861+
fn suggest_semicolon_at_end(&self, span: Span, err: &mut DiagnosticBuilder<'_>) {
3862+
err.span_suggestion_short(
3863+
span.shrink_to_hi(),
3864+
"consider using a semicolon here",
3865+
";".to_string(),
3866+
Applicability::MachineApplicable,
3867+
);
3868+
}
3869+
38613870
pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) {
38623871
// Don't do all the complex logic below for `DeclItem`.
38633872
match stmt.kind {
@@ -3883,12 +3892,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
38833892
// Check with expected type of `()`.
38843893

38853894
self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
3886-
err.span_suggestion_short(
3887-
expr.span.shrink_to_hi(),
3888-
"consider using a semicolon here",
3889-
";".to_string(),
3890-
Applicability::MachineApplicable,
3891-
);
3895+
self.suggest_semicolon_at_end(expr.span, err);
38923896
});
38933897
}
38943898
hir::StmtKind::Semi(ref expr) => {

0 commit comments

Comments
 (0)