Skip to content

Commit e13a3da

Browse files
committed
---
yaml --- r: 140649 b: refs/heads/try2 c: 15164cc h: refs/heads/master i: 140647: 15e157e v: v3
1 parent d299f1d commit e13a3da

File tree

33 files changed

+182
-351
lines changed

33 files changed

+182
-351
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: 76758562539ef3c439dd28ad53636f6b70382e7b
8+
refs/heads/try2: 15164cc6a6b6a382b5cbe527e435dfa9eb162fd4
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/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/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 10 additions & 0 deletions
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,

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,6 @@ pub fn get_lint_dict() -> LintDict {
237237
return @map;
238238
}
239239

240-
pub fn get_lint_name(lint_mode: lint) -> ~str {
241-
for lint_table.each |&(name, spec)| {
242-
if spec.lint == lint_mode {
243-
return name.to_str();
244-
}
245-
}
246-
fail!();
247-
}
248240
// This is a highly not-optimal set of data structure decisions.
249241
type LintModes = @mut SmallIntMap<level>;
250242
type LintModeMap = @mut HashMap<ast::node_id, LintModes>;

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

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ pub impl mem_categorization_ctxt {
405405
}
406406

407407
let base_cmt = self.cat_expr(base);
408-
self.cat_index(expr, base_cmt)
408+
self.cat_index(expr, base_cmt, 0)
409409
}
410410

411411
ast::expr_path(_) => {
@@ -670,7 +670,39 @@ pub impl mem_categorization_ctxt {
670670

671671
fn cat_index<N:ast_node>(&self,
672672
elt: N,
673-
base_cmt: cmt) -> cmt {
673+
base_cmt: cmt,
674+
derefs: uint) -> cmt {
675+
//! Creates a cmt for an indexing operation (`[]`); this
676+
//! indexing operation may occurs as part of an
677+
//! AutoBorrowVec, which when converting a `~[]` to an `&[]`
678+
//! effectively takes the address of the 0th element.
679+
//!
680+
//! One subtle aspect of indexing that may not be
681+
//! immediately obvious: for anything other than a fixed-length
682+
//! vector, an operation like `x[y]` actually consists of two
683+
//! disjoint (from the point of view of borrowck) operations.
684+
//! The first is a deref of `x` to create a pointer `p` that points
685+
//! at the first element in the array. The second operation is
686+
//! an index which adds `y*sizeof(T)` to `p` to obtain the
687+
//! pointer to `x[y]`. `cat_index` will produce a resulting
688+
//! cmt containing both this deref and the indexing,
689+
//! presuming that `base_cmt` is not of fixed-length type.
690+
//!
691+
//! In the event that a deref is needed, the "deref count"
692+
//! is taken from the parameter `derefs`. See the comment
693+
//! on the def'n of `root_map_key` in borrowck/mod.rs
694+
//! for more details about deref counts; the summary is
695+
//! that `derefs` should be 0 for an explicit indexing
696+
//! operation and N+1 for an indexing that is part of
697+
//! an auto-adjustment, where N is the number of autoderefs
698+
//! in that adjustment.
699+
//!
700+
//! # Parameters
701+
//! - `elt`: the AST node being indexed
702+
//! - `base_cmt`: the cmt of `elt`
703+
//! - `derefs`: the deref number to be used for
704+
//! the implicit index deref, if any (see above)
705+
674706
let mt = match ty::index(base_cmt.ty) {
675707
Some(mt) => mt,
676708
None => {
@@ -698,7 +730,7 @@ pub impl mem_categorization_ctxt {
698730
let deref_cmt = @cmt_ {
699731
id:elt.id(),
700732
span:elt.span(),
701-
cat:cat_deref(base_cmt, 0u, ptr),
733+
cat:cat_deref(base_cmt, derefs, ptr),
702734
mutbl:m,
703735
ty:mt.ty
704736
};
@@ -878,8 +910,8 @@ pub impl mem_categorization_ctxt {
878910
}
879911

880912
ast::pat_vec(ref before, slice, ref after) => {
913+
let elt_cmt = self.cat_index(pat, cmt, 0);
881914
for before.each |&before_pat| {
882-
let elt_cmt = self.cat_index(pat, cmt);
883915
self.cat_pattern(elt_cmt, before_pat, op);
884916
}
885917
for slice.each |&slice_pat| {
@@ -888,7 +920,6 @@ pub impl mem_categorization_ctxt {
888920
self.cat_pattern(slice_cmt, slice_pat, op);
889921
}
890922
for after.each |&after_pat| {
891-
let elt_cmt = self.cat_index(pat, cmt);
892923
self.cat_pattern(elt_cmt, after_pat, op);
893924
}
894925
}

branches/try2/src/librustc/middle/trans/_match.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ pub fn extract_vec_elems(bcx: block,
885885
-> ExtractedBlock {
886886
let _icx = bcx.insn_ctxt("match::extract_vec_elems");
887887
let vec_datum = match_datum(bcx, val, pat_id);
888-
let (bcx, base, len) = vec_datum.get_vec_base_and_len(bcx, pat_span, pat_id);
888+
let (bcx, base, len) = vec_datum.get_vec_base_and_len(bcx, pat_span,
889+
pat_id, 0);
889890
let vt = tvec::vec_types(bcx, node_id_type(bcx, pat_id));
890891
891892
let mut elems = do vec::from_fn(elem_count) |i| {

branches/try2/src/librustc/middle/trans/datum.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,14 @@ pub impl Datum {
735735
fn get_vec_base_and_len(&self,
736736
mut bcx: block,
737737
span: span,
738-
expr_id: ast::node_id)
738+
expr_id: ast::node_id,
739+
derefs: uint)
739740
-> (block, ValueRef, ValueRef) {
740741
//! Converts a vector into the slice pair. Performs rooting
741742
//! and write guards checks.
742743
743744
// only imp't for @[] and @str, but harmless
744-
bcx = write_guard::root_and_write_guard(self, bcx, span, expr_id, 0);
745+
bcx = write_guard::root_and_write_guard(self, bcx, span, expr_id, derefs);
745746
let (base, len) = self.get_vec_base_and_len_no_root(bcx);
746747
(bcx, base, len)
747748
}

0 commit comments

Comments
 (0)