From 034f69ec4bd4ee59843ead5f40c5b3936a8eab4f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 22 Sep 2014 10:05:49 -0400 Subject: [PATCH] Remove redundant local variable checks. --- src/librustc/diagnostics.rs | 1 - src/librustc/middle/kind.rs | 40 ------------------------------------- 2 files changed, 41 deletions(-) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 9b63a99bd2ac5..6802781207024 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -150,7 +150,6 @@ register_diagnostics!( E0144, E0145, E0146, - E0151, E0152, E0153, E0154, diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 56e65f5defe77..08e640f597a4c 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -15,7 +15,6 @@ use util::ppaux::UserString; use syntax::ast::*; use syntax::codemap::Span; -use syntax::print::pprust::{ident_to_string}; use syntax::visit::Visitor; use syntax::visit; @@ -39,10 +38,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> { fn visit_ty(&mut self, t: &Ty) { check_ty(self, t); } - - fn visit_pat(&mut self, p: &Pat) { - check_pat(self, p); - } } pub fn check_crate(tcx: &ty::ctxt) { @@ -239,38 +234,3 @@ pub fn check_freevar_bounds(cx: &Context, fn_span: Span, sp: Span, ty: ty::t, }); } -// Ensure that `ty` has a statically known size (i.e., it has the `Sized` bound). -fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: String, sp: Span) { - if !ty::type_is_sized(tcx, ty) { - span_err!(tcx.sess, sp, E0151, - "variable `{}` has dynamically sized type `{}`", - name, ty_to_string(tcx, ty)); - } -} - -// Check that any variables in a pattern have types with statically known size. -fn check_pat(cx: &mut Context, pat: &Pat) { - let var_name = match pat.node { - PatWild(PatWildSingle) => Some("_".to_string()), - PatIdent(_, ref path1, _) => Some(ident_to_string(&path1.node).to_string()), - _ => None - }; - - match var_name { - Some(name) => { - let types = cx.tcx.node_types.borrow(); - let ty = types.find(&(pat.id as uint)); - match ty { - Some(ty) => { - debug!("kind: checking sized-ness of variable {}: {}", - name, ty_to_string(cx.tcx, *ty)); - check_sized(cx.tcx, *ty, name, pat.span); - } - None => {} // extern fn args - } - } - None => {} - } - - visit::walk_pat(cx, pat); -}