Skip to content

Commit

Permalink
Remove dead code from librustc
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Wieczorek committed Sep 24, 2014
1 parent 5bcc154 commit fd52224
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 544 deletions.
7 changes: 0 additions & 7 deletions src/librustc/back/link.rs
Expand Up @@ -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(..) => {}
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/diagnostics.rs
Expand Up @@ -114,7 +114,6 @@ register_diagnostics!(
E0102,
E0103,
E0104,
E0105,
E0106,
E0107,
E0108,
Expand Down Expand Up @@ -152,7 +151,6 @@ register_diagnostics!(
E0144,
E0145,
E0146,
E0147,
E0148,
E0151,
E0152,
Expand Down
73 changes: 0 additions & 73 deletions src/librustc/middle/astencode.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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<T>(&mut self,
f: |&mut Self| -> T)
Expand Down
82 changes: 0 additions & 82 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
}
Expand All @@ -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,
Expand Down
23 changes: 0 additions & 23 deletions src/librustc/middle/borrowck/move_data.rs
Expand Up @@ -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<LoanPath>)
Expand Down Expand Up @@ -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<LoanPath>,
Expand Down
11 changes: 0 additions & 11 deletions src/librustc/middle/kind.rs
Expand Up @@ -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),
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -735,10 +735,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
})
}

pub fn cat_deref_obj<N:ast_node>(&self, node: &N, base_cmt: cmt) -> cmt {
self.cat_deref_common(node, base_cmt, 0, ty::mk_nil(), false)
}

fn cat_deref<N:ast_node>(&self,
node: &N,
base_cmt: cmt,
Expand Down
52 changes: 0 additions & 52 deletions src/librustc/middle/subst.rs
Expand Up @@ -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<ty::t>,
m_regions: Vec<ty::Region>)
Expand Down Expand Up @@ -292,15 +287,6 @@ impl<T:fmt::Show> fmt::Show for VecPerParamSpace<T> {
}
}

impl<T:Clone> VecPerParamSpace<T> {
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<T> VecPerParamSpace<T> {
fn limits(&self, space: ParamSpace) -> (uint, uint) {
match space {
Expand Down Expand Up @@ -348,14 +334,6 @@ impl<T> VecPerParamSpace<T> {
}
}

pub fn sort(t: Vec<T>, space: |&T| -> ParamSpace) -> VecPerParamSpace<T> {
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
Expand Down Expand Up @@ -435,12 +413,6 @@ impl<T> VecPerParamSpace<T> {
&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()
}
Expand Down Expand Up @@ -476,30 +448,6 @@ impl<T> VecPerParamSpace<T> {
f.into_iter().map(|p| pred(p)).collect())
}

pub fn map_rev<U>(&self, pred: |&T| -> U) -> VecPerParamSpace<U> {
/*!
* 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<U> = 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<U> = self.get_slice(SelfSpace).iter().rev().map(|p| pred(p)).collect();
selfs.reverse();
let mut tys: Vec<U> = self.get_slice(TypeSpace).iter().rev().map(|p| pred(p)).collect();
tys.reverse();
VecPerParamSpace::new(tys, selfs, fns)
}

pub fn split(self) -> (Vec<T>, Vec<T>, Vec<T>) {
// FIXME (#15418): this does two traversals when in principle
// one would suffice. i.e. change to use `move_iter`.
Expand Down

5 comments on commit fd52224

@bors
Copy link
Contributor

@bors bors commented on fd52224 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on fd52224 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging jakub-/rust/dead-code = fd52224 into auto

@bors
Copy link
Contributor

@bors bors commented on fd52224 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jakub-/rust/dead-code = fd52224 merged ok, testing candidate = 4d69696

@bors
Copy link
Contributor

@bors bors commented on fd52224 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on fd52224 Sep 24, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 4d69696

Please sign in to comment.