Skip to content

Commit 83153dc

Browse files
committed
---
yaml --- r: 140652 b: refs/heads/try2 c: dc2ca9d h: refs/heads/master v: v3
1 parent 62d838b commit 83153dc

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

+520
-621
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f547a671dcc64530f0cf07f39698d63174f37733
8+
refs/heads/try2: dc2ca9d8830a7a34242aa7722f545bc242813af3
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/cast.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,6 @@ 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)]
4127
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
4228
let mut dest: U = unstable::intrinsics::init();
4329
{

branches/try2/src/libcore/core.rc

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

63+
#[warn(vecs_implicitly_copyable)];
6364
#[deny(non_camel_case_types)];
6465
#[allow(deprecated_mutable_fields)];
6566

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

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

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

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

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

branches/try2/src/libcore/vec.rs

Lines changed: 5 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -584,29 +584,14 @@ 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)]
603587
pub fn pop<T>(v: &mut ~[T]) -> T {
604588
let ln = v.len();
605589
if ln == 0 {
606590
fail!(~"sorry, cannot vec::pop an empty vector")
607591
}
608592
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
609593
unsafe {
594+
// FIXME #4204: Should be uninit() - we don't need this zeroed
610595
let mut val = intrinsics::init();
611596
val <-> *valptr;
612597
raw::set_len(v, ln - 1u);
@@ -675,30 +660,13 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
675660
}
676661
677662
#[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)]
696663
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
697664
let new_len = v.len() + rhs.len();
698665
reserve(&mut *v, new_len);
699666
unsafe {
700667
do as_mut_buf(rhs) |p, len| {
701668
for uint::range(0, len) |i| {
669+
// FIXME #4204 Should be uninit() - don't need to zero
702670
let mut x = intrinsics::init();
703671
x <-> *ptr::mut_offset(p, i);
704672
push(&mut *v, x);
@@ -709,29 +677,13 @@ pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
709677
}
710678
711679
/// 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)]
729680
pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
730681
do as_mut_buf(*v) |p, oldlen| {
731682
assert!(newlen <= oldlen);
732683
unsafe {
733684
// This loop is optimized out for non-drop types.
734685
for uint::range(newlen, oldlen) |i| {
686+
// FIXME #4204 Should be uninit() - don't need to zero
735687
let mut dropped = intrinsics::init();
736688
dropped <-> *ptr::mut_offset(p, i);
737689
}
@@ -744,45 +696,6 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) {
744696
* Remove consecutive repeated elements from a vector; if the vector is
745697
* sorted, this removes all duplicates.
746698
*/
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)]
786699
pub fn dedup<T:Eq>(v: &mut ~[T]) {
787700
unsafe {
788701
if v.len() < 1 { return; }
@@ -796,6 +709,8 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
796709
// last_written < next_to_read < ln
797710
if *ptr::mut_offset(p, next_to_read) ==
798711
*ptr::mut_offset(p, last_written) {
712+
// FIXME #4204 Should be uninit() - don't need to
713+
// zero
799714
let mut dropped = intrinsics::init();
800715
dropped <-> *ptr::mut_offset(p, next_to_read);
801716
} else {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ 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));
241240
self.span_lint_level(level, span, msg);
242241
}
243242
fn next_node_id(@self) -> ast::node_id {

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

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,34 @@ 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::param_bound] {
559-
let mut bounds = ~[];
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+
};
560563
loop {
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-
});
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+
}
570587
}
571-
@bounds
572588
}

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,21 @@ 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::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-
}
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'),
410406
}
411407
}
408+
409+
for bs.trait_bounds.each |&tp| {
410+
w.write_char('I');
411+
enc_trait_ref(w, cx, tp);
412+
}
413+
412414
w.write_char('.');
413415
}
414416

branches/try2/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, autoderefs+1);
263+
let cmt_index = mcx.cat_index(expr, cmt);
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, 0);
577+
let cmt_index = mcx.cat_index(slice_pat, cmt);
578578
self.guarantee_valid(pat.id, pat.span,
579579
cmt_index, slice_mutbl, slice_r);
580580
}

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ 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.
197187
#[deriving(Eq, IterBytes)]
198188
pub struct root_map_key {
199189
id: ast::node_id,
@@ -615,7 +605,7 @@ pub impl BorrowckCtxt {
615605
}
616606
}
617607

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

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

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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;
1718

1819
use syntax::ast::*;
1920
use syntax::attr::attrs_contains_name;
@@ -338,46 +339,19 @@ pub fn check_bounds(cx: Context,
338339
type_param_def: &ty::TypeParameterDef)
339340
{
340341
let kind = ty::type_contents(cx.tcx, ty);
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-
}
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);
371346
}
372347
}
373-
374348
if !missing.is_empty() {
375349
cx.tcx.sess.span_err(
376350
sp,
377351
fmt!("instantiating a type parameter with an incompatible type \
378352
`%s`, which does not fulfill `%s`",
379353
ty_to_str(cx.tcx, ty),
380-
str::connect_slices(missing, " ")));
354+
missing.user_string(cx.tcx)));
381355
}
382356
}
383357

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

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

0 commit comments

Comments
 (0)