Skip to content

Commit fd30141

Browse files
committed
---
yaml --- r: 50171 b: refs/heads/auto c: 441313f h: refs/heads/master i: 50169: 4d56a3b 50167: 2b76acb v: v3
1 parent 4838101 commit fd30141

File tree

8 files changed

+438
-115
lines changed

8 files changed

+438
-115
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: a919e5ede5465cfab27cdc7cae59f2c015735753
17+
refs/heads/auto: 441313fc0ca635be18d1175e7dc265ab9ffa9d7d
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167

branches/auto/src/librustc/metadata/cstore.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,28 +141,24 @@ pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore,
141141
extern_mod_crate_map.find(&emod_id)
142142
}
143143

144-
// returns hashes of crates directly used by this crate. Hashes are sorted by
145-
// (crate name, crate version, crate hash) in lexicographic order (not semver)
144+
// returns hashes of crates directly used by this crate. Hashes are
145+
// sorted by crate name.
146146
pub fn get_dep_hashes(cstore: @mut CStore) -> ~[~str] {
147-
struct crate_hash { name: @~str, vers: @~str, hash: @~str }
147+
struct crate_hash { name: @~str, hash: @~str }
148148
let mut result = ~[];
149149

150150
let extern_mod_crate_map = cstore.extern_mod_crate_map;
151151
for extern_mod_crate_map.each_value |&cnum| {
152152
let cdata = cstore::get_crate_data(cstore, cnum);
153153
let hash = decoder::get_crate_hash(cdata.data);
154-
let vers = decoder::get_crate_vers(cdata.data);
155-
debug!("Add hash[%s]: %s %s", *cdata.name, *vers, *hash);
154+
debug!("Add hash[%s]: %s", *cdata.name, *hash);
156155
result.push(crate_hash {
157156
name: cdata.name,
158-
vers: vers,
159157
hash: hash
160158
});
161159
}
162160

163-
let sorted = do std::sort::merge_sort(result) |a, b| {
164-
(a.name, a.vers, a.hash) <= (b.name, b.vers, b.hash)
165-
};
161+
let sorted = std::sort::merge_sort(result, |a, b| a.name <= b.name);
166162

167163
debug!("sorted:");
168164
for sorted.each |x| {

branches/auto/src/librustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4741,8 +4741,8 @@ pub impl Resolver {
47414741
let mut j = this.value_ribs.len();
47424742
while j != 0 {
47434743
j -= 1;
4744-
for this.value_ribs[j].bindings.each_key |&k| {
4745-
vec::push(&mut maybes, copy *this.session.str_of(k));
4744+
for this.value_ribs[j].bindings.each_entry |e| {
4745+
vec::push(&mut maybes, copy *this.session.str_of(e.key));
47464746
vec::push(&mut values, uint::max_value);
47474747
}
47484748
}

branches/auto/src/librustc/middle/trans/tvec.rs

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use middle::ty;
2727
use util::common::indenter;
2828
use util::ppaux::ty_to_str;
2929

30+
use core::option::None;
3031
use core::uint;
3132
use core::vec;
3233
use syntax::ast;
@@ -413,30 +414,54 @@ pub fn write_content(bcx: block,
413414
return bcx;
414415
}
415416

416-
let tmpdatum = unpack_datum!(bcx, {
417+
let elem = unpack_datum!(bcx, {
417418
expr::trans_to_datum(bcx, element)
418419
});
419420

420-
let mut temp_cleanups = ~[];
421+
let next_bcx = sub_block(bcx, ~"expr_repeat: while next");
422+
let loop_bcx = loop_scope_block(bcx, next_bcx, None, ~"expr_repeat", None);
423+
let cond_bcx = scope_block(loop_bcx, None, ~"expr_repeat: loop cond");
424+
let set_bcx = scope_block(loop_bcx, None, ~"expr_repeat: body: set");
425+
let inc_bcx = scope_block(loop_bcx, None, ~"expr_repeat: body: inc");
426+
Br(bcx, loop_bcx.llbb);
421427

422-
for uint::range(0, count) |i| {
423-
let lleltptr = GEPi(bcx, lldest, [i]);
424-
if i < count - 1 {
425-
// Copy all but the last one in.
426-
bcx = tmpdatum.copy_to(bcx, INIT, lleltptr);
427-
} else {
428-
// Move the last one in.
429-
bcx = tmpdatum.move_to(bcx, INIT, lleltptr);
430-
}
431-
add_clean_temp_mem(bcx, lleltptr, vt.unit_ty);
432-
temp_cleanups.push(lleltptr);
428+
let loop_counter = {
429+
// i = 0
430+
let i = alloca(loop_bcx, T_i64());
431+
Store(loop_bcx, C_i64(0), i);
432+
433+
Br(loop_bcx, cond_bcx.llbb);
434+
i
435+
};
436+
437+
{ // i < count
438+
let lhs = Load(cond_bcx, loop_counter);
439+
let rhs = C_integral(T_i64(), count as u64, lib::llvm::False);
440+
let cmp_lr = ICmp(cond_bcx, lib::llvm::IntULT, lhs, rhs);
441+
let zext = ZExt(cond_bcx, cmp_lr, T_i8());
442+
let cond_val = ICmp(cond_bcx, lib::llvm::IntNE, zext, C_u8(0));
443+
444+
CondBr(cond_bcx, cond_val, set_bcx.llbb, next_bcx.llbb);
433445
}
434446

435-
for vec::each(temp_cleanups) |cleanup| {
436-
revoke_clean(bcx, *cleanup);
447+
{ // v[i] = elem
448+
let i = Load(set_bcx, loop_counter);
449+
let lleltptr = InBoundsGEP(set_bcx, lldest, [i]);
450+
let set_bcx = elem.copy_to(set_bcx, INIT, lleltptr);
451+
452+
Br(set_bcx, inc_bcx.llbb);
437453
}
438454

439-
return bcx;
455+
{ // i += 1
456+
let i = Load(inc_bcx, loop_counter);
457+
let plusone = Add(inc_bcx, i, C_i64(1));
458+
Store(inc_bcx, plusone, loop_counter);
459+
460+
Br(inc_bcx, cond_bcx.llbb);
461+
}
462+
463+
return next_bcx;
464+
440465
}
441466
}
442467
}

branches/auto/src/librustc/middle/typeck/coherence.rs

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,32 @@ pub fn get_base_type(inference_context: @mut InferCtxt,
104104
}
105105
}
106106

107+
pub fn type_is_defined_in_local_crate(original_type: t) -> bool {
108+
/*!
109+
*
110+
* For coherence, when we have `impl Trait for Type`, we need to
111+
* guarantee that `Type` is "local" to the
112+
* crate. For our purposes, this means that it must contain
113+
* some nominal type defined in this crate.
114+
*/
115+
116+
let mut found_nominal = false;
117+
do ty::walk_ty(original_type) |t| {
118+
match get(t).sty {
119+
ty_enum(def_id, _) |
120+
ty_trait(def_id, _, _) |
121+
ty_struct(def_id, _) => {
122+
if def_id.crate == ast::local_crate {
123+
found_nominal = true;
124+
}
125+
}
126+
127+
_ => { }
128+
}
129+
}
130+
return found_nominal;
131+
}
132+
107133
// Returns the def ID of the base type, if there is one.
108134
pub fn get_base_type_def_id(inference_context: @mut InferCtxt,
109135
span: span,
@@ -161,8 +187,7 @@ pub fn CoherenceChecker(crate_context: @mut CrateCtxt) -> CoherenceChecker {
161187
crate_context: crate_context,
162188
inference_context: new_infer_ctxt(crate_context.tcx),
163189
164-
base_type_def_ids: HashMap(),
165-
privileged_implementations: HashMap()
190+
base_type_def_ids: HashMap()
166191
}
167192
}
168193
@@ -174,11 +199,6 @@ pub struct CoherenceChecker {
174199
// definition ID.
175200
176201
base_type_def_ids: HashMap<def_id,def_id>,
177-
178-
// A set of implementations in privileged scopes; i.e. those
179-
// implementations that are defined in the same scope as their base types.
180-
181-
privileged_implementations: HashMap<node_id,()>,
182202
}
183203
184204
pub impl CoherenceChecker {
@@ -615,27 +635,11 @@ pub impl CoherenceChecker {
615635
visit_mod(module_, item.span, item.id, (), visitor);
616636
}
617637
item_impl(_, opt_trait, _, _) => {
618-
let mut ok = false;
619-
match self.base_type_def_ids.find(
620-
&local_def(item.id)) {
621-
622-
None => {
623-
// Nothing to do.
624-
}
625-
Some(base_type_def_id) => {
626-
// Check to see whether the implementation is
627-
// in the same crate as its base type.
628-
629-
if base_type_def_id.crate == local_crate {
630-
// Record that this implementation is OK.
631-
self.privileged_implementations.insert
632-
(item.id, ());
633-
ok = true;
634-
}
635-
}
636-
}
637-
638-
if !ok {
638+
// `for_ty` is `Type` in `impl Trait for Type`
639+
let for_ty =
640+
ty::node_id_to_type(self.crate_context.tcx,
641+
item.id);
642+
if !type_is_defined_in_local_crate(for_ty) {
639643
// This implementation is not in scope of its base
640644
// type. This still might be OK if the trait is
641645
// defined in the same crate.
@@ -655,25 +659,24 @@ pub impl CoherenceChecker {
655659
implement a trait or \
656660
new type instead");
657661
}
658-
_ => ()
659-
}
660662

661-
for opt_trait.each |trait_ref| {
662-
// This is OK if and only if the trait was
663-
// defined in this crate.
664-
665-
let trait_def_id =
666-
self.trait_ref_to_trait_def_id(
667-
*trait_ref);
668-
669-
if trait_def_id.crate != local_crate {
670-
let session = self.crate_context.tcx.sess;
671-
session.span_err(item.span,
672-
~"cannot provide an \
673-
extension \
674-
implementation for a \
675-
trait not defined in \
676-
this crate");
663+
Some(trait_ref) => {
664+
// This is OK if and only if the trait was
665+
// defined in this crate.
666+
667+
let trait_def_id =
668+
self.trait_ref_to_trait_def_id(
669+
trait_ref);
670+
671+
if trait_def_id.crate != local_crate {
672+
let session = self.crate_context.tcx.sess;
673+
session.span_err(item.span,
674+
~"cannot provide an \
675+
extension \
676+
implementation for a \
677+
trait not defined in \
678+
this crate");
679+
}
677680
}
678681
}
679682
}

0 commit comments

Comments
 (0)