]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #13244 : cmr/rust/tbaa, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 3 Apr 2014 10:42:02 +0000 (03:42 -0700)
committerbors <bors@rust-lang.org>
Thu, 3 Apr 2014 10:42:02 +0000 (03:42 -0700)
44 files changed:
src/librustc/back/abi.rs
src/librustc/back/archive.rs
src/librustc/back/link.rs
src/librustc/lib/llvm.rs
src/librustc/metadata/common.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/cstore.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/filesearch.rs
src/librustc/middle/astencode.rs
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/cfg/mod.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/freevars.rs
src/librustc/middle/graph.rs
src/librustc/middle/kind.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/pat_util.rs
src/librustc/middle/region.rs
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/build.rs
src/librustc/middle/trans/builder.rs
src/librustc/middle/trans/cabi.rs
src/librustc/middle/trans/callee.rs
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/datum.rs
src/librustc/middle/trans/meth.rs
src/librustc/middle/trans/reflect.rs
src/librustc/middle/trans/tvec.rs
src/librustc/middle/trans/type_.rs
src/librustc/middle/ty.rs
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/infer/lub.rs
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/resolve.rs
src/librustc/middle/typeck/mod.rs
src/librustc/middle/typeck/rscope.rs
src/librustc/util/common.rs
src/librustc/util/ppaux.rs

index 83a17bd3231a2442285a5035f95036950934858f..c722beb43ae955c9e7ebdc487638dad5cf422cf2 100644 (file)
@@ -8,44 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-pub static rc_base_field_refcnt: uint = 0u;
-
-pub static task_field_refcnt: uint = 0u;
-
-pub static task_field_stk: uint = 2u;
-
-pub static task_field_runtime_sp: uint = 3u;
-
-pub static task_field_rust_sp: uint = 4u;
-
-pub static task_field_gc_alloc_chain: uint = 5u;
-
-pub static task_field_dom: uint = 6u;
-
-pub static n_visible_task_fields: uint = 7u;
-
-pub static dom_field_interrupt_flag: uint = 1u;
-
-pub static frame_glue_fns_field_mark: uint = 0u;
-
-pub static frame_glue_fns_field_drop: uint = 1u;
-
-pub static frame_glue_fns_field_reloc: uint = 2u;
-
 pub static box_field_refcnt: uint = 0u;
 pub static box_field_tydesc: uint = 1u;
-pub static box_field_prev: uint = 2u;
-pub static box_field_next: uint = 3u;
 pub static box_field_body: uint = 4u;
 
-pub static general_code_alignment: uint = 16u;
-
-pub static tydesc_field_size: uint = 0u;
-pub static tydesc_field_align: uint = 1u;
-pub static tydesc_field_drop_glue: uint = 2u;
 pub static tydesc_field_visit_glue: uint = 3u;
-pub static tydesc_field_name_offset: uint = 4u;
-pub static n_tydesc_fields: uint = 5u;
 
 // The two halves of a closure: code and environment.
 pub static fn_field_code: uint = 0u;
@@ -64,5 +31,3 @@
 
 pub static slice_elt_base: uint = 0u;
 pub static slice_elt_len: uint = 1u;
-
-pub static abi_version: uint = 1u;
index d6173176c160b8f604a42cd40711c23a447d3621..6de7bb59b6180ea82ee96d0bf6881d7154a47b9f 100644 (file)
@@ -87,29 +87,6 @@ pub fn open(sess: &'a Session, dst: Path) -> Archive<'a> {
         Archive { sess: sess, dst: dst }
     }
 
-    /// Read a file in the archive
-    pub fn read(&self, file: &str) -> Vec<u8> {
-        // Apparently if "ar p" is used on windows, it generates a corrupt file
-        // which has bad headers and LLVM will immediately choke on it
-        if cfg!(windows) {
-            let loc = TempDir::new("rsar").unwrap();
-            let archive = os::make_absolute(&self.dst);
-            run_ar(self.sess, "x", Some(loc.path()), [&archive,
-                                                      &Path::new(file)]);
-            let result: Vec<u8> =
-                fs::File::open(&loc.path().join(file)).read_to_end()
-                                                      .unwrap()
-                                                      .move_iter()
-                                                      .collect();
-            result
-        } else {
-            run_ar(self.sess,
-                   "p",
-                   None,
-                   [&self.dst, &Path::new(file)]).output.move_iter().collect()
-        }
-    }
-
     /// Adds all of the contents of a native library to this archive. This will
     /// search in the relevant locations for a library named `name`.
     pub fn add_native_library(&mut self, name: &str) -> io::IoResult<()> {
index f198a41af655754fa3c8e5fe67412a04423f3658..e9292f54a4b266f6c7c27152f130d44596087416 100644 (file)
@@ -687,16 +687,6 @@ pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems,
     exported_name(path, hash, ccx.link_meta.crateid.version_or_default())
 }
 
-pub fn mangle_internal_name_by_type_only(ccx: &CrateContext,
-                                         t: ty::t,
-                                         name: &str) -> ~str {
-    let s = ppaux::ty_to_short_str(ccx.tcx(), t);
-    let path = [PathName(token::intern(name)),
-                PathName(token::intern(s))];
-    let hash = get_symbol_hash(ccx, t);
-    mangle(ast_map::Values(path.iter()), Some(hash.as_slice()), None)
-}
-
 pub fn mangle_internal_name_by_type_and_seq(ccx: &CrateContext,
                                             t: ty::t,
                                             name: &str) -> ~str {
index d9e1b779e96517793a0d1e1c04e1cd7d86b529e8..a733d2672e820292b1fecb05b1a6ea0a64a1e518 100644 (file)
@@ -10,6 +10,7 @@
 
 #![allow(non_uppercase_pattern_statics)]
 #![allow(non_camel_case_types)]
+#![allow(dead_code)]
 
 use std::c_str::ToCStr;
 use std::cell::RefCell;
@@ -1911,42 +1912,6 @@ pub fn mk_target_data(string_rep: &str) -> TargetData {
     }
 }
 
-/* Memory-managed interface to pass managers. */
-
-pub struct pass_manager_res {
-    pub pm: PassManagerRef,
-}
-
-impl Drop for pass_manager_res {
-    fn drop(&mut self) {
-        unsafe {
-            llvm::LLVMDisposePassManager(self.pm);
-        }
-    }
-}
-
-pub fn pass_manager_res(pm: PassManagerRef) -> pass_manager_res {
-    pass_manager_res {
-        pm: pm
-    }
-}
-
-pub struct PassManager {
-    pub llpm: PassManagerRef,
-    dtor: @pass_manager_res
-}
-
-pub fn mk_pass_manager() -> PassManager {
-    unsafe {
-        let llpm = llvm::LLVMCreatePassManager();
-
-        PassManager {
-            llpm: llpm,
-            dtor: @pass_manager_res(llpm)
-        }
-    }
-}
-
 /* Memory-managed interface to object files. */
 
 pub struct ObjectFile {
index 09d3b36321fa9a91b5fcc0afa383758bf8a3f345..264829b18a309453d318327537b153883b2509aa 100644 (file)
@@ -73,8 +73,6 @@
 pub static tag_crate_hash: uint = 0x1a;
 pub static tag_crate_crateid: uint = 0x1b;
 
-pub static tag_parent_item: uint = 0x1c;
-
 pub static tag_crate_dep_crateid: uint = 0x1d;
 pub static tag_crate_dep_hash: uint = 0x1e;
 
 pub static tag_path_elem_mod: uint = 0x26;
 pub static tag_path_elem_name: uint = 0x27;
 pub static tag_item_field: uint = 0x28;
-pub static tag_struct_mut: uint = 0x29;
 
 pub static tag_item_variances: uint = 0x2a;
-pub static tag_mod_impl_trait: uint = 0x2b;
 /*
   trait items contain tag_item_trait_method elements,
   impl items contain tag_item_impl_method elements, and classes
@@ -108,7 +104,6 @@ impl items contain tag_item_impl_method elements, and classes
  */
 pub static tag_item_impl_method: uint = 0x2c;
 pub static tag_item_trait_method_explicit_self: uint = 0x2d;
-pub static tag_item_trait_method_self_ty_region: uint = 0x2e;
 
 
 // Reexports are found within module tags. Each reexport contains def_ids
@@ -173,12 +168,8 @@ pub fn from_uint(value : uint) -> Option<astencode_tag> {
 pub static tag_lang_items_item_node_id: uint = 0x4b;
 
 pub static tag_item_unnamed_field: uint = 0x4c;
-pub static tag_items_data_item_struct_ctor: uint = 0x4d;
 pub static tag_items_data_item_visibility: uint = 0x4e;
 
-pub static tag_link_args: uint = 0x4f;
-pub static tag_link_args_arg: uint = 0x50;
-
 pub static tag_item_method_tps: uint = 0x51;
 pub static tag_item_method_fty: uint = 0x52;
 
index d840ca329387d51dc8bc97ea71d3ebb0b58ad46c..4300c2eedbf6d03de76c35f43b4f000be6cc8e71 100644 (file)
@@ -37,12 +37,6 @@ pub fn get_symbol(cstore: &cstore::CStore, def: ast::DefId) -> ~str {
     return decoder::get_symbol(cdata, def.node);
 }
 
-pub fn get_type_param_count(cstore: &cstore::CStore, def: ast::DefId)
-                         -> uint {
-    let cdata = cstore.get_crate_data(def.krate).data();
-    return decoder::get_type_param_count(cdata, def.node);
-}
-
 /// Iterates over all the language items in the given crate.
 pub fn each_lang_item(cstore: &cstore::CStore,
                       cnum: ast::CrateNum,
@@ -244,21 +238,6 @@ pub fn get_impl_vtables(tcx: &ty::ctxt,
     decoder::get_impl_vtables(cdata, def.node, tcx)
 }
 
-pub fn get_impl_method(cstore: &cstore::CStore,
-                       def: ast::DefId,
-                       mname: ast::Ident)
-                    -> Option<ast::DefId> {
-    let cdata = cstore.get_crate_data(def.krate);
-    decoder::get_impl_method(cstore.intr.clone(), cdata, def.node, mname)
-}
-
-pub fn get_item_visibility(cstore: &cstore::CStore,
-                           def_id: ast::DefId)
-                        -> ast::Visibility {
-    let cdata = cstore.get_crate_data(def_id.krate);
-    decoder::get_item_visibility(cdata, def_id.node)
-}
-
 pub fn get_native_libraries(cstore: &cstore::CStore,
                             crate_num: ast::CrateNum)
                                 -> Vec<(cstore::NativeLibaryKind, ~str)> {
index 62fcc4c617e619e9eb01f8385a94928f89825810..e3a3239bdb5b852d11accd3aa22dd4c9db4610fa 100644 (file)
@@ -23,7 +23,6 @@
 use collections::HashMap;
 use syntax::ast;
 use syntax::parse::token::IdentInterner;
-use syntax::crateid::CrateId;
 
 // A map from external crate numbers (as decoded from some crate file) to
 // local crate numbers (as generated during this session). Each external
@@ -98,19 +97,10 @@ pub fn get_crate_hash(&self, cnum: ast::CrateNum) -> Svh {
         decoder::get_crate_hash(cdata.data())
     }
 
-    pub fn get_crate_id(&self, cnum: ast::CrateNum) -> CrateId {
-        let cdata = self.get_crate_data(cnum);
-        decoder::get_crate_id(cdata.data())
-    }
-
     pub fn set_crate_data(&self, cnum: ast::CrateNum, data: @crate_metadata) {
         self.metas.borrow_mut().insert(cnum, data);
     }
 
-    pub fn have_crate_data(&self, cnum: ast::CrateNum) -> bool {
-        self.metas.borrow().contains_key(&cnum)
-    }
-
     pub fn iter_crate_data(&self, i: |ast::CrateNum, @crate_metadata|) {
         for (&k, &v) in self.metas.borrow().iter() {
             i(k, v);
index 94941913a8b8831a1a0a8b6442768c902165c38b..dc8acf63719d8258cdd9ac46142edc8ead1c8fbf 100644 (file)
@@ -279,13 +279,6 @@ fn item_region_param_defs(item_doc: ebml::Doc, cdata: Cmd)
     Rc::new(v)
 }
 
-fn item_ty_param_count(item: ebml::Doc) -> uint {
-    let mut n = 0u;
-    reader::tagged_docs(item, tag_items_data_item_ty_param_bounds,
-                      |_p| { n += 1u; true } );
-    n
-}
-
 fn enum_variant_ids(item: ebml::Doc, cdata: Cmd) -> Vec<ast::DefId> {
     let mut ids: Vec<ast::DefId> = Vec::new();
     let v = tag_items_data_item_variant;
@@ -420,10 +413,6 @@ pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
     }
 }
 
-pub fn get_type_param_count(data: &[u8], id: ast::NodeId) -> uint {
-    item_ty_param_count(lookup_item(id, data))
-}
-
 pub fn get_impl_trait(cdata: Cmd,
                       id: ast::NodeId,
                       tcx: &ty::ctxt) -> Option<@ty::TraitRef>
@@ -449,20 +438,6 @@ pub fn get_impl_vtables(cdata: Cmd,
 }
 
 
-pub fn get_impl_method(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
-                       name: ast::Ident) -> Option<ast::DefId> {
-    let items = reader::get_doc(reader::Doc(cdata.data()), tag_items);
-    let mut found = None;
-    reader::tagged_docs(find_item(id, items), tag_item_impl_method, |mid| {
-        let m_did = reader::with_doc_data(mid, parse_def_id);
-        if item_name(&*intr, find_item(m_did.node, items)) == name {
-            found = Some(translate_def_id(cdata, m_did));
-        }
-        true
-    });
-    found
-}
-
 pub fn get_symbol(data: &[u8], id: ast::NodeId) -> ~str {
     return item_symbol(lookup_item(id, data));
 }
@@ -475,14 +450,6 @@ pub enum DefLike {
     DlField
 }
 
-pub fn def_like_to_def(def_like: DefLike) -> ast::Def {
-    match def_like {
-        DlDef(def) => return def,
-        DlImpl(..) => fail!("found impl in def_like_to_def"),
-        DlField => fail!("found field in def_like_to_def")
-    }
-}
-
 /// Iterates over the language items in the given crate.
 pub fn each_lang_item(cdata: Cmd, f: |ast::NodeId, uint| -> bool) -> bool {
     let root = reader::Doc(cdata.data());
@@ -1030,11 +997,6 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
     result
 }
 
-pub fn get_item_visibility(cdata: Cmd, id: ast::NodeId)
-                        -> ast::Visibility {
-    item_visibility(lookup_item(id, cdata.data()))
-}
-
 fn get_meta_items(md: ebml::Doc) -> Vec<@ast::MetaItem> {
     let mut items: Vec<@ast::MetaItem> = Vec::new();
     reader::tagged_docs(md, tag_meta_item_word, |meta_item_doc| {
@@ -1103,7 +1065,7 @@ fn list_crate_attributes(md: ebml::Doc, hash: &Svh,
 }
 
 pub fn get_crate_attributes(data: &[u8]) -> Vec<ast::Attribute> {
-    return get_attributes(reader::Doc(data));
+    get_attributes(reader::Doc(data))
 }
 
 #[deriving(Clone)]
index 468eac4d2694ce5220dee2a0b53a7a9469feac6d..b83f42da0a05681129522e205728ef45f60941dd 100644 (file)
@@ -84,12 +84,6 @@ pub fn get_target_lib_path(&self) -> Path {
         make_target_lib_path(self.sysroot, self.target_triple)
     }
 
-    pub fn get_target_lib_file_path(&self, file: &Path) -> Path {
-        let mut p = self.get_target_lib_path();
-        p.push(file);
-        p
-    }
-
     pub fn search(&self, pick: pick) {
         self.for_each_lib_search_path(|lib_search_path| {
             debug!("searching {}", lib_search_path.display());
index 383739a1b0320db53ecbcc7545daaf1bf8a0ebd2..e6f6a87be4fdcc41db014e2a242ea4bf3adb5840 100644 (file)
@@ -111,13 +111,6 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext,
            ebml_w.writer.tell());
 }
 
-pub fn encode_exported_macro(ebml_w: &mut Encoder, i: &ast::Item) {
-    match i.node {
-        ast::ItemMac(..) => encode_ast(ebml_w, ast::IIItem(@i.clone())),
-        _ => fail!("expected a macro")
-    }
-}
-
 pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
                            tcx: &ty::ctxt,
                            maps: &Maps,
@@ -173,13 +166,6 @@ pub fn decode_inlined_item(cdata: @cstore::crate_metadata,
     }
 }
 
-pub fn decode_exported_macro(par_doc: ebml::Doc) -> @ast::Item {
-    match decode_ast(par_doc) {
-        ast::IIItem(item) => item,
-        _ => fail!("expected item")
-    }
-}
-
 // ______________________________________________________________________
 // Enumerating the IDs which appear in an AST
 
index b8b05128e4c2c3b87246ae98f7385b4bc9f4f465..6f4f2f6345eb48fa0fe161caa0bfab9d08a8accf 100644 (file)
@@ -326,6 +326,7 @@ pub struct RestrictionSet {
     bits: u32
 }
 
+#[allow(dead_code)] // potentially useful
 pub static RESTR_EMPTY: RestrictionSet  = RestrictionSet {bits: 0b0000};
 pub static RESTR_MUTATE: RestrictionSet = RestrictionSet {bits: 0b0001};
 pub static RESTR_FREEZE: RestrictionSet = RestrictionSet {bits: 0b0010};
@@ -334,10 +335,6 @@ impl RestrictionSet {
     pub fn intersects(&self, restr: RestrictionSet) -> bool {
         (self.bits & restr.bits) != 0
     }
-
-    pub fn contains_all(&self, restr: RestrictionSet) -> bool {
-        (self.bits & restr.bits) == restr.bits
-    }
 }
 
 impl BitOr<RestrictionSet,RestrictionSet> for RestrictionSet {
@@ -862,17 +859,6 @@ pub fn loan_path_to_str(&self, loan_path: &LoanPath) -> ~str {
     pub fn cmt_to_str(&self, cmt: mc::cmt) -> ~str {
         self.mc().cmt_to_str(cmt)
     }
-
-    pub fn mut_to_str(&self, mutbl: ast::Mutability) -> ~str {
-        self.mc().mut_to_str(mutbl)
-    }
-
-    pub fn mut_to_keyword(&self, mutbl: ast::Mutability) -> &'static str {
-        match mutbl {
-            ast::MutImmutable => "",
-            ast::MutMutable => "mut",
-        }
-    }
 }
 
 impl DataFlowOperator for LoanDataFlowOperator {
index 9c2dcd74351e3100b08699939b57cfb360b1e91d..97ea996bb7e458e3dd53aecd37b2c375e4b38118 100644 (file)
@@ -15,6 +15,8 @@
 
 */
 
+#![allow(dead_code)] // still a WIP, #6298
+
 use middle::graph;
 use middle::ty;
 use middle::typeck;
index 7fadfff21d119bb95223e5024c66d85f95fffa51..bd45956fbb2ac9610ba4a0fc340af12da3324498 100644 (file)
@@ -521,11 +521,3 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option<int> {
 pub fn compare_lit_exprs(tcx: &ty::ctxt, a: &Expr, b: &Expr) -> Option<int> {
     compare_const_vals(&eval_const_expr(tcx, a), &eval_const_expr(tcx, b))
 }
-
-pub fn lit_expr_eq(tcx: &ty::ctxt, a: &Expr, b: &Expr) -> Option<bool> {
-    compare_lit_exprs(tcx, a, b).map(|val| val == 0)
-}
-
-pub fn lit_eq(a: &Lit, b: &Lit) -> Option<bool> {
-    compare_const_vals(&lit_to_const(a), &lit_to_const(b)).map(|val| val == 0)
-}
index 2adc3e82576f2b185882cac73274b514d80bf788..92d359887b98f00aa6c48789e280580d1688cb38 100644 (file)
@@ -246,31 +246,6 @@ pub fn each_bit_on_entry_frozen(&self,
         self.each_bit(on_entry, f)
     }
 
-    pub fn each_bit_on_entry(&mut self,
-                             id: ast::NodeId,
-                             f: |uint| -> bool)
-                             -> bool {
-        //! Iterates through each bit that is set on entry to `id`.
-        //! Only useful after `propagate()` has been called.
-
-        let (start, end) = self.compute_id_range(id);
-        let on_entry = self.on_entry.slice(start, end);
-        debug!("each_bit_on_entry(id={:?}, on_entry={})",
-               id, bits_to_str(on_entry));
-        self.each_bit(on_entry, f)
-    }
-
-    pub fn each_gen_bit(&mut self, id: ast::NodeId, f: |uint| -> bool)
-                        -> bool {
-        //! Iterates through each bit in the gen set for `id`.
-
-        let (start, end) = self.compute_id_range(id);
-        let gens = self.gens.slice(start, end);
-        debug!("each_gen_bit(id={:?}, gens={})",
-               id, bits_to_str(gens));
-        self.each_bit(gens, f)
-    }
-
     pub fn each_gen_bit_frozen(&self, id: ast::NodeId, f: |uint| -> bool)
                                -> bool {
         //! Iterates through each bit in the gen set for `id`.
index d8851fa46f8bae96ad4bfdcff05e5746ae771b56..d6adb19419b517b0f1375ebdca2e8a522b00fa78 100644 (file)
@@ -145,7 +145,3 @@ pub fn get_freevars(tcx: &ty::ctxt, fid: ast::NodeId) -> freevar_info {
         Some(&d) => return d
     }
 }
-
-pub fn has_freevars(tcx: &ty::ctxt, fid: ast::NodeId) -> bool {
-    !get_freevars(tcx, fid).is_empty()
-}
index fd27cabaf7fbab23746b66b8b5b07e44a79a4cb0..e4603b7eae2601f7e3feb1dccda8da33431ec7f8 100644 (file)
@@ -34,6 +34,8 @@
 
 */
 
+#![allow(dead_code)] // still WIP
+
 use std::uint;
 
 pub struct Graph<N,E> {
index fd53c2e544d2c6d1f7f9f10b04e011321ee727df..a667e81f349fe63fb9804e88825cfca06d2c1c22 100644 (file)
@@ -450,17 +450,6 @@ fn check_copy(cx: &Context, ty: ty::t, sp: Span, reason: &str) {
     }
 }
 
-pub fn check_send(cx: &Context, ty: ty::t, sp: Span) -> bool {
-    if !ty::type_is_sendable(cx.tcx, ty) {
-        cx.tcx.sess.span_err(
-            sp, format!("value has non-sendable type `{}`",
-                     ty_to_str(cx.tcx, ty)));
-        false
-    } else {
-        true
-    }
-}
-
 pub fn check_static(tcx: &ty::ctxt, ty: ty::t, sp: Span) -> bool {
     if !ty::type_is_static(tcx, ty) {
         match ty::get(ty).sty {
index 86db6b6a46373a22430a8e0fcc3b9e3df4282be4..7fca0e56aa21f67aa4cd802579459a3597c2baed 100644 (file)
@@ -96,6 +96,7 @@ pub fn to_builtin_kind(&self, id: ast::DefId) -> Option<ty::BuiltinBound> {
     }
 
     $(
+        #[allow(dead_code)]
         pub fn $method(&self) -> Option<ast::DefId> {
             *self.items.get($variant as uint)
         }
index 3604499add6936040caf4a8ddc109b4b937e42e0..e376e66ca6f90c8ba76612db0c44e5d14e8c5aab 100644 (file)
@@ -64,7 +64,7 @@
 
 use middle::ty;
 use middle::typeck;
-use util::ppaux::{ty_to_str, region_ptr_to_str, Repr};
+use util::ppaux::{ty_to_str, Repr};
 
 use syntax::ast::{MutImmutable, MutMutable};
 use syntax::ast;
@@ -674,20 +674,6 @@ pub fn cat_rvalue(&mut self,
         }
     }
 
-    /// inherited mutability: used in cases where the mutability of a
-    /// component is inherited from the base it is a part of. For
-    /// example, a record field is mutable if it is declared mutable
-    /// or if the container is mutable.
-    pub fn inherited_mutability(&mut self,
-                                base_m: MutabilityCategory,
-                                interior_m: ast::Mutability)
-                                -> MutabilityCategory {
-        match interior_m {
-            MutImmutable => base_m.inherit(),
-            MutMutable => McDeclared
-        }
-    }
-
     pub fn cat_field<N:ast_node>(&mut self,
                                  node: &N,
                                  base_cmt: cmt,
@@ -1114,13 +1100,6 @@ pub fn cat_pattern(&mut self,
         Ok(())
     }
 
-    pub fn mut_to_str(&mut self, mutbl: ast::Mutability) -> ~str {
-        match mutbl {
-          MutMutable => ~"mutable",
-          MutImmutable => ~"immutable"
-        }
-    }
-
     pub fn cmt_to_str(&self, cmt: cmt) -> ~str {
         match cmt.cat {
           cat_static_item => {
@@ -1174,48 +1153,6 @@ pub fn cmt_to_str(&self, cmt: cmt) -> ~str {
           }
         }
     }
-
-    pub fn region_to_str(&self, r: ty::Region) -> ~str {
-        region_ptr_to_str(self.tcx(), r)
-    }
-}
-
-/// The node_id here is the node of the expression that references the field.
-/// This function looks it up in the def map in case the type happens to be
-/// an enum to determine which variant is in use.
-pub fn field_mutbl(tcx: &ty::ctxt,
-                   base_ty: ty::t,
-                   // FIXME #6993: change type to Name
-                   f_name: ast::Ident,
-                   node_id: ast::NodeId)
-                -> Option<ast::Mutability> {
-    // Need to refactor so that struct/enum fields can be treated uniformly.
-    match ty::get(base_ty).sty {
-      ty::ty_struct(did, _) => {
-        let r = ty::lookup_struct_fields(tcx, did);
-        for fld in r.iter() {
-            if fld.name == f_name.name {
-                return Some(ast::MutImmutable);
-            }
-        }
-      }
-      ty::ty_enum(..) => {
-        match tcx.def_map.borrow().get_copy(&node_id) {
-          ast::DefVariant(_, variant_id, _) => {
-            let r = ty::lookup_struct_fields(tcx, variant_id);
-            for fld in r.iter() {
-                if fld.name == f_name.name {
-                    return Some(ast::MutImmutable);
-                }
-            }
-          }
-          _ => {}
-        }
-      }
-      _ => { }
-    }
-
-    return None;
 }
 
 pub enum InteriorSafety {
index e9d01b9048f919041ab17e0ca00491dccf144373..2d50d2e0f772b45376ed17d392f02f598823496c 100644 (file)
@@ -86,12 +86,6 @@ pub fn pat_bindings(dm: resolve::DefMap,
     });
 }
 
-pub fn pat_binding_ids(dm: resolve::DefMap, pat: &Pat) -> Vec<NodeId> {
-    let mut found = Vec::new();
-    pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) );
-    return found;
-}
-
 /// Checks if the pattern contains any patterns that bind something to
 /// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
 pub fn pat_contains_bindings(dm: resolve::DefMap, pat: &Pat) -> bool {
index 247209539127cf0bdd067e0cbcc973a154522d97..ad940113a86c498c8c2e74f38549e087d325fdd1 100644 (file)
@@ -149,6 +149,7 @@ pub fn opt_encl_scope(&self, id: ast::NodeId) -> Option<ast::NodeId> {
         self.scope_map.borrow().find(&id).map(|x| *x)
     }
 
+    #[allow(dead_code)] // used in middle::cfg
     pub fn encl_scope(&self, id: ast::NodeId) -> ast::NodeId {
         //! Returns the narrowest scope that encloses `id`, if any.
         match self.scope_map.borrow().find(&id) {
@@ -203,12 +204,6 @@ pub fn temporary_scope(&self, expr_id: ast::NodeId) -> Option<ast::NodeId> {
         return Some(id);
     }
 
-    pub fn encl_region(&self, id: ast::NodeId) -> ty::Region {
-        //! Returns the narrowest scope region that encloses `id`, if any.
-
-        ty::ReScope(self.encl_scope(id))
-    }
-
     pub fn var_region(&self, id: ast::NodeId) -> ty::Region {
         //! Returns the lifetime of the variable `id`.
 
index c727744b4c76574170236390dfa91aa0615a83a3..b42721b754b54f788f47c0f548871c6cbd9dc62a 100644 (file)
@@ -644,25 +644,6 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint {
     }
 }
 
-/// Access a field, at a point when the value's case is known.
-pub fn deref_ty(ccx: &CrateContext, r: &Repr) -> ty::t {
-    match *r {
-        CEnum(..) => {
-            ccx.sess().bug("deref of c-like enum")
-        }
-        Univariant(ref st, _) => {
-            *st.fields.get(0)
-        }
-        General(_, ref cases) => {
-            assert!(cases.len() == 1);
-            *cases.get(0).fields.get(0)
-        }
-        NullablePointer{ .. } => {
-            ccx.sess().bug("deref of nullable ptr")
-        }
-    }
-}
-
 /// Access a field, at a point when the value's case is known.
 pub fn trans_field_ptr(bcx: &Block, r: &Repr, val: ValueRef, discr: Disr,
                        ix: uint) -> ValueRef {
@@ -896,11 +877,3 @@ fn const_struct_field(ccx: &CrateContext, val: ValueRef, ix: uint)
         real_ix = real_ix + 1;
     }
 }
-
-/// Is it safe to bitcast a value to the one field of its one variant?
-pub fn is_newtypeish(r: &Repr) -> bool {
-    match *r {
-        Univariant(ref st, false) => st.fields.len() == 1,
-        _ => false
-    }
-}
index 8ac7bd1b66b683638da3a3bc601331f78240ae09..133634a9e791cf94dfb36144d1cfb9bb48fff279 100644 (file)
 use std::libc::c_uint;
 use std::local_data;
 use syntax::abi::{X86, X86_64, Arm, Mips, Rust, RustIntrinsic};
-use syntax::ast_map::PathName;
 use syntax::ast_util::{local_def, is_local};
 use syntax::attr::AttrMetaMethods;
 use syntax::attr;
 use syntax::codemap::Span;
 use syntax::parse::token::InternedString;
-use syntax::parse::token;
 use syntax::visit::Visitor;
 use syntax::visit;
 use syntax::{ast, ast_util, ast_map};
@@ -447,10 +445,6 @@ pub fn malloc_general<'a>(bcx: &'a Block<'a>, t: ty::t, heap: heap)
 
 // Type descriptor and type glue stuff
 
-pub fn get_tydesc_simple(ccx: &CrateContext, t: ty::t) -> ValueRef {
-    get_tydesc(ccx, t).tydesc
-}
-
 pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
     match ccx.tydescs.borrow().find(&t) {
         Some(&inf) => return inf,
@@ -464,6 +458,7 @@ pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> @tydesc_info {
     return inf;
 }
 
+#[allow(dead_code)] // useful
 pub fn set_optimize_for_size(f: ValueRef) {
     lib::llvm::SetFunctionAttribute(f, lib::llvm::OptimizeForSizeAttribute)
 }
@@ -472,6 +467,7 @@ pub fn set_no_inline(f: ValueRef) {
     lib::llvm::SetFunctionAttribute(f, lib::llvm::NoInlineAttribute)
 }
 
+#[allow(dead_code)] // useful
 pub fn set_no_unwind(f: ValueRef) {
     lib::llvm::SetFunctionAttribute(f, lib::llvm::NoUnwindAttribute)
 }
@@ -667,19 +663,6 @@ fn die(cx: &Block) -> ! {
 pub type val_and_ty_fn<'r,'b> =
     'r |&'b Block<'b>, ValueRef, ty::t| -> &'b Block<'b>;
 
-pub fn load_inbounds<'a>(cx: &'a Block<'a>, p: ValueRef, idxs: &[uint])
-                     -> ValueRef {
-    return Load(cx, GEPi(cx, p, idxs));
-}
-
-pub fn store_inbounds<'a>(
-                      cx: &'a Block<'a>,
-                      v: ValueRef,
-                      p: ValueRef,
-                      idxs: &[uint]) {
-    Store(cx, v, GEPi(cx, p, idxs));
-}
-
 // Iterates through the elements of a structural type.
 pub fn iter_structural_ty<'r,
                           'b>(
@@ -975,29 +958,6 @@ pub fn need_invoke(bcx: &Block) -> bool {
     bcx.fcx.needs_invoke()
 }
 
-pub fn do_spill(bcx: &Block, v: ValueRef, t: ty::t) -> ValueRef {
-    if ty::type_is_bot(t) {
-        return C_null(Type::i8p(bcx.ccx()));
-    }
-    let llptr = alloc_ty(bcx, t, "");
-    Store(bcx, v, llptr);
-    return llptr;
-}
-
-// Since this function does *not* root, it is the caller's responsibility to
-// ensure that the referent is pointed to by a root.
-pub fn do_spill_noroot(cx: &Block, v: ValueRef) -> ValueRef {
-    let llptr = alloca(cx, val_ty(v), "");
-    Store(cx, v, llptr);
-    return llptr;
-}
-
-pub fn spill_if_immediate(cx: &Block, v: ValueRef, t: ty::t) -> ValueRef {
-    let _icx = push_ctxt("spill_if_immediate");
-    if type_is_immediate(cx.ccx(), t) { return do_spill(cx, v, t); }
-    return v;
-}
-
 pub fn load_if_immediate(cx: &Block, v: ValueRef, t: ty::t) -> ValueRef {
     let _icx = push_ctxt("load_if_immediate");
     if type_is_immediate(cx.ccx(), t) { return Load(cx, v); }
@@ -1040,20 +1000,6 @@ pub fn raw_block<'a>(
     Block::new(llbb, is_lpad, None, fcx)
 }
 
-pub fn block_locals(b: &ast::Block, it: |@ast::Local|) {
-    for s in b.stmts.iter() {
-        match s.node {
-          ast::StmtDecl(d, _) => {
-            match d.node {
-              ast::DeclLocal(ref local) => it(*local),
-              _ => {} /* fall through */
-            }
-          }
-          _ => {} /* fall through */
-        }
-    }
-}
-
 pub fn with_cond<'a>(
                  bcx: &'a Block<'a>,
                  val: ValueRef,
@@ -1173,10 +1119,6 @@ pub fn arrayalloca(cx: &Block, ty: Type, v: ValueRef) -> ValueRef {
     return ArrayAlloca(cx, ty, v);
 }
 
-pub struct BasicBlocks {
-    sa: BasicBlockRef,
-}
-
 // Creates and returns space for, or returns the argument representing, the
 // slot where the return value of the function must go.
 pub fn make_return_pointer(fcx: &FunctionContext, output_type: ty::t)
@@ -2142,11 +2084,6 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
     llfn
 }
 
-pub fn vp2i(cx: &Block, v: ValueRef) -> ValueRef {
-    let ccx = cx.ccx();
-    return PtrToInt(cx, v, ccx.int_type);
-}
-
 pub fn p2i(ccx: &CrateContext, v: ValueRef) -> ValueRef {
     unsafe {
         return llvm::LLVMConstPtrToInt(v, ccx.int_type.to_ref());
@@ -2315,18 +2252,6 @@ macro_rules! compatible_ifn (
     }
 }
 
-pub fn trap(bcx: &Block) {
-    match bcx.ccx().intrinsics.find_equiv(& &"llvm.trap") {
-      Some(&x) => { Call(bcx, x, [], []); },
-      _ => bcx.sess().bug("unbound llvm.trap in trap")
-    }
-}
-
-pub fn symname(name: &str, hash: &str, vers: &str) -> ~str {
-    let path = [PathName(token::intern(name))];
-    link::exported_name(ast_map::Values(path.iter()).chain(None), hash, vers)
-}
-
 pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::EncodeInlinedItem<'r>)
     -> encoder::EncodeParams<'r> {
 
index c7c0d51b3abd8d400f332598ec21280e7e62b79d..f40a9ede8622e268c916faa2506bf8f85c0399e9 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![allow(dead_code)] // FFI wrappers
 
 use lib::llvm::llvm;
 use lib::llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect};
index 2703ddddc8b7fe32d094a6912929ad57cdf2ef45..07017de2bc2bcd1dadf67c5882860ccc95385f30 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![allow(dead_code)] // FFI wrappers
+
 use lib;
 use lib::llvm::llvm;
 use lib::llvm::{CallConv, AtomicBinOp, AtomicOrdering, AsmDialect};
index 9ce277a7de904691b6cd0f261f640271982cb607..2c9be587eaa9ec3bbdfa81b4cc6b191e5d3a5522 100644 (file)
@@ -79,10 +79,6 @@ pub fn ignore(ty: Type) -> ArgType {
         }
     }
 
-    pub fn is_direct(&self) -> bool {
-        return self.kind == Direct;
-    }
-
     pub fn is_indirect(&self) -> bool {
         return self.kind == Indirect;
     }
index dae48512ac2a787b1ef454612c55855aac0b2554..dae4b2b471b309ba6c8323b8a930a6e28276d004 100644 (file)
@@ -512,48 +512,6 @@ pub fn trans_lang_call<'a>(
                              dest)
 }
 
-pub fn trans_lang_call_with_type_params<'a>(
-                                        bcx: &'a Block<'a>,
-                                        did: ast::DefId,
-                                        args: &[ValueRef],
-                                        type_params: &[ty::t],
-                                        dest: expr::Dest)
-                                        -> &'a Block<'a> {
-    let fty;
-    if did.krate == ast::LOCAL_CRATE {
-        fty = ty::node_id_to_type(bcx.tcx(), did.node);
-    } else {
-        fty = csearch::get_type(bcx.tcx(), did).ty;
-    }
-
-    return callee::trans_call_inner(
-        bcx,
-        None,
-        fty,
-        |bcx, _| {
-            let callee =
-                trans_fn_ref_with_vtables_to_callee(bcx, did, 0,
-                                                    type_params,
-                                                    None);
-
-            let new_llval;
-            match callee.data {
-                Fn(llfn) => {
-                    let substituted = ty::subst_tps(callee.bcx.tcx(),
-                                                    type_params,
-                                                    None,
-                                                    fty);
-                    let llfnty = type_of::type_of(callee.bcx.ccx(),
-                                                      substituted);
-                    new_llval = PointerCast(callee.bcx, llfn, llfnty);
-                }
-                _ => fail!()
-            }
-            Callee { bcx: callee.bcx, data: Fn(new_llval) }
-        },
-        ArgVals(args), Some(dest)).bcx;
-}
-
 pub fn trans_call_inner<'a>(
                         bcx: &'a Block<'a>,
                         call_info: Option<NodeInfo>,
index dce4750969d19de2acc563ba3b8e50f1aeacb5f9..4833a233423851e3106c5845f23213d530999c2b 100644 (file)
@@ -24,7 +24,6 @@
 use middle::trans::datum::{Datum, Lvalue};
 use middle::trans::debuginfo;
 use middle::trans::type_::Type;
-use middle::ty::substs;
 use middle::ty;
 use middle::typeck;
 use util::ppaux::Repr;
@@ -456,14 +455,6 @@ pub fn expr_to_str(&self, e: &ast::Expr) -> ~str {
         e.repr(self.tcx())
     }
 
-    pub fn expr_is_lval(&self, e: &ast::Expr) -> bool {
-        ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e)
-    }
-
-    pub fn expr_kind(&self, e: &ast::Expr) -> ty::ExprKind {
-        ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e)
-    }
-
     pub fn def(&self, nid: ast::NodeId) -> ast::Def {
         match self.tcx().def_map.borrow().find(&nid) {
             Some(&v) => v,
@@ -504,13 +495,6 @@ pub fn rslt<'a>(bcx: &'a Block<'a>, val: ValueRef) -> Result<'a> {
     }
 }
 
-impl<'a> Result<'a> {
-    pub fn unpack(&self, bcx: &mut &'a Block<'a>) -> ValueRef {
-        *bcx = self.bcx;
-        return self.val;
-    }
-}
-
 pub fn val_ty(v: ValueRef) -> Type {
     unsafe {
         Type::from_ref(llvm::LLVMTypeOf(v))
@@ -749,22 +733,6 @@ pub struct mono_id_ {
 
 pub type mono_id = @mono_id_;
 
-pub fn umax(cx: &Block, a: ValueRef, b: ValueRef) -> ValueRef {
-    let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
-    return build::Select(cx, cond, b, a);
-}
-
-pub fn umin(cx: &Block, a: ValueRef, b: ValueRef) -> ValueRef {
-    let cond = build::ICmp(cx, lib::llvm::IntULT, a, b);
-    return build::Select(cx, cond, a, b);
-}
-
-pub fn align_to(cx: &Block, off: ValueRef, align: ValueRef) -> ValueRef {
-    let mask = build::Sub(cx, align, C_int(cx.ccx(), 1));
-    let bumped = build::Add(cx, off, mask);
-    return build::And(cx, bumped, build::Not(cx, mask));
-}
-
 pub fn monomorphize_type(bcx: &Block, t: ty::t) -> ty::t {
     match bcx.fcx.param_substs {
         Some(substs) => {
@@ -928,14 +896,6 @@ pub fn find_vtable(tcx: &ty::ctxt,
     param_bounds.get(n_bound).clone()
 }
 
-pub fn dummy_substs(tps: Vec<ty::t> ) -> ty::substs {
-    substs {
-        regions: ty::ErasedRegions,
-        self_ty: None,
-        tps: tps
-    }
-}
-
 pub fn filename_and_line_num_from_span(bcx: &Block, span: Span)
                                        -> (ValueRef, ValueRef) {
     let loc = bcx.sess().codemap().lookup_char_pos(span.lo);
index a7fed4fa60d3fe728a57342006d5b971aa7f72d2..f98a77eed65a004ce886ba8fcfd29c63f3bfd818 100644 (file)
@@ -20,7 +20,6 @@
 use middle::trans::adt;
 use middle::trans::base;
 use middle::trans::builder::Builder;
-use middle::trans::common::{C_i32, C_null};
 use middle::trans::common::{mono_id,ExternMap,tydesc_info,BuilderRef_res,Stats};
 use middle::trans::debuginfo;
 use middle::trans::type_::Type;
@@ -30,7 +29,6 @@
 
 use std::cell::{Cell, RefCell};
 use std::c_str::ToCStr;
-use std::libc::c_uint;
 use std::ptr;
 use collections::{HashMap, HashSet};
 use syntax::ast;
@@ -51,45 +49,45 @@ pub struct CrateContext {
     pub link_meta: LinkMeta,
     pub drop_glues: RefCell<HashMap<ty::t, ValueRef>>,
     pub tydescs: RefCell<HashMap<ty::t, @tydesc_info>>,
-    // Set when running emit_tydescs to enforce that no more tydescs are
-    // created.
+    /// Set when running emit_tydescs to enforce that no more tydescs are
+    /// created.
     pub finished_tydescs: Cell<bool>,
-    // Track mapping of external ids to local items imported for inlining
+    /// Track mapping of external ids to local items imported for inlining
     pub external: RefCell<DefIdMap<Option<ast::NodeId>>>,
-    // Backwards version of the `external` map (inlined items to where they
-    // came from)
+    /// Backwards version of the `external` map (inlined items to where they
+    /// came from)
     pub external_srcs: RefCell<NodeMap<ast::DefId>>,
-    // A set of static items which cannot be inlined into other crates. This
-    // will pevent in IIItem() structures from being encoded into the metadata
-    // that is generated
+    /// A set of static items which cannot be inlined into other crates. This
+    /// will pevent in IIItem() structures from being encoded into the metadata
+    /// that is generated
     pub non_inlineable_statics: RefCell<NodeSet>,
-    // Cache instances of monomorphized functions
+    /// Cache instances of monomorphized functions
     pub monomorphized: RefCell<HashMap<mono_id, ValueRef>>,
     pub monomorphizing: RefCell<DefIdMap<uint>>,
-    // Cache generated vtables
+    /// Cache generated vtables
     pub vtables: RefCell<HashMap<(ty::t, mono_id), ValueRef>>,
-    // Cache of constant strings,
+    /// Cache of constant strings,
     pub const_cstr_cache: RefCell<HashMap<InternedString, ValueRef>>,
 
-    // Reverse-direction for const ptrs cast from globals.
-    // Key is an int, cast from a ValueRef holding a *T,
-    // Val is a ValueRef holding a *[T].
-    //
-    // Needed because LLVM loses pointer->pointee association
-    // when we ptrcast, and we have to ptrcast during translation
-    // of a [T] const because we form a slice, a [*T,int] pair, not
-    // a pointer to an LLVM array type.
+    /// Reverse-direction for const ptrs cast from globals.
+    /// Key is an int, cast from a ValueRef holding a *T,
+    /// Val is a ValueRef holding a *[T].
+    ///
+    /// Needed because LLVM loses pointer->pointee association
+    /// when we ptrcast, and we have to ptrcast during translation
+    /// of a [T] const because we form a slice, a [*T,int] pair, not
+    /// a pointer to an LLVM array type.
     pub const_globals: RefCell<HashMap<int, ValueRef>>,
 
-    // Cache of emitted const values
+    /// Cache of emitted const values
     pub const_values: RefCell<NodeMap<ValueRef>>,
 
-    // Cache of external const values
+    /// Cache of external const values
     pub extern_const_values: RefCell<DefIdMap<ValueRef>>,
 
     pub impl_method_cache: RefCell<HashMap<(ast::DefId, ast::Name), ast::DefId>>,
 
-    // Cache of closure wrappers for bare fn's.
+    /// Cache of closure wrappers for bare fn's.
     pub closure_bare_wrapper_cache: RefCell<HashMap<ValueRef, ValueRef>>,
 
     pub lltypes: RefCell<HashMap<ty::t, Type>>,
@@ -104,9 +102,9 @@ pub struct CrateContext {
     pub int_type: Type,
     pub opaque_vec_type: Type,
     pub builder: BuilderRef_res,
-    // Set when at least one function uses GC. Needed so that
-    // decl_gc_metadata knows whether to link to the module metadata, which
-    // is not emitted by LLVM's GC pass when no functions use GC.
+    /// Set when at least one function uses GC. Needed so that
+    /// decl_gc_metadata knows whether to link to the module metadata, which
+    /// is not emitted by LLVM's GC pass when no functions use GC.
     pub uses_gc: bool,
     pub dbg_cx: Option<debuginfo::CrateDebugContext>,
 }
@@ -232,36 +230,6 @@ pub fn builder<'a>(&'a self) -> Builder<'a> {
         Builder::new(self)
     }
 
-    pub fn const_inbounds_gepi(&self,
-                               pointer: ValueRef,
-                               indices: &[uint]) -> ValueRef {
-        debug!("const_inbounds_gepi: pointer={} indices={:?}",
-               self.tn.val_to_str(pointer), indices);
-        let v: Vec<ValueRef> =
-            indices.iter().map(|i| C_i32(self, *i as i32)).collect();
-        unsafe {
-            llvm::LLVMConstInBoundsGEP(pointer,
-                                       v.as_ptr(),
-                                       indices.len() as c_uint)
-        }
-    }
-
-    pub fn offsetof_gep(&self,
-                        llptr_ty: Type,
-                        indices: &[uint]) -> ValueRef {
-        /*!
-         * Returns the offset of applying the given GEP indices
-         * to an instance of `llptr_ty`. Similar to `offsetof` in C,
-         * except that `llptr_ty` must be a pointer type.
-         */
-
-        unsafe {
-            let null = C_null(llptr_ty);
-            llvm::LLVMConstPtrToInt(self.const_inbounds_gepi(null, indices),
-                                    self.int_type.to_ref())
-        }
-    }
-
     pub fn tydesc_type(&self) -> Type {
         self.tn.find_type("tydesc").unwrap()
     }
index 9f48e4714d60dbdbd0b40709c83b8b24bfbee864..500a36c5dee60f7fc32527779158c1d425d5609c 100644 (file)
 use middle::trans::glue;
 use middle::trans::tvec;
 use middle::trans::type_of;
-use middle::trans::write_guard;
 use middle::ty;
 use util::ppaux::{ty_to_str};
 
 use syntax::ast;
-use syntax::codemap::Span;
 
 /**
  * A `Datum` encapsulates the result of evaluating an expression.  It
@@ -160,10 +158,6 @@ pub fn rvalue_scratch_datum(bcx: &Block,
     Datum(scratch, ty, Rvalue(ByRef))
 }
 
-pub fn is_by_value_type(ccx: &CrateContext, ty: ty::t) -> bool {
-    appropriate_rvalue_mode(ccx, ty) == ByValue
-}
-
 pub fn appropriate_rvalue_mode(ccx: &CrateContext, ty: ty::t) -> RvalueMode {
     /*!
      * Indicates the "appropriate" mode for this value,
@@ -389,10 +383,7 @@ fn match_kind<R>(self,
         }
     }
 
-    pub fn is_by_ref(&self) -> bool {
-        self.kind.is_by_ref()
-    }
-
+    #[allow(dead_code)] // potentially useful
     pub fn assert_lvalue(self, bcx: &Block) -> Datum<Lvalue> {
         /*!
          * Asserts that this datum *is* an lvalue and returns it.
@@ -632,6 +623,7 @@ pub fn shallow_copy_and_take<'a>(&self,
         glue::take_ty(bcx, dst, self.ty)
     }
 
+    #[allow(dead_code)] // useful for debugging
     pub fn to_str(&self, ccx: &CrateContext) -> ~str {
         format!("Datum({}, {}, {:?})",
              ccx.tn.val_to_str(self.val),
@@ -645,16 +637,6 @@ pub fn appropriate_rvalue_mode(&self, ccx: &CrateContext) -> RvalueMode {
         appropriate_rvalue_mode(ccx, self.ty)
     }
 
-    pub fn root_and_write_guard<'a>(
-                                &self,
-                                bcx: &'a Block<'a>,
-                                span: Span,
-                                expr_id: ast::NodeId,
-                                derefs: uint)
-                                -> &'a Block<'a> {
-        write_guard::root_and_write_guard(self, bcx, span, expr_id, derefs)
-    }
-
     pub fn to_llscalarish<'a>(self, bcx: &'a Block<'a>) -> ValueRef {
         /*!
          * Converts `self` into a by-value `ValueRef`. Consumes this
@@ -688,16 +670,6 @@ pub fn to_expr_datumblock(self) -> DatumBlock<'a, Expr> {
 }
 
 impl<'a> DatumBlock<'a, Expr> {
-    pub fn assert_by_ref(self) -> DatumBlock<'a, Expr> {
-        assert!(self.datum.kind.is_by_ref());
-        self
-    }
-
-    pub fn store_to(self, dst: ValueRef) -> &'a Block<'a> {
-        let DatumBlock { bcx, datum } = self;
-        datum.store_to(bcx, dst)
-    }
-
     pub fn store_to_dest(self,
                          dest: expr::Dest,
                          expr_id: ast::NodeId) -> &'a Block<'a> {
@@ -705,22 +677,6 @@ pub fn store_to_dest(self,
         datum.store_to_dest(bcx, dest, expr_id)
     }
 
-    pub fn shallow_copy(self, dst: ValueRef) -> &'a Block<'a> {
-        self.datum.shallow_copy(self.bcx, dst)
-    }
-
-    pub fn ccx(&self) -> &'a CrateContext {
-        self.bcx.ccx()
-    }
-
-    pub fn tcx(&self) -> &'a ty::ctxt {
-        self.bcx.tcx()
-    }
-
-    pub fn to_str(&self) -> ~str {
-        self.datum.to_str(self.ccx())
-    }
-
     pub fn to_llbool(self) -> Result<'a> {
         let DatumBlock { datum, bcx } = self;
         rslt(bcx, datum.to_llbool(bcx))
index 3d4a33c217d813daffb748e491f1535a8a55f1fd..a206d42e5899916b6fe9ddeded2a6c9fbc257e48 100644 (file)
@@ -74,22 +74,6 @@ pub fn trans_impl(ccx: &CrateContext,
     }
 }
 
-/// Translates a (possibly monomorphized) method body.
-///
-/// Parameters:
-/// * `method`: the AST node for the method
-/// * `param_substs`: if this is a generic method, the current values for
-///   type parameters and so forth, else None
-/// * `llfn`: the LLVM ValueRef for the method
-///
-pub fn trans_method(ccx: &CrateContext, method: &ast::Method,
-                    param_substs: Option<@param_substs>,
-                    llfn: ValueRef) -> ValueRef {
-    trans_fn(ccx, method.decl, method.body,
-             llfn, param_substs, method.id, []);
-    llfn
-}
-
 pub fn trans_method_callee<'a>(
                            bcx: &'a Block<'a>,
                            method_call: MethodCall,
index 01e52fda4cb34ae9b170645d75014cbaa4bd6a06..7ad9010829c7fc8755419cff13266789fdad25ce 100644 (file)
@@ -46,10 +46,6 @@ pub fn c_uint(&mut self, u: uint) -> ValueRef {
         C_uint(self.bcx.ccx(), u)
     }
 
-    pub fn c_int(&mut self, i: int) -> ValueRef {
-        C_int(self.bcx.ccx(), i)
-    }
-
     pub fn c_bool(&mut self, b: bool) -> ValueRef {
         C_bool(self.bcx.ccx(), b)
     }
index 4aac50c5355af9c10c09d45a9b43b3c306e7aae9..d8154c6b1f5b5818871d4bca3c41a77d922e9c72 100644 (file)
@@ -55,14 +55,6 @@ pub fn get_fill(bcx: &Block, vptr: ValueRef) -> ValueRef {
     Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]))
 }
 
-pub fn set_fill(bcx: &Block, vptr: ValueRef, fill: ValueRef) {
-    Store(bcx, fill, GEPi(bcx, vptr, [0u, abi::vec_elt_fill]));
-}
-
-pub fn get_alloc(bcx: &Block, vptr: ValueRef) -> ValueRef {
-    Load(bcx, GEPi(bcx, vptr, [0u, abi::vec_elt_alloc]))
-}
-
 pub fn get_dataptr(bcx: &Block, vptr: ValueRef) -> ValueRef {
     let _icx = push_ctxt("tvec::get_dataptr");
     GEPi(bcx, vptr, [0u, abi::vec_elt_elems, 0u])
@@ -102,15 +94,6 @@ pub fn alloc_raw<'a>(
     }
 }
 
-pub fn alloc_uniq_raw<'a>(
-                      bcx: &'a Block<'a>,
-                      unit_ty: ty::t,
-                      fill: ValueRef,
-                      alloc: ValueRef)
-                      -> Result<'a> {
-    alloc_raw(bcx, unit_ty, fill, alloc, heap_exchange)
-}
-
 pub fn alloc_uniq_vec<'a>(
                  bcx: &'a Block<'a>,
                  unit_ty: ty::t,
@@ -693,19 +676,6 @@ pub fn iter_vec_raw<'r,
     }
 }
 
-pub fn iter_vec_uniq<'r,
-                     'b>(
-                     bcx: &'b Block<'b>,
-                     vptr: ValueRef,
-                     vec_ty: ty::t,
-                     fill: ValueRef,
-                     f: iter_vec_block<'r,'b>)
-                     -> &'b Block<'b> {
-    let _icx = push_ctxt("tvec::iter_vec_uniq");
-    let data_ptr = get_dataptr(bcx, vptr);
-    iter_vec_raw(bcx, data_ptr, vec_ty, fill, f)
-}
-
 pub fn iter_vec_unboxed<'r,
                         'b>(
                         bcx: &'b Block<'b>,
index ca01c0532fc39f1cac3d73bdd7d10ce168886aba..55ffa951cf2d7f62b45d81d50db571c9e2a914b4 100644 (file)
@@ -20,7 +20,6 @@
 
 use std::c_str::ToCStr;
 use std::cast;
-use std::slice;
 
 use std::libc::{c_uint};
 
@@ -135,10 +134,6 @@ pub fn float_from_ty(ccx: &CrateContext, t: ast::FloatTy) -> Type {
         }
     }
 
-    pub fn size_t(ccx: &CrateContext) -> Type {
-        Type::int(ccx)
-    }
-
     pub fn func(args: &[Type], ret: &Type) -> Type {
         let vec : &[TypeRef] = unsafe { cast::transmute(args) };
         ty!(llvm::LLVMFunctionType(ret.to_ref(), vec.as_ptr(),
@@ -151,10 +146,6 @@ pub fn variadic_func(args: &[Type], ret: &Type) -> Type {
                                    args.len() as c_uint, True))
     }
 
-    pub fn ptr(ty: Type) -> Type {
-        ty!(llvm::LLVMPointerType(ty.to_ref(), 0 as c_uint))
-    }
-
     pub fn struct_(ccx: &CrateContext, els: &[Type], packed: bool) -> Type {
         let els : &[TypeRef] = unsafe { cast::transmute(els) };
         ty!(llvm::LLVMStructTypeInContext(ccx.llcx, els.as_ptr(),
@@ -259,17 +250,6 @@ pub fn ptr_to(&self) -> Type {
         ty!(llvm::LLVMPointerType(self.to_ref(), 0))
     }
 
-    pub fn get_field(&self, idx: uint) -> Type {
-        unsafe {
-            let num_fields = llvm::LLVMCountStructElementTypes(self.to_ref()) as uint;
-            let mut elems = slice::from_elem(num_fields, 0 as TypeRef);
-
-            llvm::LLVMGetStructElementTypes(self.to_ref(), elems.as_mut_ptr());
-
-            Type::from_ref(elems[idx])
-        }
-    }
-
     pub fn is_packed(&self) -> bool {
         unsafe {
             llvm::LLVMIsPackedStruct(self.to_ref()) == True
index 176ed409dd49f6bfb8082600277f542c3c2b7f81..f9296926c748a22128e63c4296658fca631bb435 100644 (file)
@@ -411,9 +411,6 @@ pub fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
 pub fn type_needs_infer(t: t) -> bool {
     tbox_has_flag(get(t), needs_infer)
 }
-pub fn type_has_regions(t: t) -> bool {
-    tbox_has_flag(get(t), has_regions)
-}
 pub fn type_id(t: t) -> uint { get(t).id }
 
 #[deriving(Clone, Eq, TotalEq, Hash)]
@@ -1506,10 +1503,6 @@ pub fn walk_regions_and_ty(cx: &ctxt, ty: t, fldr: |r: Region|, fldt: |t: t|)
                                    |t| { fldt(t); t }).fold_ty(ty)
 }
 
-pub fn fold_regions(cx: &ctxt, ty: t, fldr: |r: Region| -> Region) -> t {
-    ty_fold::RegionFolder::regions(cx, fldr).fold_ty(ty)
-}
-
 // Substitute *only* type parameters.  Used in trans where regions are erased.
 pub fn subst_tps(tcx: &ctxt, tps: &[t], self_ty_opt: Option<t>, typ: t) -> t {
     let mut subst = TpsSubst { tcx: tcx, self_ty_opt: self_ty_opt, tps: tps };
@@ -1623,13 +1616,6 @@ pub fn type_is_structural(ty: t) -> bool {
     }
 }
 
-pub fn type_is_sequence(ty: t) -> bool {
-    match get(ty).sty {
-      ty_str(_) | ty_vec(_, _) => true,
-      _ => false
-    }
-}
-
 pub fn type_is_simd(cx: &ctxt, ty: t) -> bool {
     match get(ty).sty {
         ty_struct(did, _) => lookup_simd(cx, did),
@@ -1637,13 +1623,6 @@ pub fn type_is_simd(cx: &ctxt, ty: t) -> bool {
     }
 }
 
-pub fn type_is_str(ty: t) -> bool {
-    match get(ty).sty {
-      ty_str(_) => true,
-      _ => false
-    }
-}
-
 pub fn sequence_element_type(cx: &ctxt, ty: t) -> t {
     match get(ty).sty {
       ty_str(_) => return mk_mach_uint(ast::TyU8),
@@ -1672,20 +1651,6 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint {
     }
 }
 
-pub fn get_element_type(ty: t, i: uint) -> t {
-    match get(ty).sty {
-      ty_tup(ref ts) => return *ts.get(i),
-      _ => fail!("get_element_type called on invalid type")
-    }
-}
-
-pub fn type_is_box(ty: t) -> bool {
-    match get(ty).sty {
-      ty_box(_) => return true,
-      _ => return false
-    }
-}
-
 pub fn type_is_boxed(ty: t) -> bool {
     match get(ty).sty {
       ty_box(_) => true,
@@ -1700,20 +1665,6 @@ pub fn type_is_region_ptr(ty: t) -> bool {
     }
 }
 
-pub fn type_is_slice(ty: t) -> bool {
-    match get(ty).sty {
-      ty_vec(_, vstore_slice(_)) | ty_str(vstore_slice(_)) => true,
-      _ => return false
-    }
-}
-
-pub fn type_is_unique_box(ty: t) -> bool {
-    match get(ty).sty {
-      ty_uniq(_) => return true,
-      _ => return false
-    }
-}
-
 pub fn type_is_unsafe_ptr(ty: t) -> bool {
     match get(ty).sty {
       ty_ptr(_) => return true,
@@ -1721,14 +1672,6 @@ pub fn type_is_unsafe_ptr(ty: t) -> bool {
     }
 }
 
-pub fn type_is_vec(ty: t) -> bool {
-    return match get(ty).sty {
-          ty_vec(_, _) | ty_unboxed_vec(_) => true,
-          ty_str(_) => true,
-          _ => false
-        };
-}
-
 pub fn type_is_unique(ty: t) -> bool {
     match get(ty).sty {
         ty_uniq(_) | ty_vec(_, vstore_uniq) | ty_str(vstore_uniq) => true,
@@ -1920,10 +1863,6 @@ mod TC {
 )
 
 impl TypeContents {
-    pub fn meets_bounds(&self, cx: &ctxt, bbs: BuiltinBounds) -> bool {
-        bbs.iter().all(|bb| self.meets_bound(cx, bb))
-    }
-
     pub fn meets_bound(&self, cx: &ctxt, bb: BuiltinBound) -> bool {
         match bb {
             BoundStatic => self.is_static(cx),
@@ -2021,10 +1960,6 @@ pub fn union<T>(v: &[T], f: |&T| -> TypeContents) -> TypeContents {
         v.iter().fold(TC::None, |tc, t| tc | f(t))
     }
 
-    pub fn inverse(&self) -> TypeContents {
-        TypeContents { bits: !self.bits }
-    }
-
     pub fn has_dtor(&self) -> bool {
         self.intersects(TC::OwnsDtor)
     }
@@ -2054,10 +1989,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-pub fn type_has_dtor(cx: &ctxt, t: ty::t) -> bool {
-    type_contents(cx, t).has_dtor()
-}
-
 pub fn type_is_static(cx: &ctxt, t: ty::t) -> bool {
     type_contents(cx, t).is_static(cx)
 }
@@ -2649,14 +2580,8 @@ pub fn type_is_machine(ty: t) -> bool {
     }
 }
 
-pub fn type_is_enum(ty: t) -> bool {
-    match get(ty).sty {
-      ty_enum(_, _) => return true,
-      _ => return false
-    }
-}
-
 // Is the type's representation size known at compile time?
+#[allow(dead_code)] // leaving in for DST
 pub fn type_is_sized(cx: &ctxt, ty: ty::t) -> bool {
     match get(ty).sty {
         // FIXME(#6308) add trait, vec, str, etc here.
@@ -2688,14 +2613,6 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: t) -> bool {
     }
 }
 
-pub fn type_param(ty: t) -> Option<uint> {
-    match get(ty).sty {
-      ty_param(p) => return Some(p.idx),
-      _ => {/* fall through */ }
-    }
-    return None;
-}
-
 // Returns the type and mutability of *t.
 //
 // The parameter `explicit` indicates if this is an *explicit* dereference.
@@ -2758,10 +2675,6 @@ pub fn node_id_to_type_params(cx: &ctxt, id: ast::NodeId) -> Vec<t> {
     }
 }
 
-fn node_id_has_type_params(cx: &ctxt, id: ast::NodeId) -> bool {
-    cx.node_type_substs.borrow().contains_key(&id)
-}
-
 pub fn fn_is_variadic(fty: t) -> bool {
     match get(fty).sty {
         ty_bare_fn(ref f) => f.sig.variadic,
@@ -2802,16 +2715,6 @@ pub fn ty_closure_sigil(fty: t) -> Sigil {
     }
 }
 
-pub fn ty_fn_purity(fty: t) -> ast::Purity {
-    match get(fty).sty {
-        ty_bare_fn(ref f) => f.purity,
-        ty_closure(ref f) => f.purity,
-        ref s => {
-            fail!("ty_fn_purity() called on non-fn type: {:?}", s)
-        }
-    }
-}
-
 pub fn ty_fn_ret(fty: t) -> t {
     match get(fty).sty {
         ty_bare_fn(ref f) => f.sig.output,
@@ -2830,14 +2733,6 @@ pub fn is_fn_ty(fty: t) -> bool {
     }
 }
 
-pub fn ty_vstore(ty: t) -> vstore {
-    match get(ty).sty {
-        ty_vec(_, vstore) => vstore,
-        ty_str(vstore) => vstore,
-        ref s => fail!("ty_vstore() called on invalid sty: {:?}", s)
-    }
-}
-
 pub fn ty_region(tcx: &ctxt,
                  span: Span,
                  ty: t) -> Region {
@@ -2853,49 +2748,6 @@ pub fn ty_region(tcx: &ctxt,
     }
 }
 
-pub fn replace_fn_sig(cx: &ctxt, fsty: &sty, new_sig: FnSig) -> t {
-    match *fsty {
-        ty_bare_fn(ref f) => mk_bare_fn(cx, BareFnTy {sig: new_sig, ..*f}),
-        ty_closure(ref f) => mk_closure(cx, ClosureTy {sig: new_sig, ..**f}),
-        ref s => {
-            cx.sess.bug(
-                format!("ty_fn_sig() called on non-fn type: {:?}", s));
-        }
-    }
-}
-
-pub fn replace_closure_return_type(tcx: &ctxt, fn_type: t, ret_type: t) -> t {
-    /*!
-     *
-     * Returns a new function type based on `fn_type` but returning a value of
-     * type `ret_type` instead. */
-
-    match ty::get(fn_type).sty {
-        ty::ty_closure(ref fty) => {
-            ty::mk_closure(tcx, ClosureTy {
-                sig: FnSig {output: ret_type, ..fty.sig.clone()},
-                ..(**fty).clone()
-            })
-        }
-        _ => {
-            tcx.sess.bug(format!(
-                "replace_fn_ret() invoked with non-fn-type: {}",
-                ty_to_str(tcx, fn_type)));
-        }
-    }
-}
-
-// Returns a vec of all the input and output types of fty.
-pub fn tys_in_fn_sig(sig: &FnSig) -> Vec<t> {
-    sig.inputs.iter().map(|a| *a).collect::<Vec<_>>().append_one(sig.output)
-}
-
-// Type accessors for AST nodes
-pub fn block_ty(cx: &ctxt, b: &ast::Block) -> t {
-    return node_id_to_type(cx, b.id);
-}
-
-
 // Returns the type of a pattern as a monotype. Like @expr_ty, this function
 // doesn't provide type parameter substitutions.
 pub fn pat_ty(cx: &ctxt, pat: &ast::Pat) -> t {
@@ -3187,6 +3039,7 @@ pub struct ParamsTy {
     pub ty: t
 }
 
+#[allow(dead_code)] // this may be useful?
 pub fn expr_ty_params_and_ty(cx: &ctxt,
                              expr: &ast::Expr)
                           -> ParamsTy {
@@ -3196,10 +3049,6 @@ pub fn expr_ty_params_and_ty(cx: &ctxt,
     }
 }
 
-pub fn expr_has_ty_params(cx: &ctxt, expr: &ast::Expr) -> bool {
-    return node_id_has_type_params(cx, expr.id);
-}
-
 pub fn method_call_type_param_defs(tcx: &ctxt, origin: typeck::MethodOrigin)
                                    -> Rc<Vec<TypeParameterDef>> {
     match origin {
@@ -3423,12 +3272,6 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId {
     }
 }
 
-pub fn field_idx(name: ast::Name, fields: &[field]) -> Option<uint> {
-    let mut i = 0u;
-    for f in fields.iter() { if f.ident.name == name { return Some(i); } i += 1u; }
-    return None;
-}
-
 pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
                      -> uint {
     let mut i = 0u;
@@ -3664,14 +3507,6 @@ pub fn note_and_explain_type_err(cx: &ctxt, err: &type_err) {
     }
 }
 
-pub fn def_has_ty_params(def: ast::Def) -> bool {
-    match def {
-      ast::DefFn(_, _) | ast::DefVariant(_, _, _) | ast::DefStruct(_)
-        => true,
-      _ => false
-    }
-}
-
 pub fn provided_source(cx: &ctxt, id: ast::DefId) -> Option<ast::DefId> {
     cx.provided_method_sources.borrow().find(&id).map(|x| *x)
 }
@@ -3850,8 +3685,8 @@ pub fn try_add_builtin_trait(tcx: &ctxt,
 
 pub fn ty_to_def_id(ty: t) -> Option<ast::DefId> {
     match get(ty).sty {
-      ty_trait(~TyTrait { def_id: id, .. }) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
-      _ => None
+        ty_trait(~TyTrait { def_id: id, .. }) | ty_struct(id, _) | ty_enum(id, _) => Some(id),
+        _ => None
     }
 }
 
@@ -4247,18 +4082,6 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
     }
 }
 
-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,
-        None => cx.sess.bug("struct ID not found in parent's fields")
-    }
-}
-
 fn struct_field_tys(fields: &[StructField]) -> Vec<field_ty> {
     fields.iter().map(|field| {
         match field.node.kind {
@@ -4368,13 +4191,6 @@ fn tycat(cx: &ctxt, ty: t) -> int {
     return tbl[tycat(cx, ty) as uint ][opcat(op) as uint];
 }
 
-pub fn ty_params_to_tys(tcx: &ctxt, generics: &ast::Generics) -> Vec<t> {
-    Vec::from_fn(generics.ty_params.len(), |i| {
-        let id = generics.ty_params.get(i).id;
-        ty::mk_param(tcx, i, ast_util::local_def(id))
-    })
-}
-
 /// Returns an equivalent type with all the typedefs and self regions removed.
 pub fn normalize_ty(cx: &ctxt, t: t) -> t {
     let u = TypeNormalizer(cx).fold_ty(t);
@@ -4554,19 +4370,6 @@ pub fn each_bound_trait_and_supertraits(tcx: &ctxt,
     return true;
 }
 
-pub fn count_traits_and_supertraits(tcx: &ctxt,
-                                    type_param_defs: &[TypeParameterDef]) -> uint {
-    let mut total = 0;
-    for type_param_def in type_param_defs.iter() {
-        each_bound_trait_and_supertraits(
-            tcx, type_param_def.bounds.trait_bounds.as_slice(), |_| {
-            total += 1;
-            true
-        });
-    }
-    return total;
-}
-
 pub fn get_tydesc_ty(tcx: &ctxt) -> Result<t, ~str> {
     tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| {
         tcx.intrinsic_defs.borrow().find_copy(&tydesc_lang_item)
@@ -5050,12 +4853,4 @@ pub fn to_user_str(&self) -> &'static str {
             UniqueImmBorrow => "uniquely immutable",
         }
     }
-
-    pub fn to_short_str(&self) -> &'static str {
-        match *self {
-            MutBorrow => "mut",
-            ImmBorrow => "imm",
-            UniqueImmBorrow => "own",
-        }
-    }
 }
index 4cf3cc51cc1b64116bb6aafdcb1179f7e421cc5c..5752a928358831ca541e9e541e3720f60f554d14 100644 (file)
@@ -510,27 +510,6 @@ fn check_fn<'a>(ccx: &'a CrateCtxt<'a>,
     fcx
 }
 
-pub fn check_no_duplicate_fields(tcx: &ty::ctxt,
-                                 fields: Vec<(ast::Ident, Span)>) {
-    let mut field_names = HashMap::new();
-
-    for p in fields.iter() {
-        let (id, sp) = *p;
-        let orig_sp = field_names.find(&id).map(|x| *x);
-        match orig_sp {
-            Some(orig_sp) => {
-                tcx.sess.span_err(sp, format!("duplicate field name {} in record type declaration",
-                                              token::get_ident(id)));
-                tcx.sess.span_note(orig_sp, "first declaration of this field occurred here");
-                break;
-            }
-            None => {
-                field_names.insert(id, sp);
-            }
-        }
-    }
-}
-
 pub fn check_struct(ccx: &CrateCtxt, id: ast::NodeId, span: Span) {
     let tcx = ccx.tcx;
 
@@ -1010,10 +989,6 @@ pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
         }
     }
 
-    pub fn block_region(&self) -> ty::Region {
-        ty::ReScope(self.region_lb.get())
-    }
-
     #[inline]
     pub fn write_ty(&self, node_id: ast::NodeId, ty: ty::t) {
         debug!("write_ty({}, {}) in fcx {}",
@@ -1100,18 +1075,6 @@ pub fn node_ty(&self, id: ast::NodeId) -> ty::t {
         }
     }
 
-    pub fn node_ty_substs(&self, id: ast::NodeId) -> ty::substs {
-        match self.inh.node_type_substs.borrow().find(&id) {
-            Some(ts) => (*ts).clone(),
-            None => {
-                self.tcx().sess.bug(
-                    format!("no type substs for node {}: {} in fcx {}",
-                            id, self.tcx().map.node_to_str(id),
-                            self.tag()));
-            }
-        }
-    }
-
     pub fn method_ty_substs(&self, id: ast::NodeId) -> ty::substs {
         match self.inh.method_map.borrow().find(&MethodCall::expr(id)) {
             Some(method) => method.substs.clone(),
@@ -1167,11 +1130,6 @@ pub fn mk_assignty(&self,
         }
     }
 
-    pub fn can_mk_assignty(&self, sub: ty::t, sup: ty::t)
-                           -> Result<(), ty::type_err> {
-        infer::can_mk_coercety(self.infcx(), sub, sup)
-    }
-
     pub fn mk_eqty(&self,
                    a_is_expected: bool,
                    origin: infer::TypeOrigin,
@@ -3309,10 +3267,6 @@ pub fn check_block_no_value(fcx: &FnCtxt, blk: &ast::Block)  {
     }
 }
 
-pub fn check_block(fcx0: &FnCtxt, blk: &ast::Block)  {
-    check_block_with_expected(fcx0, blk, None)
-}
-
 pub fn check_block_with_expected(fcx: &FnCtxt,
                                  blk: &ast::Block,
                                  expected: Option<ty::t>) {
index af84e915f70403d4d4901903a0020065ac2b39ba..4a03e32dee8245a20f8e3f2f65064643796a5325 100644 (file)
@@ -373,28 +373,6 @@ pub fn eq_regions<C:Combine>(this: &C, a: ty::Region, b: ty::Region)
     })
 }
 
-pub fn eq_opt_regions<C:Combine>(
-    this: &C,
-    a: Option<ty::Region>,
-    b: Option<ty::Region>) -> cres<Option<ty::Region>> {
-
-    match (a, b) {
-        (None, None) => Ok(None),
-        (Some(a), Some(b)) => eq_regions(this, a, b).then(|| Ok(Some(a))),
-        (_, _) => {
-            // If these two substitutions are for the same type (and
-            // they should be), then the type should either
-            // consistently have a region parameter or not have a
-            // region parameter.
-            this.infcx().tcx.sess.bug(
-                format!("substitution a had opt_region {} and \
-                      b had opt_region {}",
-                     a.inf_str(this.infcx()),
-                     b.inf_str(this.infcx())));
-        }
-    }
-}
-
 pub fn super_fn_sigs<C:Combine>(this: &C, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
 
     fn argvecs<C:Combine>(this: &C, a_args: &[ty::t], b_args: &[ty::t]) -> cres<Vec<ty::t> > {
index e63ad7322b9aebfb2dd5b533fdcb47985a305602..bde750eb6f0de3dd89484fe2786ed472ce249956 100644 (file)
 
 impl<'f> Lub<'f> {
     pub fn get_ref<'a>(&'a self) -> &'a CombineFields<'f> { let Lub(ref v) = *self; v }
-    pub fn bot_ty(&self, b: ty::t) -> cres<ty::t> { Ok(b) }
-    pub fn ty_bot(&self, b: ty::t) -> cres<ty::t> {
-        self.bot_ty(b) // commutative
-    }
 }
 
 impl<'f> Combine for Lub<'f> {
index 41edc26e803d3118dc1b0d005cf2dc08e691f641..e01e34a0e5afd2802603e4d1d42f46ed8bc1322f 100644 (file)
@@ -421,19 +421,6 @@ pub fn mk_coercety(cx: &InferCtxt,
     })
 }
 
-pub fn can_mk_coercety(cx: &InferCtxt, a: ty::t, b: ty::t) -> ures {
-    debug!("can_mk_coercety({} -> {})", a.inf_str(cx), b.inf_str(cx));
-    indent(|| {
-        cx.probe(|| {
-            let trace = TypeTrace {
-                origin: Misc(codemap::DUMMY_SP),
-                values: Types(expected_found(true, a, b))
-            };
-            Coerce(cx.combine_fields(true, trace)).tys(a, b)
-        })
-    }).to_ures()
-}
-
 // See comment on the type `resolve_state` below
 pub fn resolve_type(cx: &InferCtxt,
                     a: ty::t,
@@ -631,10 +618,6 @@ pub fn next_int_var_id(&self) -> IntVid {
         result
     }
 
-    pub fn next_int_var(&self) -> ty::t {
-        ty::mk_int_var(self.tcx, self.next_int_var_id())
-    }
-
     pub fn next_float_var_id(&self) -> FloatVid {
         let mut float_var_counter = self.float_var_counter.get();
         let mut float_var_bindings = self.float_var_bindings.borrow_mut();
@@ -644,21 +627,10 @@ pub fn next_float_var_id(&self) -> FloatVid {
         result
     }
 
-    pub fn next_float_var(&self) -> ty::t {
-        ty::mk_float_var(self.tcx, self.next_float_var_id())
-    }
-
     pub fn next_region_var(&self, origin: RegionVariableOrigin) -> ty::Region {
         ty::ReInfer(ty::ReVar(self.region_vars.new_region_var(origin)))
     }
 
-    pub fn next_region_vars(&self,
-                            origin: RegionVariableOrigin,
-                            count: uint)
-                            -> Vec<ty::Region> {
-        Vec::from_fn(count, |_| self.next_region_var(origin))
-    }
-
     pub fn region_vars_for_defs(&self,
                                 span: Span,
                                 defs: &[ty::RegionParameterDef])
index 4bc0e765af50120012be35850368e3d8c1619613..5348a623d86cc3d82f8d154eba4a19a670b69c6e 100644 (file)
@@ -52,7 +52,7 @@
 use middle::ty;
 use middle::ty_fold;
 use middle::typeck::infer::{Bounds, cyclic_ty, fixup_err, fres, InferCtxt};
-use middle::typeck::infer::{region_var_bound_by_region_var, unresolved_ty};
+use middle::typeck::infer::unresolved_ty;
 use middle::typeck::infer::to_str::InferStr;
 use middle::typeck::infer::unify::{Root, UnifyInferCtxtMethods};
 use util::common::{indent, indenter};
 pub static resolve_rvar: uint        = 0b0000000010;
 pub static resolve_ivar: uint        = 0b0000000100;
 pub static resolve_fvar: uint        = 0b0000001000;
-pub static resolve_fnvar: uint       = 0b0000010000;
-pub static resolve_all: uint         = 0b0000011111;
+pub static resolve_all: uint         = 0b0000001111;
 pub static force_tvar: uint          = 0b0000100000;
 pub static force_rvar: uint          = 0b0001000000;
 pub static force_ivar: uint          = 0b0010000000;
 pub static force_fvar: uint          = 0b0100000000;
-pub static force_fnvar: uint         = 0b1000000000;
-pub static force_all: uint           = 0b1111100000;
+pub static force_all: uint           = 0b0111100000;
 
 pub static not_regions: uint         = !(force_rvar | resolve_rvar);
 
@@ -204,15 +202,6 @@ pub fn resolve_region_var(&mut self, rid: RegionVid) -> ty::Region {
         self.infcx.region_vars.resolve_var(rid)
     }
 
-    pub fn assert_not_rvar(&mut self, rid: RegionVid, r: ty::Region) {
-        match r {
-          ty::ReInfer(ty::ReVar(rid2)) => {
-            self.err = Some(region_var_bound_by_region_var(rid, rid2));
-          }
-          _ => { }
-        }
-    }
-
     pub fn resolve_ty_var(&mut self, vid: TyVid) -> ty::t {
         if self.v_seen.contains(&vid) {
             self.err = Some(cyclic_ty(vid));
index efb556ecea6984e59eb2753c6247c2a53ea6f64b..fb82bf9968afc1b80ceb4cfa4178c905003bb134 100644 (file)
@@ -264,15 +264,6 @@ pub fn write_substs_to_tcx(tcx: &ty::ctxt,
         tcx.node_type_substs.borrow_mut().insert(node_id, substs);
     }
 }
-pub fn write_tpt_to_tcx(tcx: &ty::ctxt,
-                        node_id: ast::NodeId,
-                        tpt: &ty::ty_param_substs_and_ty) {
-    write_ty_to_tcx(tcx, node_id, tpt.ty);
-    if !tpt.substs.tps.is_empty() {
-        write_substs_to_tcx(tcx, node_id, tpt.substs.tps.clone());
-    }
-}
-
 pub fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> ast::Def {
     match tcx.def_map.borrow().find(&id) {
         Some(&x) => x,
index cef047fae5df5e258eac95c49f7670485fe9f9dc..2abbd916d76276bee065f027c581ba9c8d4f88df 100644 (file)
@@ -14,7 +14,6 @@
 use std::cell::Cell;
 use syntax::ast;
 use syntax::codemap::Span;
-use syntax::owned_slice::OwnedSlice;
 
 /// Defines strategies for handling regions that are omitted.  For
 /// example, if one writes the type `&Foo`, then the lifetime of
@@ -72,10 +71,3 @@ fn anon_regions(&self,
                                                    ty::BrAnon(idx + i))))
     }
 }
-
-pub fn bound_type_regions(defs: &[ty::RegionParameterDef])
-                          -> OwnedSlice<ty::Region> {
-    assert!(defs.iter().all(|def| def.def_id.krate == ast::LOCAL_CRATE));
-    defs.iter().enumerate().map(
-        |(i, def)| ty::ReEarlyBound(def.def_id.node, i, def.name)).collect()
-}
index bdc27ceab2b2bd9543cda9c5425bdde24a8cd97e..ce8a34c4c23f5f5314c3fcb9da9314722eaadabd 100644 (file)
@@ -11,7 +11,6 @@
 #![allow(non_camel_case_types)]
 
 use syntax::ast;
-use syntax::codemap::{Span};
 use syntax::visit;
 use syntax::visit::Visitor;
 
@@ -64,12 +63,6 @@ pub fn indenter() -> _indenter {
     _indenter(())
 }
 
-pub fn field_expr(f: ast::Field) -> @ast::Expr { return f.expr; }
-
-pub fn field_exprs(fields: Vec<ast::Field> ) -> Vec<@ast::Expr> {
-    fields.move_iter().map(|f| f.expr).collect()
-}
-
 struct LoopQueryVisitor<'a> {
     p: 'a |&ast::Expr_| -> bool,
     flag: bool,
@@ -120,16 +113,3 @@ pub fn block_query(b: ast::P<ast::Block>, p: |&ast::Expr| -> bool) -> bool {
     visit::walk_block(&mut v, b, ());
     return v.flag;
 }
-
-pub fn local_rhs_span(l: &ast::Local, def: Span) -> Span {
-    match l.init {
-      Some(i) => return i.span,
-      _ => return def
-    }
-}
-
-pub fn pluralize(n: uint, s: ~str) -> ~str {
-    if n == 1 { s }
-    else { format!("{}s", s) }
-}
-
index 9b76d50a66479f9b2f628588f5b4ff7d710c4ed1..0f7de94a92d8c0a1746ac2d027108dc8a4700516 100644 (file)
@@ -58,14 +58,6 @@ pub fn note_and_explain_region(cx: &ctxt,
     }
 }
 
-/// Returns a string like "the block at 27:31" that attempts to explain a
-/// lifetime in a way it might plausibly be understood.
-pub fn explain_region(cx: &ctxt, region: ty::Region) -> ~str {
-  let (res, _) = explain_region_and_span(cx, region);
-  return res;
-}
-
-
 pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
                             -> (~str, Option<Span>) {
     return match region {
@@ -165,42 +157,6 @@ pub fn bound_region_to_str(cx: &ctxt,
     }
 }
 
-pub fn ReScope_id_to_str(cx: &ctxt, node_id: ast::NodeId) -> ~str {
-    match cx.map.find(node_id) {
-      Some(ast_map::NodeBlock(ref blk)) => {
-        format!("<block at {}>",
-             cx.sess.codemap().span_to_str(blk.span))
-      }
-      Some(ast_map::NodeExpr(expr)) => {
-        match expr.node {
-          ast::ExprCall(..) => {
-            format!("<call at {}>",
-                 cx.sess.codemap().span_to_str(expr.span))
-          }
-          ast::ExprMatch(..) => {
-            format!("<match at {}>",
-                 cx.sess.codemap().span_to_str(expr.span))
-          }
-          ast::ExprAssignOp(..) |
-          ast::ExprUnary(..) |
-          ast::ExprBinary(..) |
-          ast::ExprIndex(..) => {
-            format!("<method at {}>",
-                 cx.sess.codemap().span_to_str(expr.span))
-          }
-          _ => {
-            format!("<expression at {}>",
-                 cx.sess.codemap().span_to_str(expr.span))
-          }
-        }
-      }
-      None => {
-        format!("<unknown-{}>", node_id)
-      }
-      _ => cx.sess.bug(format!("ReScope refers to {}", cx.map.node_to_str(node_id)))
-    }
-}
-
 // In general, if you are giving a region error message,
 // you should use `explain_region()` or, better yet,
 // `note_and_explain_region()`
@@ -280,10 +236,6 @@ pub fn vec_map_to_str<T>(ts: &[T], f: |t: &T| -> ~str) -> ~str {
     format!("[{}]", tstrs.connect(", "))
 }
 
-pub fn tys_to_str(cx: &ctxt, ts: &[t]) -> ~str {
-    vec_map_to_str(ts, |t| ty_to_str(cx, *t))
-}
-
 pub fn fn_sig_to_str(cx: &ctxt, typ: &ty::FnSig) -> ~str {
     format!("fn{}{} -> {}",
             typ.binder_id,