Skip to content

Commit c8b6477

Browse files
committed
---
yaml --- r: 191807 b: refs/heads/snap-stage3 c: 181441c h: refs/heads/master i: 191805: 9f27a76 191803: 63d42a4 191799: 97ec6ea 191791: cd5b562 191775: 21db7c3 191743: 49dee06 v: v3
1 parent 781453b commit c8b6477

Some content is hidden

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

71 files changed

+1090
-1215
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 809a554fca2d0ebc2ba50077016fe282a4064752
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: aa88da63179b8ccd3b809e98b489c25199b06cf7
4+
refs/heads/snap-stage3: 181441cf6632ad34f73bd52fc0e6246981cdb378
55
refs/heads/try: ce76bff75603a754d092456285ff455eb871633d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libarena/lib.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ extern crate alloc;
4242

4343
use std::cell::{Cell, RefCell};
4444
use std::cmp;
45-
use std::intrinsics::{TyDesc, get_tydesc};
4645
use std::intrinsics;
46+
#[cfg(stage0)] // SNAP 270a677
47+
use std::intrinsics::{get_tydesc, TyDesc};
4748
use std::marker;
4849
use std::mem;
4950
#[cfg(stage0)]
@@ -186,6 +187,27 @@ fn un_bitpack_tydesc_ptr(p: usize) -> (*const TyDesc, bool) {
186187
((p & !1) as *const TyDesc, p & 1 == 1)
187188
}
188189

190+
// HACK(eddyb) TyDesc replacement using a trait object vtable.
191+
// This could be replaced in the future with a custom DST layout,
192+
// or `&'static (drop_glue, size, align)` created by a `const fn`.
193+
#[cfg(not(stage0))] // SNAP 270a677
194+
struct TyDesc {
195+
drop_glue: fn(*const i8),
196+
size: usize,
197+
align: usize
198+
}
199+
200+
#[cfg(not(stage0))] // SNAP 270a677
201+
unsafe fn get_tydesc<T>() -> *const TyDesc {
202+
use std::raw::TraitObject;
203+
204+
let ptr = &*(1 as *const T);
205+
206+
// Can use any trait that is implemented for all types.
207+
let obj = mem::transmute::<&marker::MarkerTrait, TraitObject>(ptr);
208+
obj.vtable as *const TyDesc
209+
}
210+
189211
impl<'longer_than_self> Arena<'longer_than_self> {
190212
fn chunk_size(&self) -> usize {
191213
self.copy_head.borrow().capacity()

branches/snap-stage3/src/libcore/array.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,34 @@ use marker::{Copy, Sized};
2323
use option::Option;
2424
use slice::{Iter, IterMut, SliceExt};
2525

26+
/// Utility trait implemented only on arrays of fixed size
27+
///
28+
/// This trait can be used to implement other traits on fixed-size arrays
29+
/// without causing much metadata bloat.
30+
#[unstable(feature = "core")]
31+
pub trait FixedSizeArray<T> {
32+
/// Converts the array to immutable slice
33+
fn as_slice(&self) -> &[T];
34+
/// Converts the array to mutable slice
35+
fn as_mut_slice(&mut self) -> &mut [T];
36+
}
37+
2638
// macro for implementing n-ary tuple functions and operations
2739
macro_rules! array_impls {
2840
($($N:expr)+) => {
2941
$(
42+
#[unstable(feature = "core")]
43+
impl<T> FixedSizeArray<T> for [T; $N] {
44+
#[inline]
45+
fn as_slice(&self) -> &[T] {
46+
&self[..]
47+
}
48+
#[inline]
49+
fn as_mut_slice(&mut self) -> &mut [T] {
50+
&mut self[..]
51+
}
52+
}
53+
3054
#[stable(feature = "rust1", since = "1.0.0")]
3155
impl<T:Copy> Clone for [T; $N] {
3256
fn clone(&self) -> [T; $N] {

branches/snap-stage3/src/libcore/intrinsics.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@
4444

4545
use marker::Sized;
4646

47+
#[cfg(stage0)] // SNAP 270a677
4748
pub type GlueFn = extern "Rust" fn(*const i8);
4849

4950
#[lang="ty_desc"]
5051
#[derive(Copy)]
52+
#[cfg(stage0)] // SNAP 270a677
5153
pub struct TyDesc {
5254
// sizeof(T)
5355
pub size: usize,
@@ -197,8 +199,13 @@ extern "rust-intrinsic" {
197199
pub fn pref_align_of<T>() -> usize;
198200

199201
/// Get a static pointer to a type descriptor.
202+
#[cfg(stage0)] // SNAP 270a677
200203
pub fn get_tydesc<T: ?Sized>() -> *const TyDesc;
201204

205+
/// Gets a static string slice containing the name of a type.
206+
#[cfg(not(stage0))] // SNAP 270a677
207+
pub fn type_name<T: ?Sized>() -> &'static str;
208+
202209
/// Gets an identifier which is globally unique to the specified type. This
203210
/// function will return the same value for a type regardless of whichever
204211
/// crate it is invoked in.

branches/snap-stage3/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ pub mod default;
129129
/* Core types and methods on primitives */
130130

131131
pub mod any;
132+
pub mod array;
132133
pub mod atomic;
133134
pub mod cell;
134135
pub mod char;
@@ -151,7 +152,6 @@ mod bool {
151152

152153
// note: does not need to be public
153154
mod tuple;
154-
mod array;
155155

156156
#[doc(hidden)]
157157
mod core {

branches/snap-stage3/src/libcore/result.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ impl<T, E> Result<T, E> {
448448
/// ```
449449
/// use std::old_io::IoResult;
450450
///
451-
/// let mut buffer = &mut b"1\n2\n3\n4\n";
451+
/// let mut buffer: &[u8] = b"1\n2\n3\n4\n";
452+
/// let mut buffer = &mut buffer;
452453
///
453454
/// let mut sum = 0;
454455
///

branches/snap-stage3/src/librustc/middle/astencode.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,14 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
993993
})
994994
}
995995

996+
ty::AdjustUnsafeFnPointer => {
997+
this.emit_enum_variant("AdjustUnsafeFnPointer", 2, 0, |_| {
998+
Ok(())
999+
})
1000+
}
1001+
9961002
ty::AdjustDerefRef(ref auto_deref_ref) => {
997-
this.emit_enum_variant("AdjustDerefRef", 2, 2, |this| {
1003+
this.emit_enum_variant("AdjustDerefRef", 3, 2, |this| {
9981004
this.emit_enum_variant_arg(0,
9991005
|this| Ok(this.emit_auto_deref_ref(ecx, auto_deref_ref)))
10001006
})
@@ -1619,6 +1625,9 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
16191625
ty::AdjustReifyFnPointer(def_id)
16201626
}
16211627
2 => {
1628+
ty::AdjustUnsafeFnPointer
1629+
}
1630+
3 => {
16221631
let auto_deref_ref: ty::AutoDerefRef =
16231632
this.read_enum_variant_arg(0,
16241633
|this| Ok(this.read_auto_deref_ref(dcx))).unwrap();

branches/snap-stage3/src/librustc/middle/expr_use_visitor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
790790
None => { }
791791
Some(adjustment) => {
792792
match *adjustment {
793-
ty::AdjustReifyFnPointer(..) => {
793+
ty::AdjustReifyFnPointer(..) |
794+
ty::AdjustUnsafeFnPointer(..) => {
794795
// Creating a closure/fn-pointer consumes the
795796
// input and stores it into the resulting
796797
// rvalue.

branches/snap-stage3/src/librustc/middle/infer/bivariate.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ use middle::infer::{cres};
3333
use middle::infer::type_variable::{BiTo};
3434
use util::ppaux::{Repr};
3535

36-
use syntax::ast::{Unsafety};
37-
3836
pub struct Bivariate<'f, 'tcx: 'f> {
3937
fields: CombineFields<'f, 'tcx>
4038
}
@@ -74,24 +72,6 @@ impl<'f, 'tcx> Combine<'tcx> for Bivariate<'f, 'tcx> {
7472
Ok(a)
7573
}
7674

77-
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
78-
debug!("mts({} <: {})",
79-
a.repr(self.fields.infcx.tcx),
80-
b.repr(self.fields.infcx.tcx));
81-
82-
if a.mutbl != b.mutbl { return Err(ty::terr_mutability); }
83-
let t = try!(self.tys(a.ty, b.ty));
84-
Ok(ty::mt { mutbl: a.mutbl, ty: t })
85-
}
86-
87-
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
88-
if a != b {
89-
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
90-
} else {
91-
Ok(a)
92-
}
93-
}
94-
9575
fn builtin_bounds(&self,
9676
a: BuiltinBounds,
9777
b: BuiltinBounds)

branches/snap-stage3/src/librustc/middle/infer/combine.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,24 @@ pub trait Combine<'tcx> : Sized {
7474
fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields().clone()) }
7575
fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields().clone()) }
7676

77-
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>>;
77+
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
78+
debug!("{}.mts({}, {})",
79+
self.tag(),
80+
a.repr(self.tcx()),
81+
b.repr(self.tcx()));
82+
83+
if a.mutbl != b.mutbl {
84+
Err(ty::terr_mutability)
85+
} else {
86+
let mutbl = a.mutbl;
87+
let variance = match mutbl {
88+
ast::MutImmutable => ty::Covariant,
89+
ast::MutMutable => ty::Invariant,
90+
};
91+
let ty = try!(self.tys_with_variance(variance, a.ty, b.ty));
92+
Ok(ty::mt {ty: ty, mutbl: mutbl})
93+
}
94+
}
7895

7996
fn tys_with_variance(&self, variance: ty::Variance, a: Ty<'tcx>, b: Ty<'tcx>)
8097
-> cres<'tcx, Ty<'tcx>>;
@@ -246,7 +263,13 @@ pub trait Combine<'tcx> : Sized {
246263
self.tys_with_variance(ty::Contravariant, a, b).and_then(|t| Ok(t))
247264
}
248265

249-
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety>;
266+
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
267+
if a != b {
268+
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
269+
} else {
270+
Ok(a)
271+
}
272+
}
250273

251274
fn abi(&self, a: abi::Abi, b: abi::Abi) -> cres<'tcx, abi::Abi> {
252275
if a == b {

branches/snap-stage3/src/librustc/middle/infer/equate.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use middle::infer::{Subtype};
1616
use middle::infer::type_variable::{EqTo};
1717
use util::ppaux::{Repr};
1818

19-
use syntax::ast::Unsafety;
20-
2119
pub struct Equate<'f, 'tcx: 'f> {
2220
fields: CombineFields<'f, 'tcx>
2321
}
@@ -54,24 +52,6 @@ impl<'f, 'tcx> Combine<'tcx> for Equate<'f, 'tcx> {
5452
Ok(a)
5553
}
5654

57-
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
58-
debug!("mts({} <: {})",
59-
a.repr(self.fields.infcx.tcx),
60-
b.repr(self.fields.infcx.tcx));
61-
62-
if a.mutbl != b.mutbl { return Err(ty::terr_mutability); }
63-
let t = try!(self.tys(a.ty, b.ty));
64-
Ok(ty::mt { mutbl: a.mutbl, ty: t })
65-
}
66-
67-
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
68-
if a != b {
69-
Err(ty::terr_unsafety_mismatch(expected_found(self, a, b)))
70-
} else {
71-
Ok(a)
72-
}
73-
}
74-
7555
fn tys(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> cres<'tcx, Ty<'tcx>> {
7656
debug!("{}.tys({}, {})", self.tag(),
7757
a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx));

branches/snap-stage3/src/librustc/middle/infer/glb.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use super::{cres};
1515
use super::Subtype;
1616

1717
use middle::ty::{self, Ty};
18-
use syntax::ast::{MutImmutable, MutMutable, Unsafety};
19-
use util::ppaux::mt_to_string;
2018
use util::ppaux::Repr;
2119

2220
/// "Greatest lower bound" (common subtype)
@@ -55,44 +53,6 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> {
5553
}
5654
}
5755

58-
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
59-
let tcx = self.fields.infcx.tcx;
60-
61-
debug!("{}.mts({}, {})",
62-
self.tag(),
63-
mt_to_string(tcx, a),
64-
mt_to_string(tcx, b));
65-
66-
match (a.mutbl, b.mutbl) {
67-
// If one side or both is mut, then the GLB must use
68-
// the precise type from the mut side.
69-
(MutMutable, MutMutable) => {
70-
let t = try!(self.equate().tys(a.ty, b.ty));
71-
Ok(ty::mt {ty: t, mutbl: MutMutable})
72-
}
73-
74-
// If one side or both is immutable, we can use the GLB of
75-
// both sides but mutbl must be `MutImmutable`.
76-
(MutImmutable, MutImmutable) => {
77-
let t = try!(self.tys(a.ty, b.ty));
78-
Ok(ty::mt {ty: t, mutbl: MutImmutable})
79-
}
80-
81-
// There is no mutual subtype of these combinations.
82-
(MutMutable, MutImmutable) |
83-
(MutImmutable, MutMutable) => {
84-
Err(ty::terr_mutability)
85-
}
86-
}
87-
}
88-
89-
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
90-
match (a, b) {
91-
(Unsafety::Normal, _) | (_, Unsafety::Normal) => Ok(Unsafety::Normal),
92-
(Unsafety::Unsafe, Unsafety::Unsafe) => Ok(Unsafety::Unsafe)
93-
}
94-
}
95-
9656
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
9757
debug!("{}.regions({}, {})",
9858
self.tag(),

branches/snap-stage3/src/librustc/middle/infer/lub.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use super::{cres};
1515
use super::{Subtype};
1616

1717
use middle::ty::{self, Ty};
18-
use syntax::ast::{MutMutable, MutImmutable, Unsafety};
19-
use util::ppaux::mt_to_string;
2018
use util::ppaux::Repr;
2119

2220
/// "Least upper bound" (common supertype)
@@ -55,39 +53,6 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> {
5553
}
5654
}
5755

58-
fn mts(&self, a: &ty::mt<'tcx>, b: &ty::mt<'tcx>) -> cres<'tcx, ty::mt<'tcx>> {
59-
let tcx = self.tcx();
60-
61-
debug!("{}.mts({}, {})",
62-
self.tag(),
63-
mt_to_string(tcx, a),
64-
mt_to_string(tcx, b));
65-
66-
if a.mutbl != b.mutbl {
67-
return Err(ty::terr_mutability)
68-
}
69-
70-
let m = a.mutbl;
71-
match m {
72-
MutImmutable => {
73-
let t = try!(self.tys(a.ty, b.ty));
74-
Ok(ty::mt {ty: t, mutbl: m})
75-
}
76-
77-
MutMutable => {
78-
let t = try!(self.equate().tys(a.ty, b.ty));
79-
Ok(ty::mt {ty: t, mutbl: m})
80-
}
81-
}
82-
}
83-
84-
fn unsafeties(&self, a: Unsafety, b: Unsafety) -> cres<'tcx, Unsafety> {
85-
match (a, b) {
86-
(Unsafety::Unsafe, _) | (_, Unsafety::Unsafe) => Ok(Unsafety::Unsafe),
87-
(Unsafety::Normal, Unsafety::Normal) => Ok(Unsafety::Normal),
88-
}
89-
}
90-
9156
fn regions(&self, a: ty::Region, b: ty::Region) -> cres<'tcx, ty::Region> {
9257
debug!("{}.regions({}, {})",
9358
self.tag(),

0 commit comments

Comments
 (0)