Skip to content

Statements do not have types. #42489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 9 additions & 30 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ use syntax::feature_gate::{GateIssue, emit_feature_err};
use syntax::ptr::P;
use syntax::symbol::{Symbol, InternedString, keywords};
use syntax::util::lev_distance::find_best_match_for_name;
use syntax_pos::{self, BytePos, Span, DUMMY_SP};
use syntax_pos::{self, BytePos, Span};

use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
Expand Down Expand Up @@ -1901,14 +1901,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
value)
}

pub fn write_nil(&self, node_id: ast::NodeId) {
self.write_ty(node_id, self.tcx.mk_nil());
}

pub fn write_error(&self, node_id: ast::NodeId) {
self.write_ty(node_id, self.tcx.types.err);
}

pub fn require_type_meets(&self,
ty: Ty<'tcx>,
span: Span,
Expand Down Expand Up @@ -4020,11 +4012,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
// Don't do all the complex logic below for DeclItem.
match stmt.node {
hir::StmtDecl(ref decl, id) => {
hir::StmtDecl(ref decl, _) => {
match decl.node {
hir::DeclLocal(_) => {}
hir::DeclItem(_) => {
self.write_nil(id);
return;
}
}
Expand All @@ -4040,34 +4031,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.diverges.set(Diverges::Maybe);
self.has_errors.set(false);

let (node_id, _span) = match stmt.node {
hir::StmtDecl(ref decl, id) => {
let span = match decl.node {
match stmt.node {
hir::StmtDecl(ref decl, _) => {
match decl.node {
hir::DeclLocal(ref l) => {
self.check_decl_local(&l);
l.span
}
hir::DeclItem(_) => {/* ignore for now */
DUMMY_SP
}
};
(id, span)
hir::DeclItem(_) => {/* ignore for now */}
}
}
hir::StmtExpr(ref expr, id) => {
hir::StmtExpr(ref expr, _) => {
// Check with expected type of ()
self.check_expr_has_type(&expr, self.tcx.mk_nil());
(id, expr.span)
}
hir::StmtSemi(ref expr, id) => {
hir::StmtSemi(ref expr, _) => {
self.check_expr(&expr);
(id, expr.span)
}
};

if self.has_errors.get() {
self.write_error(node_id);
} else {
self.write_nil(node_id);
}

// Combine the diverging and has_error flags.
Expand Down
5 changes: 0 additions & 5 deletions src/librustc_typeck/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,6 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
NestedVisitorMap::None
}

fn visit_stmt(&mut self, s: &'gcx hir::Stmt) {
self.visit_node_id(s.span, s.node.id());
intravisit::walk_stmt(self, s);
}

fn visit_expr(&mut self, e: &'gcx hir::Expr) {
self.fix_scalar_builtin_expr(e);

Expand Down