Skip to content

Commit 8ae1894

Browse files
committed
---
yaml --- r: 59022 b: refs/heads/incoming c: f547a67 h: refs/heads/master v: v3
1 parent 4282ea8 commit 8ae1894

Some content is hidden

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

47 files changed

+621
-665
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 78520867b928ba33c557617895dd197c11361cbd
9+
refs/heads/incoming: f547a671dcc64530f0cf07f39698d63174f37733
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/cast.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ pub mod rusti {
2424
}
2525

2626
/// Casts the value at `src` to U. The two types must have the same length.
27+
#[cfg(not(stage0))]
28+
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
29+
let mut dest: U = unstable::intrinsics::uninit();
30+
{
31+
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
32+
let src_ptr: *u8 = rusti::transmute(src);
33+
unstable::intrinsics::memmove64(dest_ptr,
34+
src_ptr,
35+
sys::size_of::<U>() as u64);
36+
}
37+
dest
38+
}
39+
40+
#[cfg(stage0)]
2741
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
2842
let mut dest: U = unstable::intrinsics::init();
2943
{

branches/incoming/src/libcore/core.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ they contained the following prologue:
6060
// Don't link to core. We are core.
6161
#[no_core];
6262

63-
#[warn(vecs_implicitly_copyable)];
6463
#[deny(non_camel_case_types)];
6564
#[allow(deprecated_mutable_fields)];
6665

branches/incoming/src/libcore/unstable/intrinsics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ pub extern "rust-intrinsic" {
4444

4545
pub fn init<T>() -> T;
4646

47+
#[cfg(not(stage0))]
48+
pub unsafe fn uninit<T>() -> T;
49+
4750
pub fn forget<T>(_: T) -> ();
4851

4952
pub fn needs_drop<T>() -> bool;

branches/incoming/src/libcore/vec.rs

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,29 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
584584
}
585585
586586
/// Remove the last element from a vector and return it
587+
#[cfg(not(stage0))]
588+
pub fn pop<T>(v: &mut ~[T]) -> T {
589+
let ln = v.len();
590+
if ln == 0 {
591+
fail!(~"sorry, cannot vec::pop an empty vector")
592+
}
593+
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
594+
unsafe {
595+
let mut val = intrinsics::uninit();
596+
val <-> *valptr;
597+
raw::set_len(v, ln - 1u);
598+
val
599+
}
600+
}
601+
602+
#[cfg(stage0)]
587603
pub fn pop<T>(v: &mut ~[T]) -> T {
588604
let ln = v.len();
589605
if ln == 0 {
590606
fail!(~"sorry, cannot vec::pop an empty vector")
591607
}
592608
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
593609
unsafe {
594-
// FIXME #4204: Should be uninit() - we don't need this zeroed
595610
let mut val = intrinsics::init();
596611
val <-> *valptr;
597612
raw::set_len(v, ln - 1u);
@@ -660,13 +675,30 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
660675
}
661676
662677
#[inline(always)]
678+
#[cfg(not(stage0))]
679+
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
680+
let new_len = v.len() + rhs.len();
681+
reserve(&mut *v, new_len);
682+
unsafe {
683+
do as_mut_buf(rhs) |p, len| {
684+
for uint::range(0, len) |i| {
685+
let mut x = intrinsics::uninit();
686+
x <-> *ptr::mut_offset(p, i);
687+
push(&mut *v, x);
688+
}
689+
}
690+
raw::set_len(&mut rhs, 0);
691+
}
692+
}
693+
694+
#[inline(always)]
695+
#[cfg(stage0)]
663696
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
664697
let new_len = v.len() + rhs.len();
665698
reserve(&mut *v, new_len);
666699
unsafe {
667700
do as_mut_buf(rhs) |p, len| {
668701
for uint::range(0, len) |i| {
669-
// FIXME #4204 Should be uninit() - don't need to zero
670702
let mut x = intrinsics::init();
671703
x <-> *ptr::mut_offset(p, i);
672704
push(&mut *v, x);
@@ -677,13 +709,29 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
677709
}
678710
679711
/// Shorten a vector, dropping excess elements.
712+
#[cfg(not(stage0))]
713+
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
714+
do as_mut_buf(*v) |p, oldlen| {
715+
assert!(newlen <= oldlen);
716+
unsafe {
717+
// This loop is optimized out for non-drop types.
718+
for uint::range(newlen, oldlen) |i| {
719+
let mut dropped = intrinsics::uninit();
720+
dropped <-> *ptr::mut_offset(p, i);
721+
}
722+
}
723+
}
724+
unsafe { raw::set_len(&mut *v, newlen); }
725+
}
726+
727+
/// Shorten a vector, dropping excess elements.
728+
#[cfg(stage0)]
680729
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
681730
do as_mut_buf(*v) |p, oldlen| {
682731
assert!(newlen <= oldlen);
683732
unsafe {
684733
// This loop is optimized out for non-drop types.
685734
for uint::range(newlen, oldlen) |i| {
686-
// FIXME #4204 Should be uninit() - don't need to zero
687735
let mut dropped = intrinsics::init();
688736
dropped <-> *ptr::mut_offset(p, i);
689737
}
@@ -696,6 +744,45 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
696744
* Remove consecutive repeated elements from a vector; if the vector is
697745
* sorted, this removes all duplicates.
698746
*/
747+
#[cfg(not(stage0))]
748+
pub fn dedup<T:Eq>(v: &mut ~[T]) {
749+
unsafe {
750+
if v.len() < 1 { return; }
751+
let mut last_written = 0, next_to_read = 1;
752+
do as_const_buf(*v) |p, ln| {
753+
// We have a mutable reference to v, so we can make arbitrary
754+
// changes. (cf. push and pop)
755+
let p = p as *mut T;
756+
// last_written < next_to_read <= ln
757+
while next_to_read < ln {
758+
// last_written < next_to_read < ln
759+
if *ptr::mut_offset(p, next_to_read) ==
760+
*ptr::mut_offset(p, last_written) {
761+
let mut dropped = intrinsics::uninit();
762+
dropped <-> *ptr::mut_offset(p, next_to_read);
763+
} else {
764+
last_written += 1;
765+
// last_written <= next_to_read < ln
766+
if next_to_read != last_written {
767+
*ptr::mut_offset(p, last_written) <->
768+
*ptr::mut_offset(p, next_to_read);
769+
}
770+
}
771+
// last_written <= next_to_read < ln
772+
next_to_read += 1;
773+
// last_written < next_to_read <= ln
774+
}
775+
}
776+
// last_written < next_to_read == ln
777+
raw::set_len(v, last_written + 1);
778+
}
779+
}
780+
781+
/**
782+
* Remove consecutive repeated elements from a vector; if the vector is
783+
* sorted, this removes all duplicates.
784+
*/
785+
#[cfg(stage0)]
699786
pub fn dedup<T:Eq>(v: &mut ~[T]) {
700787
unsafe {
701788
if v.len() < 1 { return; }
@@ -709,8 +796,6 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
709796
// last_written < next_to_read < ln
710797
if *ptr::mut_offset(p, next_to_read) ==
711798
*ptr::mut_offset(p, last_written) {
712-
// FIXME #4204 Should be uninit() - don't need to
713-
// zero
714799
let mut dropped = intrinsics::init();
715800
dropped <-> *ptr::mut_offset(p, next_to_read);
716801
} else {

branches/incoming/src/librustc/driver/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ pub impl Session_ {
237237
msg: &str) {
238238
let level = lint::get_lint_settings_level(
239239
self.lint_settings, lint_mode, expr_id, item_id);
240+
let msg = fmt!("%s [-W %s]", msg, lint::get_lint_name(lint_mode));
240241
self.span_lint_level(level, span, msg);
241242
}
242243
fn next_node_id(@self) -> ast::node_id {

branches/incoming/src/librustc/metadata/tydecode.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -555,34 +555,18 @@ fn parse_type_param_def(st: @mut PState, conv: conv_did) -> ty::TypeParameterDef
555555
bounds: parse_bounds(st, conv)}
556556
}
557557
558-
fn parse_bounds(st: @mut PState, conv: conv_did) -> @ty::ParamBounds {
559-
let mut param_bounds = ty::ParamBounds {
560-
builtin_bounds: ty::EmptyBuiltinBounds(),
561-
trait_bounds: ~[]
562-
};
558+
fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {
559+
let mut bounds = ~[];
563560
loop {
564-
match next(st) {
565-
'S' => {
566-
param_bounds.builtin_bounds.add(ty::BoundOwned);
567-
}
568-
'C' => {
569-
param_bounds.builtin_bounds.add(ty::BoundCopy);
570-
}
571-
'K' => {
572-
param_bounds.builtin_bounds.add(ty::BoundConst);
573-
}
574-
'O' => {
575-
param_bounds.builtin_bounds.add(ty::BoundStatic);
576-
}
577-
'I' => {
578-
param_bounds.trait_bounds.push(@parse_trait_ref(st, conv));
579-
}
580-
'.' => {
581-
return @param_bounds;
582-
}
583-
_ => {
584-
fail!(~"parse_bounds: bad bounds")
585-
}
586-
}
561+
bounds.push(match next(st) {
562+
'S' => ty::bound_owned,
563+
'C' => ty::bound_copy,
564+
'K' => ty::bound_const,
565+
'O' => ty::bound_durable,
566+
'I' => ty::bound_trait(@parse_trait_ref(st, conv)),
567+
'.' => break,
568+
_ => fail!(~"parse_bounds: bad bounds")
569+
});
587570
}
571+
@bounds
588572
}

branches/incoming/src/librustc/metadata/tyencode.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,19 @@ fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
396396
enc_ty(w, cx, fsig.output);
397397
}
398398

399-
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @ty::ParamBounds) {
400-
for bs.builtin_bounds.each |bound| {
401-
match bound {
402-
ty::BoundOwned => w.write_char('S'),
403-
ty::BoundCopy => w.write_char('C'),
404-
ty::BoundConst => w.write_char('K'),
405-
ty::BoundStatic => w.write_char('O'),
399+
fn enc_bounds(w: @io::Writer, cx: @ctxt, bs: @~[ty::param_bound]) {
400+
for (*bs).each |bound| {
401+
match *bound {
402+
ty::bound_owned => w.write_char('S'),
403+
ty::bound_copy => w.write_char('C'),
404+
ty::bound_const => w.write_char('K'),
405+
ty::bound_durable => w.write_char('O'),
406+
ty::bound_trait(tp) => {
407+
w.write_char('I');
408+
enc_trait_ref(w, cx, tp);
409+
}
406410
}
407411
}
408-
409-
for bs.trait_bounds.each |&tp| {
410-
w.write_char('I');
411-
enc_trait_ref(w, cx, tp);
412-
}
413-
414412
w.write_char('.');
415413
}
416414

branches/incoming/src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub impl GatherLoanCtxt {
260260
r)
261261
}
262262
ty::AutoBorrowVec(r, m) | ty::AutoBorrowVecRef(r, m) => {
263-
let cmt_index = mcx.cat_index(expr, cmt);
263+
let cmt_index = mcx.cat_index(expr, cmt, autoderefs+1);
264264
self.guarantee_valid(expr.id,
265265
expr.span,
266266
cmt_index,
@@ -574,7 +574,7 @@ pub impl GatherLoanCtxt {
574574
let (slice_mutbl, slice_r) =
575575
self.vec_slice_info(slice_pat, slice_ty);
576576
let mcx = self.bccx.mc_ctxt();
577-
let cmt_index = mcx.cat_index(slice_pat, cmt);
577+
let cmt_index = mcx.cat_index(slice_pat, cmt, 0);
578578
self.guarantee_valid(pat.id, pat.span,
579579
cmt_index, slice_mutbl, slice_r);
580580
}

branches/incoming/src/librustc/middle/borrowck/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ pub type LoanMap = @mut HashMap<ast::node_id, @Loan>;
184184
//
185185
// Note that there is no entry with derefs:3---the type of that expression
186186
// is T, which is not a box.
187+
//
188+
// Note that implicit dereferences also occur with indexing of `@[]`,
189+
// `@str`, etc. The same rules apply. So, for example, given a
190+
// variable `x` of type `@[@[...]]`, if I have an instance of the
191+
// expression `x[0]` which is then auto-slice'd, there would be two
192+
// potential entries in the root map, both with the id of the `x[0]`
193+
// expression. The entry with `derefs==0` refers to the deref of `x`
194+
// used as part of evaluating `x[0]`. The entry with `derefs==1`
195+
// refers to the deref of the `x[0]` that occurs as part of the
196+
// auto-slice.
187197
#[deriving(Eq, IterBytes)]
188198
pub struct root_map_key {
189199
id: ast::node_id,
@@ -605,7 +615,7 @@ pub impl BorrowckCtxt {
605615
}
606616
}
607617

608-
LpExtend(lp_base, _, LpInterior(mc::interior_field(fld, _))) => {
618+
LpExtend(lp_base, _, LpInterior(mc::interior_field(fld))) => {
609619
self.append_loan_path_to_str_from_interior(lp_base, out);
610620
str::push_char(out, '.');
611621
str::push_str(out, *self.tcx.sess.intr().get(fld));

branches/incoming/src/librustc/middle/kind.rs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use middle::pat_util;
1414
use middle::ty;
1515
use middle::typeck;
1616
use util::ppaux::{Repr, ty_to_str};
17-
use util::ppaux::UserString;
1817

1918
use syntax::ast::*;
2019
use syntax::attr::attrs_contains_name;
@@ -339,19 +338,46 @@ pub fn check_bounds(cx: Context,
339338
type_param_def: &ty::TypeParameterDef)
340339
{
341340
let kind = ty::type_contents(cx.tcx, ty);
342-
let mut missing = ty::EmptyBuiltinBounds();
343-
for type_param_def.bounds.builtin_bounds.each |bound| {
344-
if !kind.meets_bound(cx.tcx, bound) {
345-
missing.add(bound);
341+
let mut missing = ~[];
342+
for type_param_def.bounds.each |bound| {
343+
match *bound {
344+
ty::bound_trait(_) => {
345+
/* Not our job, checking in typeck */
346+
}
347+
348+
ty::bound_copy => {
349+
if !kind.is_copy(cx.tcx) {
350+
missing.push("Copy");
351+
}
352+
}
353+
354+
ty::bound_durable => {
355+
if !kind.is_durable(cx.tcx) {
356+
missing.push("'static");
357+
}
358+
}
359+
360+
ty::bound_owned => {
361+
if !kind.is_owned(cx.tcx) {
362+
missing.push("Owned");
363+
}
364+
}
365+
366+
ty::bound_const => {
367+
if !kind.is_const(cx.tcx) {
368+
missing.push("Const");
369+
}
370+
}
346371
}
347372
}
373+
348374
if !missing.is_empty() {
349375
cx.tcx.sess.span_err(
350376
sp,
351377
fmt!("instantiating a type parameter with an incompatible type \
352378
`%s`, which does not fulfill `%s`",
353379
ty_to_str(cx.tcx, ty),
354-
missing.user_string(cx.tcx)));
380+
str::connect_slices(missing, " ")));
355381
}
356382
}
357383

@@ -414,7 +440,7 @@ pub fn check_owned(cx: Context, ty: ty::t, sp: span) -> bool {
414440

415441
// note: also used from middle::typeck::regionck!
416442
pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
417-
if !ty::type_is_static(tcx, ty) {
443+
if !ty::type_is_durable(tcx, ty) {
418444
match ty::get(ty).sty {
419445
ty::ty_param(*) => {
420446
tcx.sess.span_err(sp, "value may contain borrowed \

0 commit comments

Comments
 (0)