clean up
This commit is contained in:
parent
ae51953e80
commit
c861e24e72
3 changed files with 15 additions and 16 deletions
|
@ -830,11 +830,11 @@ impl<'hir> Map<'hir> {
|
||||||
Node::ForeignItem(_) |
|
Node::ForeignItem(_) |
|
||||||
Node::TraitItem(_) |
|
Node::TraitItem(_) |
|
||||||
Node::ImplItem(_) => break,
|
Node::ImplItem(_) => break,
|
||||||
Node::Expr(expr) => match expr.node {
|
Node::Expr(expr) => match expr.kind {
|
||||||
ExprKind::Match(_, _, _) => return Some(expr),
|
ExprKind::Match(_, _, _) => return Some(expr),
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
Node::Stmt(stmt) => match stmt.node {
|
Node::Stmt(stmt) => match stmt.kind {
|
||||||
StmtKind::Local(_) => break,
|
StmtKind::Local(_) => break,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
//! we may want to adjust precisely when coercions occur.
|
//! we may want to adjust precisely when coercions occur.
|
||||||
|
|
||||||
use crate::check::{FnCtxt, Needs};
|
use crate::check::{FnCtxt, Needs};
|
||||||
use errors::{Applicability, DiagnosticBuilder};
|
use errors::DiagnosticBuilder;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::hir::ptr::P;
|
use rustc::hir::ptr::P;
|
||||||
|
@ -1311,13 +1311,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||||
pointing_at_return_type,
|
pointing_at_return_type,
|
||||||
) {
|
) {
|
||||||
if match_expr.span.desugaring_kind().is_none() {
|
if match_expr.span.desugaring_kind().is_none() {
|
||||||
err.span_laber(match_expr.span, "expected this to be `()`");
|
err.span_label(match_expr.span, "expected this to be `()`");
|
||||||
err.span_suggestion_short(
|
fcx.suggest_semicolon_at_end(match_expr.span, &mut err);
|
||||||
match_expr.span.shrink_to_hi(),
|
|
||||||
"consider using a semicolon here",
|
|
||||||
";".to_string(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
fcx.get_node_fn_decl(parent).map(|(fn_decl, _, is_main)| (fn_decl, is_main))
|
||||||
|
|
|
@ -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) {
|
pub fn check_stmt(&self, stmt: &'tcx hir::Stmt) {
|
||||||
// Don't do all the complex logic below for `DeclItem`.
|
// Don't do all the complex logic below for `DeclItem`.
|
||||||
match stmt.kind {
|
match stmt.kind {
|
||||||
|
@ -3883,12 +3892,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// Check with expected type of `()`.
|
// Check with expected type of `()`.
|
||||||
|
|
||||||
self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
|
self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit(), |err| {
|
||||||
err.span_suggestion_short(
|
self.suggest_semicolon_at_end(expr.span, err);
|
||||||
expr.span.shrink_to_hi(),
|
|
||||||
"consider using a semicolon here",
|
|
||||||
";".to_string(),
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hir::StmtKind::Semi(ref expr) => {
|
hir::StmtKind::Semi(ref expr) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue