Skip to content

Commit c799b37

Browse files
committed
Auto merge of #42489 - eddyb:untyped-stmts, r=nikomatsakis
Statements do not have types. Past refactors accidentally left in some dead type-checking code - nothing reads the always-`()` types. r? @nikomatsakis
2 parents f09576c + c1c2cd2 commit c799b37

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

src/librustc_typeck/check/mod.rs

+9-30
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ use syntax::feature_gate::{GateIssue, emit_feature_err};
120120
use syntax::ptr::P;
121121
use syntax::symbol::{Symbol, InternedString, keywords};
122122
use syntax::util::lev_distance::find_best_match_for_name;
123-
use syntax_pos::{self, BytePos, Span, DUMMY_SP};
123+
use syntax_pos::{self, BytePos, Span};
124124

125125
use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
126126
use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -1901,14 +1901,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
19011901
value)
19021902
}
19031903

1904-
pub fn write_nil(&self, node_id: ast::NodeId) {
1905-
self.write_ty(node_id, self.tcx.mk_nil());
1906-
}
1907-
1908-
pub fn write_error(&self, node_id: ast::NodeId) {
1909-
self.write_ty(node_id, self.tcx.types.err);
1910-
}
1911-
19121904
pub fn require_type_meets(&self,
19131905
ty: Ty<'tcx>,
19141906
span: Span,
@@ -4020,11 +4012,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
40204012
pub fn check_stmt(&self, stmt: &'gcx hir::Stmt) {
40214013
// Don't do all the complex logic below for DeclItem.
40224014
match stmt.node {
4023-
hir::StmtDecl(ref decl, id) => {
4015+
hir::StmtDecl(ref decl, _) => {
40244016
match decl.node {
40254017
hir::DeclLocal(_) => {}
40264018
hir::DeclItem(_) => {
4027-
self.write_nil(id);
40284019
return;
40294020
}
40304021
}
@@ -4040,34 +4031,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
40404031
self.diverges.set(Diverges::Maybe);
40414032
self.has_errors.set(false);
40424033

4043-
let (node_id, _span) = match stmt.node {
4044-
hir::StmtDecl(ref decl, id) => {
4045-
let span = match decl.node {
4034+
match stmt.node {
4035+
hir::StmtDecl(ref decl, _) => {
4036+
match decl.node {
40464037
hir::DeclLocal(ref l) => {
40474038
self.check_decl_local(&l);
4048-
l.span
40494039
}
4050-
hir::DeclItem(_) => {/* ignore for now */
4051-
DUMMY_SP
4052-
}
4053-
};
4054-
(id, span)
4040+
hir::DeclItem(_) => {/* ignore for now */}
4041+
}
40554042
}
4056-
hir::StmtExpr(ref expr, id) => {
4043+
hir::StmtExpr(ref expr, _) => {
40574044
// Check with expected type of ()
40584045
self.check_expr_has_type(&expr, self.tcx.mk_nil());
4059-
(id, expr.span)
40604046
}
4061-
hir::StmtSemi(ref expr, id) => {
4047+
hir::StmtSemi(ref expr, _) => {
40624048
self.check_expr(&expr);
4063-
(id, expr.span)
40644049
}
4065-
};
4066-
4067-
if self.has_errors.get() {
4068-
self.write_error(node_id);
4069-
} else {
4070-
self.write_nil(node_id);
40714050
}
40724051

40734052
// Combine the diverging and has_error flags.

src/librustc_typeck/check/writeback.rs

-5
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> {
155155
NestedVisitorMap::None
156156
}
157157

158-
fn visit_stmt(&mut self, s: &'gcx hir::Stmt) {
159-
self.visit_node_id(s.span, s.node.id());
160-
intravisit::walk_stmt(self, s);
161-
}
162-
163158
fn visit_expr(&mut self, e: &'gcx hir::Expr) {
164159
self.fix_scalar_builtin_expr(e);
165160

0 commit comments

Comments
 (0)