Skip to content

Commit 778ab06

Browse files
committed
---
yaml --- r: 130133 b: refs/heads/master c: 7241267 h: refs/heads/master i: 130131: 1b6bcb8 v: v3
1 parent b313007 commit 778ab06

27 files changed

+115
-486
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: e59a4584c98e0eb21be5ba0a972a647025f14df5
2+
refs/heads/master: 7241267b93ea02cc25edda531fdc5b6261a96d01
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0

trunk/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We want to maintain the option to parametrize at runtime. We may eventually chan
8383

8484
## Why aren't values type-parametric? Why only items?
8585

86-
Doing so would make type inference much more complex, and require the implementation strategy of runtime parametrization.
86+
Doing so would make type inference much more complex, and require the implementation strategy of runtime parameterization.
8787

8888
## Why are enumerations nominal and closed?
8989

trunk/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ our code in this file. We'll talk about multiple-file projects later on in the
18081808
guide.
18091809

18101810
Before we move on, let me show you one more Cargo command: `run`. `cargo run`
1811-
is kind of like `cargo build`, but it also then runs the produced exectuable.
1811+
is kind of like `cargo build`, but it also then runs the produced executable.
18121812
Try it out:
18131813

18141814
```{notrust,ignore}

trunk/src/doc/rust.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ On `struct`s:
19541954

19551955
- `repr` - specifies the representation to use for this struct. Takes a list
19561956
of options. The currently accepted ones are `C` and `packed`, which may be
1957-
combined. `C` will use a C ABI comptible struct layout, and `packed` will
1957+
combined. `C` will use a C ABI compatible struct layout, and `packed` will
19581958
remove any padding between fields (note that this is very fragile and may
19591959
break platforms which require aligned access).
19601960

@@ -2367,7 +2367,7 @@ One can indicate the stability of an API using the following attributes:
23672367
These levels are directly inspired by
23682368
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23692369

2370-
Stability levels are inherited, so an items's stability attribute is the
2370+
Stability levels are inherited, so an item's stability attribute is the
23712371
default stability for everything nested underneath it.
23722372

23732373
There are lints for disallowing items marked with certain levels: `deprecated`,
@@ -2444,7 +2444,7 @@ The currently implemented features of the reference compiler are:
24442444

24452445
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
24462446
ways insufficient for concatenating identifiers, and may
2447-
be removed entirely for something more wholsome.
2447+
be removed entirely for something more wholesome.
24482448

24492449
* `default_type_params` - Allows use of default type parameters. The future of
24502450
this feature is uncertain.
@@ -3604,7 +3604,7 @@ of the type.[^structtype]
36043604

36053605
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
36063606

3607-
The memory layout of a `struct` is undefined by default to allow for compiler optimziations like
3607+
The memory layout of a `struct` is undefined by default to allow for compiler optimizations like
36083608
field reordering, but it can be fixed with the `#[repr(...)]` attribute.
36093609
In either case, fields may be given in any order in a corresponding struct *expression*;
36103610
the resulting `struct` value will always have the same memory layout.
@@ -3668,17 +3668,32 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668

36693669
All pointers in Rust are explicit first-class values.
36703670
They can be copied, stored into data structures, and returned from functions.
3671-
There are two varieties of pointer in Rust:
3671+
There are four varieties of pointer in Rust:
3672+
3673+
* Owning pointers (`Box`)
3674+
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675+
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676+
Owning pointers are written `Box<content>`,
3677+
for example `Box<int>` means an owning pointer to an owned box containing an integer.
3678+
Copying an owned box is a "deep" operation:
3679+
it involves allocating a new owned box and copying the contents of the old box into the new box.
3680+
Releasing an owning pointer immediately releases its corresponding owned box.
36723681

36733682
* References (`&`)
36743683
: These point to memory _owned by some other value_.
3675-
A reference type is written `&type` for some lifetime-variable `f`,
3676-
or just `&'a type` when you need an explicit lifetime.
3684+
References arise by (automatic) conversion from owning pointers, managed pointers,
3685+
or by applying the borrowing operator `&` to some other value,
3686+
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3687+
A borrow expression is written `&content`.
3688+
3689+
A reference type is written `&'f type` for some lifetime-variable `f`,
3690+
or just `&type` when the lifetime can be elided;
3691+
for example `&int` means a reference to an integer.
36773692
Copying a reference is a "shallow" operation:
36783693
it involves only copying the pointer itself.
36793694
Releasing a reference typically has no effect on the value it points to,
3680-
with the exception of temporary values, which are released when the last
3681-
reference to them is released.
3695+
with the exception of temporary values,
3696+
which are released when the last reference to them is released.
36823697

36833698
* Raw pointers (`*`)
36843699
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3691,9 +3706,6 @@ There are two varieties of pointer in Rust:
36913706
they exist to support interoperability with foreign code,
36923707
and writing performance-critical or low-level functions.
36933708

3694-
The standard library contains addtional 'smart pointer' types beyond references
3695-
and raw pointers.
3696-
36973709
### Function types
36983710

36993711
The function type constructor `fn` forms new function types.
@@ -4202,7 +4214,7 @@ be ignored in favor of only building the artifacts specified by command line.
42024214
purpose of this output type is to create a static library containing all of
42034215
the local crate's code along with all upstream dependencies. The static
42044216
library is actually a `*.a` archive on linux and osx and a `*.lib` file on
4205-
windows. This format is recommended for use in situtations such as linking
4217+
windows. This format is recommended for use in situations such as linking
42064218
Rust code into an existing non-Rust application because it will not have
42074219
dynamic dependencies on other Rust code.
42084220

trunk/src/libcore/slice.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -996,15 +996,6 @@ impl<'a, T> Collection for &'a [T] {
996996
}
997997
}
998998

999-
#[experimental = "trait is experimental"]
1000-
impl<'a, T> Collection for &'a mut [T] {
1001-
/// Returns the length of a vector
1002-
#[inline]
1003-
fn len(&self) -> uint {
1004-
self.repr().len
1005-
}
1006-
}
1007-
1008999
#[unstable = "waiting for DST"]
10091000
impl<'a, T> Default for &'a [T] {
10101001
fn default() -> &'a [T] { &[] }

trunk/src/librustc/diagnostics.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,5 @@ register_diagnostics!(
169169
E0155,
170170
E0156,
171171
E0157,
172-
E0158,
173-
E0159,
174-
E0160
172+
E0158
175173
)

trunk/src/librustc/middle/astencode.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,18 +1073,9 @@ impl<'a> rbml_writer_helpers for Encoder<'a> {
10731073
this.emit_enum_variant_arg(0, |this| Ok(this.emit_unsize_kind(ecx, uk)))
10741074
})
10751075
}
1076-
&ty::AutoUnsafe(m, None) => {
1077-
this.emit_enum_variant("AutoUnsafe", 3, 2, |this| {
1078-
this.emit_enum_variant_arg(0, |this| m.encode(this));
1079-
this.emit_enum_variant_arg(1,
1080-
|this| this.emit_option(|this| this.emit_option_none()))
1081-
})
1082-
}
1083-
&ty::AutoUnsafe(m, Some(box ref a)) => {
1084-
this.emit_enum_variant("AutoUnsafe", 3, 2, |this| {
1085-
this.emit_enum_variant_arg(0, |this| m.encode(this));
1086-
this.emit_enum_variant_arg(1, |this| this.emit_option(
1087-
|this| this.emit_option_some(|this| Ok(this.emit_autoref(ecx, a)))))
1076+
&ty::AutoUnsafe(m) => {
1077+
this.emit_enum_variant("AutoUnsafe", 3, 1, |this| {
1078+
this.emit_enum_variant_arg(0, |this| m.encode(this))
10881079
})
10891080
}
10901081
}
@@ -1644,16 +1635,8 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> {
16441635
3 => {
16451636
let m: ast::Mutability =
16461637
this.read_enum_variant_arg(0, |this| Decodable::decode(this)).unwrap();
1647-
let a: Option<Box<ty::AutoRef>> =
1648-
this.read_enum_variant_arg(1, |this| this.read_option(|this, b| {
1649-
if b {
1650-
Ok(Some(box this.read_autoref(xcx)))
1651-
} else {
1652-
Ok(None)
1653-
}
1654-
})).unwrap();
16551638

1656-
ty::AutoUnsafe(m, a)
1639+
ty::AutoUnsafe(m)
16571640
}
16581641
_ => fail!("bad enum variant for ty::AutoRef")
16591642
})

trunk/src/librustc/middle/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ impl<'d,'t,TYPER:mc::Typer> ExprUseVisitor<'d,'t,TYPER> {
762762
ty::BorrowKind::from_mutbl(m),
763763
AutoRef);
764764
}
765-
ty::AutoUnsizeUniq(_) | ty::AutoUnsize(_) | ty::AutoUnsafe(..) => {}
765+
ty::AutoUnsizeUniq(_) | ty::AutoUnsize(_) | ty::AutoUnsafe(_) => {}
766766
}
767767
}
768768

trunk/src/librustc/middle/trans/adt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,8 @@ impl Case {
296296

297297
for (i, &ty) in self.tys.iter().enumerate() {
298298
match ty::get(ty).sty {
299-
// &T/&mut T/*T could either be a thin or fat pointer depending on T
300-
ty::ty_rptr(_, ty::mt { ty, .. })
301-
| ty::ty_ptr(ty::mt { ty, .. }) => match ty::get(ty).sty {
299+
// &T/&mut T could either be a thin or fat pointer depending on T
300+
ty::ty_rptr(_, ty::mt { ty, .. }) => match ty::get(ty).sty {
302301
// &[T] and &str are a pointer and length pair
303302
ty::ty_vec(_, None) | ty::ty_str => return Some(FatPointer(i, slice_elt_base)),
304303

trunk/src/librustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,8 @@ pub fn compare_scalar_types<'a>(
566566

567567
match ty::get(t).sty {
568568
ty::ty_nil => f(nil_type),
569-
ty::ty_bool | ty::ty_uint(_) | ty::ty_char => f(unsigned_int),
570-
ty::ty_ptr(mt) if ty::type_is_sized(cx.tcx(), mt.ty) => f(unsigned_int),
569+
ty::ty_bool | ty::ty_ptr(_) |
570+
ty::ty_uint(_) | ty::ty_char => f(unsigned_int),
571571
ty::ty_int(_) => f(signed_int),
572572
ty::ty_float(_) => f(floating_point),
573573
// Should never get here, because t is scalar.

trunk/src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr, is_local: bool) -> (ValueRef
243243
}
244244
Some(ref autoref) => {
245245
match *autoref {
246-
ty::AutoUnsafe(_, None) |
246+
ty::AutoUnsafe(_) |
247247
ty::AutoPtr(ty::ReStatic, _, None) => {
248248
// Don't copy data to do a deref+ref
249249
// (i.e., skip the last auto-deref).

trunk/src/librustc/middle/trans/expr.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>,
254254
let mut datum = datum;
255255

256256
let datum = match autoref {
257-
&AutoPtr(_, _, ref a) | &AutoUnsafe(_, ref a) => {
257+
&AutoUnsafe(..) => {
258+
debug!(" AutoUnsafe");
259+
unpack_datum!(bcx, ref_ptr(bcx, expr, datum))
260+
}
261+
&AutoPtr(_, _, ref a) => {
258262
debug!(" AutoPtr");
259263
match a {
260264
&Some(box ref a) => datum = unpack_datum!(bcx,
@@ -1843,7 +1847,8 @@ pub fn cast_type_kind(tcx: &ty::ctxt, t: ty::t) -> cast_kind {
18431847
match ty::get(t).sty {
18441848
ty::ty_char => cast_integral,
18451849
ty::ty_float(..) => cast_float,
1846-
ty::ty_rptr(_, mt) | ty::ty_ptr(mt) => {
1850+
ty::ty_ptr(..) => cast_pointer,
1851+
ty::ty_rptr(_, mt) => {
18471852
if ty::type_is_sized(tcx, mt.ty) {
18481853
cast_pointer
18491854
} else {

trunk/src/librustc/middle/trans/reflect.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a, 'b> Reflector<'a, 'b> {
154154
// Unfortunately we can't do anything here because at runtime we
155155
// pass around the value by pointer (*u8). But unsized pointers are
156156
// fat and so we can't just cast them to *u8 and back. So we have
157-
// to work with the pointer directly (see ty_ptr/ty_rptr/ty_uniq).
157+
// to work with the pointer directly (see ty_rptr/ty_uniq).
158158
fail!("Can't reflect unsized type")
159159
}
160160
// FIXME(15049) Reflection for unsized structs.
@@ -177,24 +177,8 @@ impl<'a, 'b> Reflector<'a, 'b> {
177177
self.visit("box", extra.as_slice())
178178
}
179179
ty::ty_ptr(ref mt) => {
180-
match ty::get(mt.ty).sty {
181-
ty::ty_vec(ty, None) => {
182-
let extra = self.c_mt(&ty::mt{ty: ty, mutbl: mt.mutbl});
183-
self.visit("evec_slice", extra.as_slice())
184-
}
185-
ty::ty_str => self.visit("estr_slice", &[]),
186-
ty::ty_trait(..) => {
187-
let extra = [
188-
self.c_slice(token::intern_and_get_ident(
189-
ty_to_string(tcx, t).as_slice()))
190-
];
191-
self.visit("trait", extra);
192-
}
193-
_ => {
194-
let extra = self.c_mt(mt);
195-
self.visit("ptr", extra.as_slice())
196-
}
197-
}
180+
let extra = self.c_mt(mt);
181+
self.visit("ptr", extra.as_slice())
198182
}
199183
ty::ty_uniq(typ) => {
200184
match ty::get(typ).sty {

trunk/src/librustc/middle/trans/type_of.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
174174
ty::ty_uint(t) => Type::uint_from_ty(cx, t),
175175
ty::ty_float(t) => Type::float_from_ty(cx, t),
176176

177-
ty::ty_box(..) => Type::i8p(cx),
178-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => {
177+
ty::ty_box(..) |
178+
ty::ty_ptr(..) => Type::i8p(cx),
179+
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => {
179180
if ty::type_is_sized(cx.tcx(), ty) {
180181
Type::i8p(cx)
181182
} else {
@@ -302,8 +303,9 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
302303
ty::ty_box(typ) => {
303304
Type::at_box(cx, type_of(cx, typ)).ptr_to()
304305
}
306+
ty::ty_ptr(ref mt) => type_of(cx, mt.ty).ptr_to(),
305307

306-
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => {
308+
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => {
307309
match ty::get(ty).sty {
308310
ty::ty_str => {
309311
// This means we get a nicer name in the output (str is always

trunk/src/librustc/middle/ty.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ pub enum AutoRef {
298298

299299
/// Convert from T to *T
300300
/// Value to thin pointer
301-
/// The second field allows us to wrap other AutoRef adjustments.
302-
AutoUnsafe(ast::Mutability, Option<Box<AutoRef>>),
301+
AutoUnsafe(ast::Mutability),
303302
}
304303

305304
// Ugly little helper function. The first bool in the returned tuple is true if
@@ -327,7 +326,6 @@ fn autoref_object_region(autoref: &AutoRef) -> (bool, bool, Option<Region>) {
327326
(b, u, Some(adj_r))
328327
}
329328
}
330-
&AutoUnsafe(_, Some(box ref autoref)) => autoref_object_region(autoref),
331329
_ => (false, false, None)
332330
}
333331
}
@@ -382,12 +380,6 @@ pub fn type_of_adjust(cx: &ctxt, adj: &AutoAdjustment) -> Option<t> {
382380
None => None
383381
}
384382
}
385-
&AutoUnsafe(m, Some(box ref autoref)) => {
386-
match type_of_autoref(cx, autoref) {
387-
Some(t) => Some(mk_ptr(cx, mt {mutbl: m, ty: t})),
388-
None => None
389-
}
390-
}
391383
_ => None
392384
}
393385
}
@@ -1906,7 +1898,7 @@ pub fn type_is_self(ty: t) -> bool {
19061898

19071899
fn type_is_slice(ty: t) -> bool {
19081900
match get(ty).sty {
1909-
ty_ptr(mt) | ty_rptr(_, mt) => match get(mt.ty).sty {
1901+
ty_rptr(_, mt) => match get(mt.ty).sty {
19101902
ty_vec(_, None) | ty_str => true,
19111903
_ => false,
19121904
},
@@ -2004,8 +1996,7 @@ pub fn type_is_unique(ty: t) -> bool {
20041996

20051997
pub fn type_is_fat_ptr(cx: &ctxt, ty: t) -> bool {
20061998
match get(ty).sty {
2007-
ty_ptr(mt{ty, ..}) | ty_rptr(_, mt{ty, ..})
2008-
| ty_uniq(ty) if !type_is_sized(cx, ty) => true,
1999+
ty_rptr(_, mt{ty, ..}) | ty_uniq(ty) if !type_is_sized(cx, ty) => true,
20092000
_ => false,
20102001
}
20112002
}
@@ -2905,7 +2896,7 @@ pub fn is_type_representable(cx: &ctxt, sp: Span, ty: t) -> Representability {
29052896

29062897
pub fn type_is_trait(ty: t) -> bool {
29072898
match get(ty).sty {
2908-
ty_uniq(ty) | ty_rptr(_, mt { ty, ..}) | ty_ptr(mt { ty, ..}) => match get(ty).sty {
2899+
ty_uniq(ty) | ty_rptr(_, mt { ty, ..}) => match get(ty).sty {
29092900
ty_trait(..) => true,
29102901
_ => false
29112902
},
@@ -3401,12 +3392,8 @@ pub fn adjust_ty(cx: &ctxt,
34013392
})
34023393
}
34033394

3404-
AutoUnsafe(m, ref a) => {
3405-
let adjusted_ty = match a {
3406-
&Some(box ref a) => adjust_for_autoref(cx, span, ty, a),
3407-
&None => ty
3408-
};
3409-
mk_ptr(cx, mt {ty: adjusted_ty, mutbl: m})
3395+
AutoUnsafe(m) => {
3396+
mk_ptr(cx, mt {ty: ty, mutbl: m})
34103397
}
34113398

34123399
AutoUnsize(ref k) => unsize_ty(cx, ty, k, span),
@@ -3457,8 +3444,7 @@ impl AutoRef {
34573444
ty::AutoPtr(r, m, Some(ref a)) => ty::AutoPtr(f(r), m, Some(box a.map_region(f))),
34583445
ty::AutoUnsize(ref k) => ty::AutoUnsize(k.clone()),
34593446
ty::AutoUnsizeUniq(ref k) => ty::AutoUnsizeUniq(k.clone()),
3460-
ty::AutoUnsafe(m, None) => ty::AutoUnsafe(m, None),
3461-
ty::AutoUnsafe(m, Some(ref a)) => ty::AutoUnsafe(m, Some(box a.map_region(f))),
3447+
ty::AutoUnsafe(m) => ty::AutoUnsafe(m),
34623448
}
34633449
}
34643450
}

0 commit comments

Comments
 (0)