From fd52224e78fe14828f8750fed469cc5c40f260e7 Mon Sep 17 00:00:00 2001 From: Jakub Wieczorek Date: Sat, 20 Sep 2014 15:20:54 +0200 Subject: [PATCH] Remove dead code from librustc --- src/librustc/back/link.rs | 7 -- src/librustc/diagnostics.rs | 2 - src/librustc/middle/astencode.rs | 73 ---------------- src/librustc/middle/borrowck/mod.rs | 82 ----------------- src/librustc/middle/borrowck/move_data.rs | 23 ----- src/librustc/middle/kind.rs | 11 --- src/librustc/middle/mem_categorization.rs | 4 - src/librustc/middle/subst.rs | 52 ----------- src/librustc/middle/trans/monomorphize.rs | 30 ------- src/librustc/middle/ty.rs | 86 ------------------ src/librustc/middle/typeck/check/demand.rs | 14 --- src/librustc/middle/typeck/check/mod.rs | 87 ------------------- src/librustc/middle/typeck/check/regionck.rs | 20 ----- src/librustc/middle/typeck/check/vtable2.rs | 11 --- src/librustc/middle/typeck/check/writeback.rs | 17 +--- src/librustc/middle/typeck/infer/mod.rs | 6 -- .../typeck/infer/region_inference/mod.rs | 11 --- src/librustc/util/ppaux.rs | 9 -- 18 files changed, 1 insertion(+), 544 deletions(-) diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index e6e9448fa563e..633248562a553 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -397,13 +397,6 @@ pub fn get_cc_prog(sess: &Session) -> String { }.to_string() } -pub fn get_ar_prog(sess: &Session) -> String { - match sess.opts.cg.ar { - Some(ref ar) => (*ar).clone(), - None => "ar".to_string() - } -} - pub fn remove(sess: &Session, path: &Path) { match fs::unlink(path) { Ok(..) => {} diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 14cf07cd5e47f..20842beae16d5 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -114,7 +114,6 @@ register_diagnostics!( E0102, E0103, E0104, - E0105, E0106, E0107, E0108, @@ -152,7 +151,6 @@ register_diagnostics!( E0144, E0145, E0146, - E0147, E0148, E0151, E0152, diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index acb4f1be85ca2..f40d6d47281c1 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -662,30 +662,6 @@ impl tr for MethodOrigin { } } -// ______________________________________________________________________ -// Encoding and decoding vtable_res - -pub fn encode_vtable_res(ecx: &e::EncodeContext, - rbml_w: &mut Encoder, - dr: &typeck::vtable_res) { - // can't autogenerate this code because automatic code of - // ty::t doesn't work, and there is no way (atm) to have - // hand-written encoding routines combine with auto-generated - // ones. perhaps we should fix this. - encode_vec_per_param_space( - rbml_w, dr, - |rbml_w, param_tables| encode_vtable_param_res(ecx, rbml_w, - param_tables)) -} - -pub fn encode_vtable_param_res(ecx: &e::EncodeContext, - rbml_w: &mut Encoder, - param_tables: &typeck::vtable_param_res) { - rbml_w.emit_from_vec(param_tables.as_slice(), |rbml_w, vtable_origin| { - Ok(encode_vtable_origin(ecx, rbml_w, vtable_origin)) - }).unwrap() -} - pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder, kind: ty::UnboxedClosureKind) { use serialize::Encoder; @@ -714,55 +690,6 @@ pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder, }).unwrap() } -pub fn encode_vtable_origin(ecx: &e::EncodeContext, - rbml_w: &mut Encoder, - vtable_origin: &typeck::vtable_origin) { - use serialize::Encoder; - - rbml_w.emit_enum("vtable_origin", |rbml_w| { - match *vtable_origin { - typeck::vtable_static(def_id, ref substs, ref vtable_res) => { - rbml_w.emit_enum_variant("vtable_static", 0u, 3u, |rbml_w| { - rbml_w.emit_enum_variant_arg(0u, |rbml_w| { - Ok(rbml_w.emit_def_id(def_id)) - }); - rbml_w.emit_enum_variant_arg(1u, |rbml_w| { - Ok(rbml_w.emit_substs(ecx, substs)) - }); - rbml_w.emit_enum_variant_arg(2u, |rbml_w| { - Ok(encode_vtable_res(ecx, rbml_w, vtable_res)) - }) - }) - } - typeck::vtable_param(pn, bn) => { - rbml_w.emit_enum_variant("vtable_param", 1u, 3u, |rbml_w| { - rbml_w.emit_enum_variant_arg(0u, |rbml_w| { - pn.encode(rbml_w) - }); - rbml_w.emit_enum_variant_arg(1u, |rbml_w| { - rbml_w.emit_uint(bn) - }) - }) - } - typeck::vtable_unboxed_closure(def_id) => { - rbml_w.emit_enum_variant("vtable_unboxed_closure", - 2u, - 1u, - |rbml_w| { - rbml_w.emit_enum_variant_arg(0u, |rbml_w| { - Ok(rbml_w.emit_def_id(def_id)) - }) - }) - } - typeck::vtable_error => { - rbml_w.emit_enum_variant("vtable_error", 3u, 3u, |_rbml_w| { - Ok(()) - }) - } - } - }).unwrap() -} - pub trait vtable_decoder_helpers { fn read_vec_per_param_space(&mut self, f: |&mut Self| -> T) diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 4f18d00070ad6..d3d6e7508f077 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -16,7 +16,6 @@ use middle::cfg; use middle::dataflow::DataFlowContext; use middle::dataflow::BitwiseOperator; use middle::dataflow::DataFlowOperator; -use middle::def; use middle::expr_use_visitor as euv; use middle::mem_categorization as mc; use middle::ty; @@ -386,11 +385,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { self.tcx.region_maps.is_subregion_of(r_sub, r_sup) } - pub fn is_subscope_of(&self, r_sub: ast::NodeId, r_sup: ast::NodeId) - -> bool { - self.tcx.region_maps.is_subscope_of(r_sub, r_sup) - } - pub fn mc(&self) -> mc::MemCategorizationContext<'a, ty::ctxt<'tcx>> { mc::MemCategorizationContext::new(self.tcx) } @@ -404,82 +398,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } } - pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> mc::cmt { - match self.mc().cat_expr_unadjusted(expr) { - Ok(c) => c, - Err(()) => { - self.tcx.sess.span_bug(expr.span, "error in mem categorization"); - } - } - } - - pub fn cat_expr_autoderefd(&self, - expr: &ast::Expr, - adj: &ty::AutoAdjustment) - -> mc::cmt { - let r = match *adj { - ty::AdjustDerefRef( - ty::AutoDerefRef { - autoderefs: autoderefs, ..}) => { - self.mc().cat_expr_autoderefd(expr, autoderefs) - } - ty::AdjustAddEnv(..) => { - // no autoderefs - self.mc().cat_expr_unadjusted(expr) - } - }; - - match r { - Ok(c) => c, - Err(()) => { - self.tcx.sess.span_bug(expr.span, - "error in mem categorization"); - } - } - } - - pub fn cat_def(&self, - id: ast::NodeId, - span: Span, - ty: ty::t, - def: def::Def) - -> mc::cmt { - match self.mc().cat_def(id, span, ty, def) { - Ok(c) => c, - Err(()) => { - self.tcx.sess.span_bug(span, "error in mem categorization"); - } - } - } - - pub fn cat_captured_var(&self, - closure_id: ast::NodeId, - closure_span: Span, - upvar_def: def::Def) - -> mc::cmt { - // Create the cmt for the variable being borrowed, from the - // caller's perspective - let var_id = upvar_def.def_id().node; - let var_ty = ty::node_id_to_type(self.tcx, var_id); - self.cat_def(closure_id, closure_span, var_ty, upvar_def) - } - - pub fn cat_discr(&self, cmt: mc::cmt, match_id: ast::NodeId) -> mc::cmt { - Rc::new(mc::cmt_ { - cat: mc::cat_discr(cmt.clone(), match_id), - mutbl: cmt.mutbl.inherit(), - ..*cmt - }) - } - - pub fn cat_pattern(&self, - cmt: mc::cmt, - pat: &ast::Pat, - op: |mc::cmt, &ast::Pat|) { - let r = self.mc().cat_pattern(cmt, pat, |_,x,y| op(x,y)); - assert!(r.is_ok()); - } - pub fn report(&self, err: BckError) { self.span_err( err.span, diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index fdd16c886866d..d8597c08b454c 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -568,22 +568,6 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { } } - pub fn each_path_moved_by(&self, - id: ast::NodeId, - f: |&Move, &LoanPath| -> bool) - -> bool { - /*! - * Iterates through each path moved by `id` - */ - - self.dfcx_moves.each_gen_bit(id, |index| { - let move = self.move_data.moves.borrow(); - let move = move.get(index); - let moved_path = move.path; - f(move, &*self.move_data.path_loan_path(moved_path)) - }) - } - pub fn kind_of_move_of_path(&self, id: ast::NodeId, loan_path: &Rc) @@ -665,13 +649,6 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { }) } - pub fn is_assignee(&self, - id: ast::NodeId) - -> bool { - //! True if `id` is the id of the LHS of an assignment - self.move_data.assignee_ids.borrow().iter().any(|x| x == &id) - } - pub fn each_assignment_of(&self, id: ast::NodeId, loan_path: &Rc, diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 4a5b2e01463ad..f5d4ece3bcccf 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -355,17 +355,6 @@ pub fn check_freevar_bounds(cx: &Context, fn_span: Span, sp: Span, ty: ty::t, }); } -pub fn check_trait_cast_bounds(cx: &Context, sp: Span, ty: ty::t, - bounds: ty::BuiltinBounds) { - check_builtin_bounds(cx, ty, bounds, |missing| { - span_err!(cx.tcx.sess, sp, E0147, - "cannot pack type `{}`, which does not fulfill `{}`, as a trait bounded by {}", - ty_to_string(cx.tcx, ty), - missing.user_string(cx.tcx), - bounds.user_string(cx.tcx)); - }); -} - fn check_copy(cx: &Context, ty: ty::t, sp: Span, reason: &str) { debug!("type_contents({})={}", ty_to_string(cx.tcx, ty), diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index c3b477da4bce5..3b831dd6847a1 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -735,10 +735,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { }) } - pub fn cat_deref_obj(&self, node: &N, base_cmt: cmt) -> cmt { - self.cat_deref_common(node, base_cmt, 0, ty::mk_nil(), false) - } - fn cat_deref(&self, node: &N, base_cmt: cmt, diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 9583dcf560e94..b55678e3a5078 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -195,11 +195,6 @@ impl Substs { } } - pub fn with_method_from(self, substs: &Substs) -> Substs { - self.with_method(Vec::from_slice(substs.types.get_slice(FnSpace)), - Vec::from_slice(substs.regions().get_slice(FnSpace))) - } - pub fn with_method(self, m_types: Vec, m_regions: Vec) @@ -292,15 +287,6 @@ impl fmt::Show for VecPerParamSpace { } } -impl VecPerParamSpace { - pub fn push_all(&mut self, space: ParamSpace, values: &[T]) { - // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n). - for t in values.iter() { - self.push(space, t.clone()); - } - } -} - impl VecPerParamSpace { fn limits(&self, space: ParamSpace) -> (uint, uint) { match space { @@ -348,14 +334,6 @@ impl VecPerParamSpace { } } - pub fn sort(t: Vec, space: |&T| -> ParamSpace) -> VecPerParamSpace { - let mut result = VecPerParamSpace::empty(); - for t in t.into_iter() { - result.push(space(&t), t); - } - result - } - /// Appends `value` to the vector associated with `space`. /// /// Unlike the `push` method in `Vec`, this should not be assumed @@ -435,12 +413,6 @@ impl VecPerParamSpace { &self.get_slice(space)[index] } - pub fn get_mut<'a>(&'a mut self, - space: ParamSpace, - index: uint) -> &'a mut T { - &mut self.get_mut_slice(space)[index] - } - pub fn iter<'a>(&'a self) -> Items<'a,T> { self.content.iter() } @@ -476,30 +448,6 @@ impl VecPerParamSpace { f.into_iter().map(|p| pred(p)).collect()) } - pub fn map_rev(&self, pred: |&T| -> U) -> VecPerParamSpace { - /*! - * Executes the map but in reverse order. For hacky reasons, we rely - * on this in table. - * - * FIXME(#5527) -- order of eval becomes irrelevant with newer - * trait reform, which features an idempotent algorithm that - * can be run to a fixed point - */ - - let mut fns: Vec = self.get_slice(FnSpace).iter().rev().map(|p| pred(p)).collect(); - - // NB: Calling foo.rev().map().rev() causes the calls to map - // to occur in the wrong order. This was somewhat surprising - // to me, though it makes total sense. - fns.reverse(); - - let mut selfs: Vec = self.get_slice(SelfSpace).iter().rev().map(|p| pred(p)).collect(); - selfs.reverse(); - let mut tys: Vec = self.get_slice(TypeSpace).iter().rev().map(|p| pred(p)).collect(); - tys.reverse(); - VecPerParamSpace::new(tys, selfs, fns) - } - pub fn split(self) -> (Vec, Vec, Vec) { // FIXME (#15418): this does two traversals when in principle // one would suffice. i.e. change to use `move_iter`. diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index d2bbbdfad0ef6..12a2815cfef34 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -21,7 +21,6 @@ use middle::trans::base; use middle::trans::common::*; use middle::trans::foreign; use middle::ty; -use middle::typeck; use util::ppaux::Repr; use syntax::abi; @@ -285,37 +284,8 @@ pub fn monomorphic_fn(ccx: &CrateContext, (lldecl, true) } -// Used to identify cached monomorphized functions -#[deriving(PartialEq, Eq, Hash)] -pub struct MonoParamId { - pub subst: ty::t, -} - #[deriving(PartialEq, Eq, Hash)] pub struct MonoId { pub def: ast::DefId, pub params: subst::VecPerParamSpace } - -pub fn make_vtable_id(_ccx: &CrateContext, - origin: &typeck::vtable_origin) - -> MonoId { - match origin { - &typeck::vtable_static(impl_id, ref substs, _) => { - MonoId { - def: impl_id, - params: substs.types.clone() - } - } - - &typeck::vtable_unboxed_closure(def_id) => { - MonoId { - def: def_id, - params: subst::VecPerParamSpace::empty(), - } - } - - // can't this be checked at the callee? - _ => fail!("make_vtable_id needs vtable_static") - } -} diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 469cdad076da2..f1499cb91663f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -1915,13 +1915,6 @@ pub fn fold_ty(cx: &ctxt, t0: t, fldop: |t| -> t) -> t { f.fold_ty(t0) } -pub fn walk_regions_and_ty(cx: &ctxt, ty: t, fldr: |r: Region|, fldt: |t: t|) - -> t { - ty_fold::RegionFolder::general(cx, - |r| { fldr(r); r }, - |t| { fldt(t); t }).fold_ty(ty) -} - impl ParamTy { pub fn new(space: subst::ParamSpace, index: uint, @@ -3551,58 +3544,6 @@ pub fn unsize_ty(cx: &ctxt, } } -impl AutoRef { - pub fn map_region(&self, f: |Region| -> Region) -> AutoRef { - match *self { - ty::AutoPtr(r, m, None) => ty::AutoPtr(f(r), m, None), - ty::AutoPtr(r, m, Some(ref a)) => ty::AutoPtr(f(r), m, Some(box a.map_region(f))), - ty::AutoUnsize(ref k) => ty::AutoUnsize(k.clone()), - ty::AutoUnsizeUniq(ref k) => ty::AutoUnsizeUniq(k.clone()), - ty::AutoUnsafe(m, None) => ty::AutoUnsafe(m, None), - ty::AutoUnsafe(m, Some(ref a)) => ty::AutoUnsafe(m, Some(box a.map_region(f))), - } - } -} - -pub fn method_call_type_param_defs<'tcx, T>(typer: &T, - origin: &typeck::MethodOrigin) - -> VecPerParamSpace - where T: mc::Typer<'tcx> { - match *origin { - typeck::MethodStatic(did) => { - ty::lookup_item_type(typer.tcx(), did).generics.types.clone() - } - typeck::MethodStaticUnboxedClosure(did) => { - let def_id = typer.unboxed_closures() - .borrow() - .find(&did) - .expect("method_call_type_param_defs: didn't \ - find unboxed closure") - .kind - .trait_did(typer.tcx()); - lookup_trait_def(typer.tcx(), def_id).generics.types.clone() - } - typeck::MethodTypeParam(typeck::MethodParam{ - trait_ref: ref trait_ref, - method_num: n_mth, - .. - }) | - typeck::MethodTraitObject(typeck::MethodObject{ - trait_ref: ref trait_ref, - method_num: n_mth, - .. - }) => { - match ty::trait_item(typer.tcx(), trait_ref.def_id, n_mth) { - ty::MethodTraitItem(method) => method.generics.types.clone(), - ty::TypeTraitItem(_) => { - typer.tcx().sess.bug("method_call_type_param_defs() \ - called on associated type") - } - } - } - } -} - pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> def::Def { match tcx.def_map.borrow().find(&expr.id) { Some(&def) => def, @@ -3821,22 +3762,6 @@ pub fn impl_or_trait_item_idx(id: ast::Ident, trait_items: &[ImplOrTraitItem]) trait_items.iter().position(|m| m.ident() == id) } -/// Returns a vector containing the indices of all type parameters that appear -/// in `ty`. The vector may contain duplicates. Probably should be converted -/// to a bitset or some other representation. -pub fn param_tys_in_type(ty: t) -> Vec { - let mut rslt = Vec::new(); - walk_ty(ty, |ty| { - match get(ty).sty { - ty_param(p) => { - rslt.push(p); - } - _ => () - } - }); - rslt -} - pub fn ty_sort_string(cx: &ctxt, t: t) -> String { match get(t).sty { ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | @@ -4706,17 +4631,6 @@ pub fn is_tuple_struct(cx: &ctxt, did: ast::DefId) -> bool { !fields.is_empty() && fields.iter().all(|f| f.name == token::special_names::unnamed_field) } -pub fn lookup_struct_field(cx: &ctxt, - parent: ast::DefId, - field_id: ast::DefId) - -> field_ty { - let r = lookup_struct_fields(cx, parent); - match r.iter().find(|f| f.id.node == field_id.node) { - Some(t) => t.clone(), - None => cx.sess.bug("struct ID not found in parent's fields") - } -} - // Returns a list of fields corresponding to the struct's items. trans uses // this. Takes a list of substs with which to instantiate field types. pub fn struct_fields(cx: &ctxt, did: ast::DefId, substs: &Substs) diff --git a/src/librustc/middle/typeck/check/demand.rs b/src/librustc/middle/typeck/check/demand.rs index 1b10b30b3358e..2359f9d72d2b7 100644 --- a/src/librustc/middle/typeck/check/demand.rs +++ b/src/librustc/middle/typeck/check/demand.rs @@ -77,17 +77,3 @@ pub fn coerce(fcx: &FnCtxt, sp: Span, expected: ty::t, expr: &ast::Expr) { } } } - -pub fn coerce_with_fn(fcx: &FnCtxt, - sp: Span, - expected: ty::t, - expr: &ast::Expr, - handle_err: |Span, ty::t, ty::t, &ty::type_err|) { - let expr_ty = fcx.expr_ty(expr); - match fcx.mk_assignty(expr, expr_ty, expected) { - result::Ok(()) => { /* ok */ } - result::Err(ref err) => { - handle_err(sp, expected, expr_ty, err); - } - } -} diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 5f1ff1d640630..821cf629d835c 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1901,18 +1901,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - pub fn method_ty_substs(&self, id: ast::NodeId) -> subst::Substs { - match self.inh.method_map.borrow().find(&MethodCall::expr(id)) { - Some(method) => method.substs.clone(), - None => { - self.tcx().sess.bug( - format!("no method entry for node {}: {} in fcx {}", - id, self.tcx().map.node_to_string(id), - self.tag()).as_slice()); - } - } - } - pub fn opt_node_ty_substs(&self, id: ast::NodeId, f: |&ty::ItemSubsts|) { @@ -1984,18 +1972,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.infcx().type_error_message(sp, mk_msg, actual_ty, err); } - pub fn report_mismatched_return_types(&self, - sp: Span, - e: ty::t, - a: ty::t, - err: &ty::type_err) { - // Derived error - if ty::type_is_error(e) || ty::type_is_error(a) { - return; - } - self.infcx().report_mismatched_types(sp, e, a, err) - } - pub fn report_mismatched_types(&self, sp: Span, e: ty::t, @@ -4663,24 +4639,6 @@ impl Repr for Expectation { } } -pub fn require_uint(fcx: &FnCtxt, sp: Span, t: ty::t) { - if !type_is_uint(fcx, sp, t) { - fcx.type_error_message(sp, |actual| { - format!("mismatched types: expected `uint` type, found `{}`", - actual) - }, t, None); - } -} - -pub fn require_integral(fcx: &FnCtxt, sp: Span, t: ty::t) { - if !type_is_integral(fcx, sp, t) { - fcx.type_error_message(sp, |actual| { - format!("mismatched types: expected integral type, found `{}`", - actual) - }, t, None); - } -} - pub fn check_decl_initializer(fcx: &FnCtxt, nid: ast::NodeId, init: &ast::Expr) @@ -5602,51 +5560,6 @@ pub fn structure_of<'a>(fcx: &FnCtxt, sp: Span, typ: ty::t) &ty::get(structurally_resolved_type(fcx, sp, typ)).sty } -pub fn type_is_integral(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_integral(typ_s); -} - -pub fn type_is_uint(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_uint(typ_s); -} - -pub fn type_is_scalar(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_scalar(typ_s); -} - -pub fn type_is_char(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_char(typ_s); -} - -pub fn type_is_bare_fn(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_bare_fn(typ_s); -} - -pub fn type_is_floating_point(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_floating_point(typ_s); -} - -pub fn type_is_unsafe_ptr(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_unsafe_ptr(typ_s); -} - -pub fn type_is_region_ptr(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_region_ptr(typ_s); -} - -pub fn type_is_c_like_enum(fcx: &FnCtxt, sp: Span, typ: ty::t) -> bool { - let typ_s = structurally_resolved_type(fcx, sp, typ); - return ty::type_is_c_like_enum(fcx.ccx.tcx, typ_s); -} - // Returns true if b contains a break that can exit from b pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &ast::Block) -> bool { // First: is there an unlabeled break immediately diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index d0791191c0fc0..85fe0a42c49d3 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -213,26 +213,6 @@ pub struct Rcx<'a, 'tcx: 'a> { repeating_scope: ast::NodeId, } -/// When entering a function, we can derive relationships from the -/// signature between various regions and type parameters. Consider -/// a function like: -/// -/// fn foo<'a, A>(x: &'a A) { ... } -/// -/// Here, we can derive that `A` must outlive `'a`, because otherwise -/// the caller would be illegal. We record this by storing a series of -/// pairs (in this case, `('a, A)`). These pairs will be consulted -/// later during regionck. -/// -/// In the case of nested fns, additional relationships may be -/// derived. The result is a link list walking up the stack (hence -/// the `previous` field). -#[deriving(Clone)] -pub struct RegionSubParamConstraints<'a> { - pairs: Vec<(ty::Region, ty::ParamTy)>, - previous: Option<&'a RegionSubParamConstraints<'a>>, -} - fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region { /*! * Returns the validity region of `def` -- that is, how long diff --git a/src/librustc/middle/typeck/check/vtable2.rs b/src/librustc/middle/typeck/check/vtable2.rs index 0022efd845e30..61ff86afcec3f 100644 --- a/src/librustc/middle/typeck/check/vtable2.rs +++ b/src/librustc/middle/typeck/check/vtable2.rs @@ -25,17 +25,6 @@ use syntax::codemap::Span; use util::ppaux::UserString; use util::ppaux::Repr; -/// When reporting an error about a failed trait obligation, it's nice -/// to include some context indicating why we were checking that -/// obligation in the first place. The span is often enough but -/// sometimes it's not. Currently this enum is a bit of a hack and I -/// suspect it should be carried in the obligation or more deeply -/// integrated somehow. -pub enum ErrorReportingContext { - GenericContext, - ImplSupertraitCheck, -} - pub fn check_object_cast(fcx: &FnCtxt, cast_expr: &ast::Expr, source_expr: &ast::Expr, diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 5f76c748417b7..f734aa09e4a12 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -22,7 +22,6 @@ use middle::typeck::infer::{force_all, resolve_all, resolve_region}; use middle::typeck::infer::resolve_type; use middle::typeck::infer; use middle::typeck::{MethodCall, MethodCallee}; -use middle::typeck::vtable_res; use middle::typeck::write_substs_to_tcx; use middle::typeck::write_ty_to_tcx; use util::ppaux::Repr; @@ -67,17 +66,6 @@ pub fn resolve_type_vars_in_fn(fcx: &FnCtxt, wbcx.visit_object_cast_map(); } -pub fn resolve_impl_res(infcx: &infer::InferCtxt, - span: Span, - vtable_res: &vtable_res) - -> vtable_res { - let errors = Cell::new(false); // nobody cares - let mut resolver = Resolver::from_infcx(infcx, - &errors, - ResolvingImplRes(span)); - vtable_res.resolve_in(&mut resolver) -} - /////////////////////////////////////////////////////////////////////////// // The Writerback context. This visitor walks the AST, checking the // fn-specific tables to find references to types or regions. It @@ -413,10 +401,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { reason: ResolveReason) -> Resolver<'cx, 'tcx> { - Resolver { infcx: fcx.infcx(), - tcx: fcx.tcx(), - writeback_errors: &fcx.writeback_errors, - reason: reason } + Resolver::from_infcx(fcx.infcx(), &fcx.writeback_errors, reason) } fn from_infcx(infcx: &'cx infer::InferCtxt<'cx, 'tcx>, diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 3af744824ff96..d1b754155f8c7 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -66,12 +66,6 @@ pub mod unify; pub type Bound = Option; -#[deriving(PartialEq,Clone)] -pub struct Bounds { - pub lb: Bound, - pub ub: Bound -} - pub type cres = Result; // "combine result" pub type ures = cres<()>; // "unify result" pub type fres = Result; // "fixup result" diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 7e61c254a656b..008ca6c077165 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -525,17 +525,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } } - pub fn max_regions(&self, - a: Region, - b: Region) - -> Option - { - match self.glb_concrete_regions(a, b) { - Ok(r) => Some(r), - Err(_) => None - } - } - pub fn resolve_var(&self, rid: RegionVid) -> ty::Region { match *self.values.borrow() { None => { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 5b83f024309bf..0a4fd90765c03 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -25,7 +25,6 @@ use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer}; use middle::ty; use middle::typeck; use middle::typeck::check::regionmanip; -use middle::typeck::infer; use std::rc::Rc; use syntax::abi; @@ -1181,14 +1180,6 @@ impl Repr for ast::FloatTy { } } -impl Repr for infer::Bounds { - fn repr(&self, tcx: &ctxt) -> String { - format!("({} <= {})", - self.lb.repr(tcx), - self.ub.repr(tcx)) - } -} - impl Repr for ty::ExplicitSelfCategory { fn repr(&self, _: &ctxt) -> String { explicit_self_category_to_str(self).to_string()