Skip to content

Commit 08e2cf8

Browse files
committed
auto merge of #5676 : nikomatsakis/rust/issue-4183-trait_ref, r=nikomatsakis
These are a number of incremental steps towards #4183 and #4646.
2 parents babe506 + 13801f6 commit 08e2cf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1895
-1422
lines changed

src/libcore/libc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ pub mod funcs {
13941394
use libc::types::common::posix88::{DIR, dirent_t};
13951395
use libc::types::os::arch::c95::{c_char, c_int, c_long};
13961396

1397-
// NOTE: On OS X opendir and readdir have two versions,
1397+
// NB: On OS X opendir and readdir have two versions,
13981398
// one for 32-bit kernelspace and one for 64.
13991399
// We should be linking to the 64-bit ones, called
14001400
// opendir$INODE64, etc. but for some reason rustc

src/libcore/option.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ use ops::Add;
4646
use kinds::Copy;
4747
use util;
4848
use num::Zero;
49-
use iter::{BaseIter, MutableIter};
49+
use iter::{BaseIter, MutableIter, ExtendedIter};
50+
use iter;
5051

5152
#[cfg(test)] use ptr;
5253
#[cfg(test)] use str;
@@ -118,6 +119,31 @@ impl<T> MutableIter<T> for Option<T> {
118119
}
119120
}
120121

122+
impl<A> ExtendedIter<A> for Option<A> {
123+
pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) {
124+
iter::eachi(self, blk)
125+
}
126+
pub fn all(&self, blk: &fn(&A) -> bool) -> bool {
127+
iter::all(self, blk)
128+
}
129+
pub fn any(&self, blk: &fn(&A) -> bool) -> bool {
130+
iter::any(self, blk)
131+
}
132+
pub fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B {
133+
iter::foldl(self, b0, blk)
134+
}
135+
pub fn position(&self, f: &fn(&A) -> bool) -> Option<uint> {
136+
iter::position(self, f)
137+
}
138+
fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
139+
iter::map_to_vec(self, op)
140+
}
141+
fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB)
142+
-> ~[B] {
143+
iter::flat_map_to_vec(self, op)
144+
}
145+
}
146+
121147
pub impl<T> Option<T> {
122148
/// Returns true if the option equals `none`
123149
fn is_none(&const self) -> bool {

src/libcore/reflect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
443443
}
444444

445445
fn visit_trait(&self) -> bool {
446-
self.align_to::<TyVisitor>();
446+
self.align_to::<@TyVisitor>();
447447
if ! self.inner.visit_trait() { return false; }
448-
self.bump_past::<TyVisitor>();
448+
self.bump_past::<@TyVisitor>();
449449
true
450450
}
451451

src/libcore/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> @Program {
298298
@ProgRes(repr) as @Program
299299
}
300300

301-
fn read_all(rd: io::Reader) -> ~str {
301+
fn read_all(rd: @io::Reader) -> ~str {
302302
let buf = io::with_bytes_writer(|wr| {
303303
let mut bytes = [0, ..4096];
304304
while !rd.eof() {

src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ pub fn compile_rest(sess: Session, cfg: ast::crate_cfg,
308308

309309
};
310310

311-
// NOTE: Android hack
311+
// NB: Android hack
312312
if sess.targ_cfg.arch == abi::Arm &&
313313
(sess.opts.output_type == link::output_type_object ||
314314
sess.opts.output_type == link::output_type_exe) {

src/librustc/metadata/common.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ pub static tag_crate_dep_vers: uint = 0x2cu;
7474
pub static tag_mod_impl: uint = 0x30u;
7575

7676
pub static tag_item_trait_method: uint = 0x31u;
77-
pub static tag_impl_trait: uint = 0x32u;
77+
78+
pub static tag_item_trait_ref: uint = 0x32u;
79+
pub static tag_item_super_trait_ref: uint = 0x33u;
7880

7981
// discriminator value for variants
8082
pub static tag_disr_val: uint = 0x34u;
@@ -102,6 +104,7 @@ pub static tag_item_dtor: uint = 0x49u;
102104
pub static tag_item_trait_method_self_ty: uint = 0x4b;
103105
pub static tag_item_trait_method_self_ty_region: uint = 0x4c;
104106

107+
105108
// Reexports are found within module tags. Each reexport contains def_ids
106109
// and names.
107110
pub static tag_items_data_item_reexport: uint = 0x4d;
@@ -159,6 +162,10 @@ pub static tag_items_data_item_visibility: uint = 0x78;
159162
pub static tag_link_args: uint = 0x79;
160163
pub static tag_link_args_arg: uint = 0x7a;
161164

165+
pub static tag_item_method_tps: uint = 0x7b;
166+
pub static tag_item_method_fty: uint = 0x7c;
167+
pub static tag_item_method_transformed_self_ty: uint = 0x7d;
168+
162169
pub struct LinkMeta {
163170
name: @str,
164171
vers: @str,

src/librustc/metadata/csearch.rs

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,24 @@ pub fn get_impls_for_mod(cstore: @mut cstore::CStore, def: ast::def_id,
111111
}
112112
}
113113

114-
pub fn get_trait_methods(tcx: ty::ctxt,
115-
def: ast::def_id)
116-
-> @~[ty::method] {
117-
let cstore = tcx.cstore;
114+
pub fn get_method(tcx: ty::ctxt,
115+
def: ast::def_id) -> ty::method
116+
{
117+
let cdata = cstore::get_crate_data(tcx.cstore, def.crate);
118+
decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx)
119+
}
120+
121+
pub fn get_method_name_and_self_ty(cstore: @mut cstore::CStore,
122+
def: ast::def_id) -> (ast::ident, ast::self_ty_)
123+
{
124+
let cdata = cstore::get_crate_data(cstore, def.crate);
125+
decoder::get_method_name_and_self_ty(cstore.intr, cdata, def.node)
126+
}
127+
128+
pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore,
129+
def: ast::def_id) -> ~[ast::def_id] {
118130
let cdata = cstore::get_crate_data(cstore, def.crate);
119-
decoder::get_trait_methods(cstore.intr, cdata, def.node, tcx)
131+
decoder::get_trait_method_def_ids(cdata, def.node)
120132
}
121133

122134
pub fn get_provided_trait_methods(tcx: ty::ctxt,
@@ -127,19 +139,12 @@ pub fn get_provided_trait_methods(tcx: ty::ctxt,
127139
decoder::get_provided_trait_methods(cstore.intr, cdata, def.node, tcx)
128140
}
129141

130-
pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::t] {
142+
pub fn get_supertraits(tcx: ty::ctxt, def: ast::def_id) -> ~[@ty::TraitRef] {
131143
let cstore = tcx.cstore;
132144
let cdata = cstore::get_crate_data(cstore, def.crate);
133145
decoder::get_supertraits(cdata, def.node, tcx)
134146
}
135147

136-
pub fn get_method_names_if_trait(cstore: @mut cstore::CStore,
137-
def: ast::def_id)
138-
-> Option<~[(ast::ident, ast::self_ty_)]> {
139-
let cdata = cstore::get_crate_data(cstore, def.crate);
140-
return decoder::get_method_names_if_trait(cstore.intr, cdata, def.node);
141-
}
142-
143148
pub fn get_type_name_if_impl(cstore: @mut cstore::CStore, def: ast::def_id)
144149
-> Option<ast::ident> {
145150
let cdata = cstore::get_crate_data(cstore, def.crate);
@@ -175,6 +180,12 @@ pub fn get_type(tcx: ty::ctxt,
175180
decoder::get_type(cdata, def.node, tcx)
176181
}
177182

183+
pub fn get_trait_def(tcx: ty::ctxt, def: ast::def_id) -> ty::TraitDef {
184+
let cstore = tcx.cstore;
185+
let cdata = cstore::get_crate_data(cstore, def.crate);
186+
decoder::get_trait_def(cdata, def.node, tcx)
187+
}
188+
178189
pub fn get_region_param(cstore: @mut metadata::cstore::CStore,
179190
def: ast::def_id) -> Option<ty::region_variance> {
180191
let cdata = cstore::get_crate_data(cstore, def.crate);
@@ -199,16 +210,17 @@ pub fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id,
199210
debug!("got field data %?", the_field);
200211
let ty = decoder::item_type(def, the_field, tcx, cdata);
201212
ty::ty_param_bounds_and_ty {
202-
bounds: @~[],
203-
region_param: None,
213+
generics: ty::Generics {bounds: @~[],
214+
region_param: None},
204215
ty: ty
205216
}
206217
}
207218

208219
// Given a def_id for an impl or class, return the traits it implements,
209220
// or the empty vector if it's not for an impl or for a class that implements
210221
// traits
211-
pub fn get_impl_traits(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::t] {
222+
pub fn get_impl_traits(tcx: ty::ctxt,
223+
def: ast::def_id) -> ~[@ty::TraitRef] {
212224
let cstore = tcx.cstore;
213225
let cdata = cstore::get_crate_data(cstore, def.crate);
214226
decoder::get_impl_traits(cdata, def.node, tcx)

0 commit comments

Comments
 (0)