diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs index 83a17bd3231a2..c722beb43ae95 100644 --- a/src/librustc/back/abi.rs +++ b/src/librustc/back/abi.rs @@ -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 vec_elt_elems: uint = 2u; pub static slice_elt_base: uint = 0u; pub static slice_elt_len: uint = 1u; - -pub static abi_version: uint = 1u; diff --git a/src/librustc/back/archive.rs b/src/librustc/back/archive.rs index d6173176c160b..6de7bb59b6180 100644 --- a/src/librustc/back/archive.rs +++ b/src/librustc/back/archive.rs @@ -87,29 +87,6 @@ impl<'a> Archive<'a> { Archive { sess: sess, dst: dst } } - /// Read a file in the archive - pub fn read(&self, file: &str) -> Vec { - // 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 = - 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<()> { diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index f198a41af6557..e9292f54a4b26 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -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 { diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index d9e1b779e9651..a733d2672e820 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -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 { diff --git a/src/librustc/metadata/common.rs b/src/librustc/metadata/common.rs index 09d3b36321fa9..264829b18a309 100644 --- a/src/librustc/metadata/common.rs +++ b/src/librustc/metadata/common.rs @@ -73,8 +73,6 @@ pub static tag_crate_dep: uint = 0x19; 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; @@ -94,10 +92,8 @@ pub static tag_path_len: uint = 0x25; 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 @@ pub static tag_mod_impl_trait: uint = 0x2b; */ 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 static tag_lang_items_item_id: uint = 0x4a; 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; diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index d840ca329387d..4300c2eedbf6d 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -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 { - 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)> { diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 62fcc4c617e61..e3a3239bdb5b8 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -23,7 +23,6 @@ use std::rc::Rc; 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 @@ impl CStore { 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); diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 94941913a8b88..dc8acf63719d8 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -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 { let mut ids: Vec = 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, cdata: Cmd, id: ast::NodeId, - name: ast::Ident) -> Option { - 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, 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 { - return get_attributes(reader::Doc(data)); + get_attributes(reader::Doc(data)) } #[deriving(Clone)] diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 468eac4d2694c..b83f42da0a056 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -84,12 +84,6 @@ impl<'a> FileSearch<'a> { 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()); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 383739a1b0320..e6f6a87be4fdc 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -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 diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b8b05128e4c2c..6f4f2f6345eb4 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -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 for RestrictionSet { @@ -862,17 +859,6 @@ impl<'a> BorrowckCtxt<'a> { 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 { diff --git a/src/librustc/middle/cfg/mod.rs b/src/librustc/middle/cfg/mod.rs index 9c2dcd74351e3..97ea996bb7e45 100644 --- a/src/librustc/middle/cfg/mod.rs +++ b/src/librustc/middle/cfg/mod.rs @@ -15,6 +15,8 @@ Uses `Graph` as the underlying representation. */ +#![allow(dead_code)] // still a WIP, #6298 + use middle::graph; use middle::ty; use middle::typeck; diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 7fadfff21d119..bd45956fbb2ac 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -521,11 +521,3 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> Option { pub fn compare_lit_exprs(tcx: &ty::ctxt, a: &Expr, b: &Expr) -> Option { 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 { - compare_lit_exprs(tcx, a, b).map(|val| val == 0) -} - -pub fn lit_eq(a: &Lit, b: &Lit) -> Option { - compare_const_vals(&lit_to_const(a), &lit_to_const(b)).map(|val| val == 0) -} diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 2adc3e82576f2..92d359887b98f 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -246,31 +246,6 @@ impl<'a, O:DataFlowOperator> DataFlowContext<'a, O> { 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`. diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index d8851fa46f8ba..d6adb19419b51 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -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() -} diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index fd27cabaf7fba..e4603b7eae260 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -34,6 +34,8 @@ be indexed by the direction (see the type `Direction`). */ +#![allow(dead_code)] // still WIP + use std::uint; pub struct Graph { diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index fd53c2e544d2c..a667e81f349fe 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -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 { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 86db6b6a46373..7fca0e56aa21f 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -96,6 +96,7 @@ impl LanguageItems { } $( + #[allow(dead_code)] pub fn $method(&self) -> Option { *self.items.get($variant as uint) } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 3604499add693..e376e66ca6f90 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -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 @@ impl MemCategorizationContext { } } - /// 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(&mut self, node: &N, base_cmt: cmt, @@ -1114,13 +1100,6 @@ impl MemCategorizationContext { 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 @@ impl MemCategorizationContext { } } } - - 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 { - // 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 { diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index e9d01b9048f91..2d50d2e0f772b 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -86,12 +86,6 @@ pub fn pat_bindings(dm: resolve::DefMap, }); } -pub fn pat_binding_ids(dm: resolve::DefMap, pat: &Pat) -> Vec { - 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 { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 247209539127c..ad940113a86c4 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -149,6 +149,7 @@ impl RegionMaps { 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 @@ impl RegionMaps { 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`. diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index c727744b4c765..b42721b754b54 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -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 - } -} diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 8ac7bd1b66b68..133634a9e791c 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -77,13 +77,11 @@ use std::cell::{Cell, RefCell}; 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 @@ pub fn compare_scalar_values<'a>( 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 @@ pub fn declare_intrinsics(ccx: &mut CrateContext) { } } -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> { diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index c7c0d51b3abd8..f40a9ede8622e 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -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}; diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index 2703ddddc8b7f..07017de2bc2bc 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -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}; diff --git a/src/librustc/middle/trans/cabi.rs b/src/librustc/middle/trans/cabi.rs index 9ce277a7de904..2c9be587eaa9e 100644 --- a/src/librustc/middle/trans/cabi.rs +++ b/src/librustc/middle/trans/cabi.rs @@ -79,10 +79,6 @@ impl ArgType { } } - pub fn is_direct(&self) -> bool { - return self.kind == Direct; - } - pub fn is_indirect(&self) -> bool { return self.kind == Indirect; } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index dae48512ac2a7..dae4b2b471b30 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -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, diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index dce4750969d19..4833a23342385 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -24,7 +24,6 @@ use middle::trans::datum; 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 @@ impl<'a> Block<'a> { 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::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); diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index a7fed4fa60d3f..f98a77eed65a0 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -20,7 +20,6 @@ use middle::resolve; 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 util::nodemap::{NodeMap, NodeSet, DefIdMap}; 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>, pub tydescs: RefCell>, - // 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, - // 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>>, - // 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>, - // 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, - // Cache instances of monomorphized functions + /// Cache instances of monomorphized functions pub monomorphized: RefCell>, pub monomorphizing: RefCell>, - // Cache generated vtables + /// Cache generated vtables pub vtables: RefCell>, - // Cache of constant strings, + /// Cache of constant strings, pub const_cstr_cache: RefCell>, - // 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>, - // Cache of emitted const values + /// Cache of emitted const values pub const_values: RefCell>, - // Cache of external const values + /// Cache of external const values pub extern_const_values: RefCell>, pub impl_method_cache: RefCell>, - // Cache of closure wrappers for bare fn's. + /// Cache of closure wrappers for bare fn's. pub closure_bare_wrapper_cache: RefCell>, pub lltypes: RefCell>, @@ -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, } @@ -232,36 +230,6 @@ impl CrateContext { 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 = - 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() } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 9f48e4714d60d..500a36c5dee60 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -24,12 +24,10 @@ use middle::trans::expr; 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 @@ impl Datum { } } - 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 { /*! * Asserts that this datum *is* an lvalue and returns it. @@ -632,6 +623,7 @@ impl Datum { 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 @@ impl Datum { 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 @@ impl<'a, K:KindOps> DatumBlock<'a, K> { } 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 @@ impl<'a> DatumBlock<'a, Expr> { 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)) diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 3d4a33c217d81..a206d42e58999 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -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, diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 01e52fda4cb34..7ad9010829c7f 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -46,10 +46,6 @@ impl<'a> Reflector<'a> { 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) } diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 4aac50c5355af..d8154c6b1f5b5 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -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>, diff --git a/src/librustc/middle/trans/type_.rs b/src/librustc/middle/trans/type_.rs index ca01c0532fc39..55ffa951cf2d7 100644 --- a/src/librustc/middle/trans/type_.rs +++ b/src/librustc/middle/trans/type_.rs @@ -20,7 +20,6 @@ use syntax::abi::{X86, X86_64, Arm, Mips}; use std::c_str::ToCStr; use std::cast; -use std::slice; use std::libc::{c_uint}; @@ -135,10 +134,6 @@ impl 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 @@ impl 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 @@ impl 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 diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 176ed409dd49f..f9296926c748a 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -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, 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 @@ def_type_content_sets!( ) 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 @@ impl 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 @@ impl fmt::Show for TypeContents { } } -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 { - 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 { } } -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 { - sig.inputs.iter().map(|a| *a).collect::>().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> { 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 { - 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 { 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 { 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 { } } -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 { fields.iter().map(|field| { match field.node.kind { @@ -4368,13 +4191,6 @@ pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool { return tbl[tycat(cx, ty) as uint ][opcat(op) as uint]; } -pub fn ty_params_to_tys(tcx: &ctxt, generics: &ast::Generics) -> Vec { - 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 { tcx.lang_items.require(TyDescStructLangItem).map(|tydesc_lang_item| { tcx.intrinsic_defs.borrow().find_copy(&tydesc_lang_item) @@ -5050,12 +4853,4 @@ impl BorrowKind { UniqueImmBorrow => "uniquely immutable", } } - - pub fn to_short_str(&self) -> &'static str { - match *self { - MutBorrow => "mut", - ImmBorrow => "imm", - UniqueImmBorrow => "own", - } - } } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 4cf3cc51cc1b6..5752a92835883 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -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 @@ impl<'a> FnCtxt<'a> { } } - 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 @@ impl<'a> FnCtxt<'a> { } } - 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 @@ impl<'a> FnCtxt<'a> { } } - 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) { diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index af84e915f7040..4a03e32dee824 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -373,28 +373,6 @@ pub fn eq_regions(this: &C, a: ty::Region, b: ty::Region) }) } -pub fn eq_opt_regions( - this: &C, - a: Option, - b: Option) -> cres> { - - 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(this: &C, a: &ty::FnSig, b: &ty::FnSig) -> cres { fn argvecs(this: &C, a_args: &[ty::t], b_args: &[ty::t]) -> cres > { diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index e63ad7322b9ae..bde750eb6f0de 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -31,10 +31,6 @@ pub struct Lub<'f>(CombineFields<'f>); // least-upper-bound: common supertype 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 { Ok(b) } - pub fn ty_bot(&self, b: ty::t) -> cres { - self.bot_ty(b) // commutative - } } impl<'f> Combine for Lub<'f> { diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 41edc26e803d3..e01e34a0e5afd 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -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 @@ impl<'a> InferCtxt<'a> { 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 @@ impl<'a> InferCtxt<'a> { 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 { - Vec::from_fn(count, |_| self.next_region_var(origin)) - } - pub fn region_vars_for_defs(&self, span: Span, defs: &[ty::RegionParameterDef]) diff --git a/src/librustc/middle/typeck/infer/resolve.rs b/src/librustc/middle/typeck/infer/resolve.rs index 4bc0e765af501..5348a623d86cc 100644 --- a/src/librustc/middle/typeck/infer/resolve.rs +++ b/src/librustc/middle/typeck/infer/resolve.rs @@ -52,7 +52,7 @@ use middle::ty::{type_is_bot, IntType, UintType}; 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}; @@ -64,14 +64,12 @@ pub static resolve_nested_tvar: uint = 0b0000000001; 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 @@ impl<'a> ResolveState<'a> { 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)); diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index efb556ecea698..fb82bf9968afc 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -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, diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index cef047fae5df5..2abbd916d7627 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -14,7 +14,6 @@ use middle::ty; 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 @@ impl RegionScope for BindingRscope { ty::BrAnon(idx + i)))) } } - -pub fn bound_type_regions(defs: &[ty::RegionParameterDef]) - -> OwnedSlice { - 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() -} diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index bdc27ceab2b2b..ce8a34c4c23f5 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -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 ) -> 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, 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) } -} - diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 9b76d50a66479..0f7de94a92d8c 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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) { 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!("", - cx.sess.codemap().span_to_str(blk.span)) - } - Some(ast_map::NodeExpr(expr)) => { - match expr.node { - ast::ExprCall(..) => { - format!("", - cx.sess.codemap().span_to_str(expr.span)) - } - ast::ExprMatch(..) => { - format!("", - cx.sess.codemap().span_to_str(expr.span)) - } - ast::ExprAssignOp(..) | - ast::ExprUnary(..) | - ast::ExprBinary(..) | - ast::ExprIndex(..) => { - format!("", - cx.sess.codemap().span_to_str(expr.span)) - } - _ => { - format!("", - cx.sess.codemap().span_to_str(expr.span)) - } - } - } - None => { - format!("", 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(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,