Skip to content

Commit b1e4c67

Browse files
committed
---
yaml --- r: 65150 b: refs/heads/master c: 32e30aa h: refs/heads/master v: v3
1 parent f9dee9c commit b1e4c67

File tree

20 files changed

+323
-161
lines changed

20 files changed

+323
-161
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 474d9983beb8a5770a202c552f36c14fa52917a2
2+
refs/heads/master: 32e30aaa00d098d81fd269d48845cbfd95d20710
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libcore/cast.rs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,17 @@
1212
1313
use sys;
1414
use unstable;
15-
16-
pub mod rusti {
17-
#[abi = "rust-intrinsic"]
18-
#[link_name = "rusti"]
19-
pub extern "rust-intrinsic" {
20-
fn forget<T>(x: T);
21-
22-
fn transmute<T,U>(e: T) -> U;
23-
}
24-
}
15+
use unstable::intrinsics;
2516

2617
/// Casts the value at `src` to U. The two types must have the same length.
2718
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
28-
let mut dest: U = unstable::intrinsics::init();
19+
let mut dest: U = intrinsics::init();
2920
{
30-
let dest_ptr: *mut u8 = rusti::transmute(&mut dest);
31-
let src_ptr: *u8 = rusti::transmute(src);
32-
unstable::intrinsics::memmove64(dest_ptr,
33-
src_ptr,
34-
sys::size_of::<U>() as u64);
21+
let dest_ptr: *mut u8 = transmute(&mut dest);
22+
let src_ptr: *u8 = transmute(src);
23+
intrinsics::memmove64(dest_ptr,
24+
src_ptr,
25+
sys::size_of::<U>() as u64);
3526
}
3627
dest
3728
}
@@ -45,7 +36,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
4536
* reinterpret_cast on pointer types.
4637
*/
4738
#[inline(always)]
48-
pub unsafe fn forget<T>(thing: T) { rusti::forget(thing); }
39+
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
4940

5041
/**
5142
* Force-increment the reference count on a shared box. If used
@@ -65,7 +56,7 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
6556
*/
6657
#[inline(always)]
6758
pub unsafe fn transmute<L, G>(thing: L) -> G {
68-
rusti::transmute(thing)
59+
intrinsics::transmute(thing)
6960
}
7061

7162
/// Coerce an immutable reference to be mutable.

trunk/src/libcore/clone.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ by convention implementing the `Clone` trait and calling the
2525
use core::kinds::Const;
2626

2727
pub trait Clone {
28-
/// Return a deep copy of the owned object tree. Types with shared ownership like managed boxes
29-
/// are cloned with a shallow copy.
28+
/// Returns a copy of the value. The contents of owned pointers
29+
/// are copied to maintain uniqueness, while the contents of
30+
/// managed pointers are not copied.
3031
fn clone(&self) -> Self;
3132
}
3233

@@ -85,8 +86,9 @@ clone_impl!(bool)
8586
clone_impl!(char)
8687

8788
pub trait DeepClone {
88-
/// Return a deep copy of the object tree. Types with shared ownership are also copied via a
89-
/// deep copy, unlike `Clone`.
89+
/// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
90+
/// *are* copied. Note that this is currently unimplemented for managed boxes, as
91+
/// it would need to handle cycles, but it is implemented for other smart-pointer types.
9092
fn deep_clone(&self) -> Self;
9193
}
9294

trunk/src/libcore/stackwalk.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#[doc(hidden)]; // FIXME #3538
1212

1313
use cast::transmute;
14+
use unstable::intrinsics;
1415

1516
pub type Word = uint;
1617

@@ -75,13 +76,6 @@ fn test_simple_deep() {
7576

7677
fn frame_address(f: &fn(x: *u8)) {
7778
unsafe {
78-
rusti::frame_address(f)
79-
}
80-
}
81-
82-
pub mod rusti {
83-
#[abi = "rust-intrinsic"]
84-
pub extern "rust-intrinsic" {
85-
pub fn frame_address(f: &once fn(x: *u8));
79+
intrinsics::frame_address(f)
8680
}
8781
}

trunk/src/libcore/sys.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use libc;
1919
use libc::{c_void, c_char, size_t};
2020
use repr;
2121
use str;
22+
use unstable::intrinsics;
2223

2324
pub type FreeGlue<'self> = &'self fn(*TypeDesc, *c_void);
2425

@@ -38,16 +39,6 @@ pub struct Closure {
3839
env: *(),
3940
}
4041

41-
pub mod rusti {
42-
#[abi = "rust-intrinsic"]
43-
pub extern "rust-intrinsic" {
44-
fn get_tydesc<T>() -> *();
45-
fn size_of<T>() -> uint;
46-
fn pref_align_of<T>() -> uint;
47-
fn min_align_of<T>() -> uint;
48-
}
49-
}
50-
5142
pub mod rustrt {
5243
use libc::{c_char, size_t};
5344

@@ -81,7 +72,7 @@ pub fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
8172
*/
8273
#[inline(always)]
8374
pub fn get_type_desc<T>() -> *TypeDesc {
84-
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
75+
unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
8576
}
8677

8778
/// Returns a pointer to a type descriptor.
@@ -93,7 +84,7 @@ pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
9384
/// Returns the size of a type
9485
#[inline(always)]
9586
pub fn size_of<T>() -> uint {
96-
unsafe { rusti::size_of::<T>() }
87+
unsafe { intrinsics::size_of::<T>() }
9788
}
9889

9990
/// Returns the size of the type that `_val` points to
@@ -128,7 +119,7 @@ pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
128119
*/
129120
#[inline(always)]
130121
pub fn min_align_of<T>() -> uint {
131-
unsafe { rusti::min_align_of::<T>() }
122+
unsafe { intrinsics::min_align_of::<T>() }
132123
}
133124

134125
/// Returns the ABI-required minimum alignment of the type of the value that
@@ -141,7 +132,7 @@ pub fn min_align_of_val<T>(_val: &T) -> uint {
141132
/// Returns the preferred alignment of a type
142133
#[inline(always)]
143134
pub fn pref_align_of<T>() -> uint {
144-
unsafe { rusti::pref_align_of::<T>() }
135+
unsafe { intrinsics::pref_align_of::<T>() }
145136
}
146137

147138
/// Returns the preferred alignment of the type of the value that

trunk/src/libcore/unstable/intrinsics.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,16 @@ pub extern "rust-intrinsic" {
114114
/// `forget` is unsafe because the caller is responsible for
115115
/// ensuring the argument is deallocated already.
116116
pub unsafe fn forget<T>(_: T) -> ();
117+
pub fn transmute<T,U>(e: T) -> U;
117118

118119
/// Returns `true` if a type requires drop glue.
119120
pub fn needs_drop<T>() -> bool;
120121

121122
// XXX: intrinsic uses legacy modes and has reference to TyDesc
122123
// and TyVisitor which are in librustc
123124
//fn visit_tydesc(++td: *TyDesc, &&tv: TyVisitor) -> ();
124-
// XXX: intrinsic uses legacy modes
125-
//fn frame_address(f: &once fn(*u8));
125+
126+
pub fn frame_address(f: &once fn(*u8));
126127

127128
/// Get the address of the `__morestack` stack growth function.
128129
pub fn morestack_addr() -> *();

trunk/src/librustc/lib/llvm.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,15 +1571,13 @@ pub mod llvm {
15711571
pub unsafe fn LLVMBuildAtomicLoad(B: BuilderRef,
15721572
PointerVal: ValueRef,
15731573
Name: *c_char,
1574-
Order: AtomicOrdering,
1575-
Alignment: c_uint)
1574+
Order: AtomicOrdering)
15761575
-> ValueRef;
15771576

15781577
pub unsafe fn LLVMBuildAtomicStore(B: BuilderRef,
15791578
Val: ValueRef,
15801579
Ptr: ValueRef,
1581-
Order: AtomicOrdering,
1582-
Alignment: c_uint)
1580+
Order: AtomicOrdering)
15831581
-> ValueRef;
15841582

15851583
pub unsafe fn LLVMBuildAtomicCmpXchg(B: BuilderRef,

trunk/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ pub impl<'self> CheckLoanCtxt<'self> {
343343
cmt = b;
344344
}
345345

346+
mc::cat_downcast(b) |
346347
mc::cat_interior(b, _) => {
347348
if cmt.mutbl == mc::McInherited {
348349
cmt = b;

trunk/src/librustc/middle/borrowck/gather_loans/lifetime.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl GuaranteeLifetimeContext {
104104
}
105105
}
106106

107+
mc::cat_downcast(base) |
107108
mc::cat_deref(base, _, mc::uniq_ptr(*)) |
108109
mc::cat_interior(base, _) => {
109110
self.check(base, discr_scope)
@@ -302,6 +303,7 @@ impl GuaranteeLifetimeContext {
302303
mc::cat_deref(*) => {
303304
false
304305
}
306+
r @ mc::cat_downcast(*) |
305307
r @ mc::cat_interior(*) |
306308
r @ mc::cat_stack_upvar(*) |
307309
r @ mc::cat_discr(*) => {
@@ -339,6 +341,7 @@ impl GuaranteeLifetimeContext {
339341
mc::cat_deref(_, _, mc::region_ptr(_, r)) => {
340342
r
341343
}
344+
mc::cat_downcast(cmt) |
342345
mc::cat_deref(cmt, _, mc::uniq_ptr(*)) |
343346
mc::cat_deref(cmt, _, mc::gc_ptr(*)) |
344347
mc::cat_interior(cmt, _) |

trunk/src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,17 @@ impl RestrictionsContext {
7979
set: restrictions}])
8080
}
8181

82-
mc::cat_interior(cmt_base, i @ mc::interior_variant(_)) => {
82+
mc::cat_downcast(cmt_base) => {
8383
// When we borrow the interior of an enum, we have to
8484
// ensure the enum itself is not mutated, because that
8585
// could cause the type of the memory to change.
86-
let result = self.compute(cmt_base, restrictions | RESTR_MUTATE);
87-
self.extend(result, cmt.mutbl, LpInterior(i), restrictions)
86+
self.compute(cmt_base, restrictions | RESTR_MUTATE)
8887
}
8988

90-
mc::cat_interior(cmt_base, i @ mc::interior_tuple) |
91-
mc::cat_interior(cmt_base, i @ mc::interior_anon_field) |
92-
mc::cat_interior(cmt_base, i @ mc::interior_field(*)) |
93-
mc::cat_interior(cmt_base, i @ mc::interior_index(*)) => {
94-
// For all of these cases, overwriting the base would
95-
// not change the type of the memory, so no additional
96-
// restrictions are needed.
97-
//
98-
// FIXME(#5397) --- Mut fields are not treated soundly
99-
// (hopefully they will just get phased out)
89+
mc::cat_interior(cmt_base, i) => {
90+
// Overwriting the base would not change the type of
91+
// the memory, so no additional restrictions are
92+
// needed.
10093
let result = self.compute(cmt_base, restrictions);
10194
self.extend(result, cmt.mutbl, LpInterior(i), restrictions)
10295
}

trunk/src/librustc/middle/borrowck/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ pub enum LoanPath {
232232

233233
#[deriving(Eq)]
234234
pub enum LoanPathElem {
235-
LpDeref, // `*LV` in doc.rs
236-
LpInterior(mc::interior_kind) // `LV.f` in doc.rs
235+
LpDeref, // `*LV` in doc.rs
236+
LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
237237
}
238238

239239
pub impl LoanPath {
@@ -276,6 +276,7 @@ pub fn opt_loan_path(cmt: mc::cmt) -> Option<@LoanPath> {
276276
|&lp| @LpExtend(lp, cmt.mutbl, LpInterior(ik)))
277277
}
278278

279+
mc::cat_downcast(cmt_base) |
279280
mc::cat_stack_upvar(cmt_base) |
280281
mc::cat_discr(cmt_base, _) => {
281282
opt_loan_path(cmt_base)
@@ -612,24 +613,25 @@ pub impl BorrowckCtxt {
612613
}
613614
}
614615

615-
LpExtend(lp_base, _, LpInterior(mc::interior_field(fld))) => {
616+
LpExtend(lp_base, _, LpInterior(mc::InteriorField(fname))) => {
616617
self.append_loan_path_to_str_from_interior(lp_base, out);
617-
str::push_char(out, '.');
618-
str::push_str(out, *self.tcx.sess.intr().get(fld));
618+
match fname {
619+
mc::NamedField(fname) => {
620+
str::push_char(out, '.');
621+
str::push_str(out, *self.tcx.sess.intr().get(fname));
622+
}
623+
mc::PositionalField(idx) => {
624+
str::push_char(out, '#'); // invent a notation here
625+
str::push_str(out, idx.to_str());
626+
}
627+
}
619628
}
620629

621-
LpExtend(lp_base, _, LpInterior(mc::interior_index(*))) => {
630+
LpExtend(lp_base, _, LpInterior(mc::InteriorElement(_))) => {
622631
self.append_loan_path_to_str_from_interior(lp_base, out);
623632
str::push_str(out, "[]");
624633
}
625634

626-
LpExtend(lp_base, _, LpInterior(mc::interior_tuple)) |
627-
LpExtend(lp_base, _, LpInterior(mc::interior_anon_field)) |
628-
LpExtend(lp_base, _, LpInterior(mc::interior_variant(_))) => {
629-
self.append_loan_path_to_str_from_interior(lp_base, out);
630-
str::push_str(out, ".(tuple)");
631-
}
632-
633635
LpExtend(lp_base, _, LpDeref) => {
634636
str::push_char(out, '*');
635637
self.append_loan_path_to_str(lp_base, out);

0 commit comments

Comments
 (0)