Remove dead code from librustc
This commit is contained in:
parent
5bcc154dff
commit
fd52224e78
@ -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(..) => {}
|
||||
|
@ -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,
|
||||
|
@ -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<T>(&mut self,
|
||||
f: |&mut Self| -> T)
|
||||
|
@ -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,
|
||||
|
@ -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>)
|
||||
@ -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>,
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
|
@ -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>)
|
||||
@ -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 {
|
||||
@ -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
|
||||
@ -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()
|
||||
}
|
||||
@ -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`.
|
||||
|
@ -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<ty::t>
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
@ -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<TypeParameterDef>
|
||||
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<ParamTy> {
|
||||
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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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>,
|
||||
|
@ -66,12 +66,6 @@ pub mod unify;
|
||||
|
||||
pub type Bound<T> = Option<T>;
|
||||
|
||||
#[deriving(PartialEq,Clone)]
|
||||
pub struct Bounds<T> {
|
||||
pub lb: Bound<T>,
|
||||
pub ub: Bound<T>
|
||||
}
|
||||
|
||||
pub type cres<T> = Result<T,ty::type_err>; // "combine result"
|
||||
pub type ures = cres<()>; // "unify result"
|
||||
pub type fres<T> = Result<T, fixup_err>; // "fixup result"
|
||||
|
@ -525,17 +525,6 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_regions(&self,
|
||||
a: Region,
|
||||
b: Region)
|
||||
-> Option<Region>
|
||||
{
|
||||
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 => {
|
||||
|
@ -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<T:Repr> Repr for infer::Bounds<T> {
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user