Skip to content

Commit 78858a4

Browse files
committed
---
yaml --- r: 212847 b: refs/heads/master c: 33b7386 h: refs/heads/master i: 212845: fb1b58a 212843: dcc82f7 212839: 9cb1015 212831: ebba880 v: v3
1 parent 5338975 commit 78858a4

Some content is hidden

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

77 files changed

+11859
-173
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: a9f1e29c4ef68d09f3a926462e4be946d0749042
2+
refs/heads/master: 33b7386d3949e0a372e386f7a4593b12d5fa542a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
55
refs/heads/try: 1864973ae17213c5a58c4dd3f9af6d1b6c7d2e05

trunk/src/doc/trpl/patterns.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -221,27 +221,12 @@ struct Point {
221221
let origin = Point { x: 0, y: 0 };
222222

223223
match origin {
224-
Point { x, y } => println!("({},{})", x, y),
224+
Point { x: x, y: y } => println!("({},{})", x, y),
225225
}
226226
```
227227

228228
[struct]: structs.html
229229

230-
We can use `:` to give a value a different name.
231-
232-
```rust
233-
struct Point {
234-
x: i32,
235-
y: i32,
236-
}
237-
238-
let origin = Point { x: 0, y: 0 };
239-
240-
match origin {
241-
Point { x: x1, y: y1 } => println!("({},{})", x1, y1),
242-
}
243-
```
244-
245230
If we only care about some of the values, we don’t have to give them all names:
246231

247232
```rust
@@ -253,7 +238,7 @@ struct Point {
253238
let origin = Point { x: 0, y: 0 };
254239

255240
match origin {
256-
Point { x, .. } => println!("x is {}", x),
241+
Point { x: x, .. } => println!("x is {}", x),
257242
}
258243
```
259244

@@ -270,7 +255,7 @@ struct Point {
270255
let origin = Point { x: 0, y: 0 };
271256

272257
match origin {
273-
Point { y, .. } => println!("y is {}", y),
258+
Point { y: y, .. } => println!("y is {}", y),
274259
}
275260
```
276261

trunk/src/doc/trpl/traits.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
% Traits
22

3-
A trait is a language feature that tells the Rust compiler about
4-
functionality a type must provide.
5-
63
Do you remember the `impl` keyword, used to call a function with [method
74
syntax][methodsyntax]?
85

trunk/src/liballoc/arc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ impl<T: ?Sized> Deref for Arc<T> {
330330
}
331331
}
332332

333+
#[stable(feature = "rc_arc_as_ref", since = "1.2.0")]
334+
impl<T: ?Sized> AsRef<T> for Arc<T> {
335+
336+
#[inline]
337+
fn as_ref(&self) -> &T {
338+
&self.inner().data
339+
}
340+
}
341+
333342
impl<T: Clone> Arc<T> {
334343
/// Make a mutable reference from the given `Arc<T>`.
335344
///

trunk/src/liballoc/rc.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ use std::boxed;
156156
use core::cell::Cell;
157157
use core::clone::Clone;
158158
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
159+
use core::convert::AsRef;
159160
use core::default::Default;
160161
use core::fmt;
161162
use core::hash::{Hasher, Hash};
@@ -379,6 +380,15 @@ impl<T: ?Sized> Deref for Rc<T> {
379380
}
380381
}
381382

383+
#[stable(feature = "rc_arc_as_ref", since = "1.2.0")]
384+
impl<T: ?Sized> AsRef<T> for Rc<T> {
385+
386+
#[inline(always)]
387+
fn as_ref(&self) -> &T {
388+
&self.inner().value
389+
}
390+
}
391+
382392
#[stable(feature = "rust1", since = "1.0.0")]
383393
impl<T: ?Sized> Drop for Rc<T> {
384394
/// Drops the `Rc<T>`.

trunk/src/librustc/metadata/tyencode.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Encoder, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx>) {
113113
ty::TyArray(t, sz) => {
114114
mywrite!(w, "V");
115115
enc_ty(w, cx, t);
116-
mywrite!(w, "/");
117-
match sz {
118-
Some(n) => mywrite!(w, "{}|", n),
119-
None => mywrite!(w, "|"),
120-
}
116+
mywrite!(w, "/{}|", sz);
117+
}
118+
ty::TySlice(t) => {
119+
mywrite!(w, "V");
120+
enc_ty(w, cx, t);
121+
mywrite!(w, "/|");
121122
}
122123
ty::TyStr => {
123124
mywrite!(w, "v");

trunk/src/librustc/middle/check_const.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
423423
self.visit_expr(&**element);
424424
// The count is checked elsewhere (typeck).
425425
let count = match node_ty.sty {
426-
ty::TyArray(_, Some(n)) => n,
426+
ty::TyArray(_, n) => n,
427427
_ => unreachable!()
428428
};
429429
// [element; 0] is always zero-sized.
@@ -851,10 +851,14 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'tcx> {
851851
}
852852
let mutbl = bk.to_mutbl_lossy();
853853
if mutbl == ast::MutMutable && self.mode == Mode::StaticMut {
854-
// Mutable slices are the only `&mut` allowed in globals,
855-
// but only in `static mut`, nowhere else.
854+
// Mutable slices are the only `&mut` allowed in
855+
// globals, but only in `static mut`, nowhere else.
856+
// FIXME: This exception is really weird... there isn't
857+
// any fundamental reason to restrict this based on
858+
// type of the expression. `&mut [1]` has exactly the
859+
// same representation as &mut 1.
856860
match cmt.ty.sty {
857-
ty::TyArray(_, _) => break,
861+
ty::TyArray(_, _) | ty::TySlice(_) => break,
858862
_ => {}
859863
}
860864
}

trunk/src/librustc/middle/check_match.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,14 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
537537

538538
ty::TyRef(_, ty::mt { ty, mutbl }) => {
539539
match ty.sty {
540-
ty::TyArray(_, Some(n)) => match ctor {
540+
ty::TyArray(_, n) => match ctor {
541541
&Single => {
542542
assert_eq!(pats_len, n);
543543
ast::PatVec(pats.collect(), None, vec!())
544544
},
545545
_ => unreachable!()
546546
},
547-
ty::TyArray(_, None) => match ctor {
547+
ty::TySlice(_) => match ctor {
548548
&Slice(n) => {
549549
assert_eq!(pats_len, n);
550550
ast::PatVec(pats.collect(), None, vec!())
@@ -560,7 +560,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
560560
}
561561
}
562562

563-
ty::TyArray(_, Some(len)) => {
563+
ty::TyArray(_, len) => {
564564
assert_eq!(pats_len, len);
565565
ast::PatVec(pats.collect(), None, vec![])
566566
}
@@ -601,7 +601,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
601601
[true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
602602

603603
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
604-
ty::TyArray(_, None) =>
604+
ty::TySlice(_) =>
605605
range_inclusive(0, max_slice_length).map(|length| Slice(length)).collect(),
606606
_ => vec!(Single)
607607
},
@@ -779,7 +779,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
779779
vec!(ConstantRange(eval_const_expr(cx.tcx, &**lo), eval_const_expr(cx.tcx, &**hi))),
780780
ast::PatVec(ref before, ref slice, ref after) =>
781781
match left_ty.sty {
782-
ty::TyArray(_, Some(_)) => vec!(Single),
782+
ty::TyArray(_, _) => vec!(Single),
783783
_ => if slice.is_some() {
784784
range_inclusive(before.len() + after.len(), max_slice_length)
785785
.map(|length| Slice(length))
@@ -807,7 +807,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
807807
ty::TyTuple(ref fs) => fs.len(),
808808
ty::TyBox(_) => 1,
809809
ty::TyRef(_, ty::mt { ty, .. }) => match ty.sty {
810-
ty::TyArray(_, None) => match *ctor {
810+
ty::TySlice(_) => match *ctor {
811811
Slice(length) => length,
812812
ConstantValue(_) => 0,
813813
_ => unreachable!()
@@ -822,7 +822,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
822822
}
823823
}
824824
ty::TyStruct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
825-
ty::TyArray(_, Some(n)) => n,
825+
ty::TyArray(_, n) => n,
826826
_ => 0
827827
}
828828
}

trunk/src/librustc/middle/fast_reject.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn simplify_type(tcx: &ty::ctxt,
5555
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
5656
ty::TyEnum(def_id, _) => Some(EnumSimplifiedType(def_id)),
5757
ty::TyStr => Some(StrSimplifiedType),
58-
ty::TyArray(..) => Some(VecSimplifiedType),
58+
ty::TyArray(..) | ty::TySlice(_) => Some(VecSimplifiedType),
5959
ty::TyRawPtr(_) => Some(PtrSimplifiedType),
6060
ty::TyTrait(ref trait_info) => {
6161
Some(TraitSimplifiedType(trait_info.principal_def_id()))

trunk/src/librustc/middle/implicator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
117117
}
118118

119119
ty::TyArray(t, _) |
120+
ty::TySlice(t) |
120121
ty::TyRawPtr(ty::mt { ty: t, .. }) |
121122
ty::TyBox(t) => {
122123
self.accumulate_from_ty(t)

trunk/src/librustc/middle/infer/freshen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
159159
ty::TyStr |
160160
ty::TyError |
161161
ty::TyArray(..) |
162+
ty::TySlice(..) |
162163
ty::TyRawPtr(..) |
163164
ty::TyRef(..) |
164165
ty::TyBareFn(..) |

trunk/src/librustc/middle/mem_categorization.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fn deref_kind(t: Ty, context: DerefKindContext) -> McResult<deref_kind> {
230230
Ok(deref_interior(InteriorField(PositionalField(0))))
231231
}
232232

233-
ty::TyArray(_, _) | ty::TyStr => {
233+
ty::TyArray(_, _) | ty::TySlice(_) | ty::TyStr => {
234234
// no deref of indexed content without supplying InteriorOffsetKind
235235
if let Some(context) = context {
236236
Ok(deref_interior(InteriorElement(context, element_kind(t))))
@@ -843,7 +843,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
843843
// Only promote `[T; 0]` before an RFC for rvalue promotions
844844
// is accepted.
845845
let qualif = match expr_ty.sty {
846-
ty::TyArray(_, Some(0)) => qualif,
846+
ty::TyArray(_, 0) => qualif,
847847
_ => check_const::ConstQualif::NOT_CONST
848848
};
849849

@@ -1130,7 +1130,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
11301130
-> (ast::Mutability, ty::Region) {
11311131
match slice_ty.sty {
11321132
ty::TyRef(r, ref mt) => match mt.ty.sty {
1133-
ty::TyArray(_, None) => (mt.mutbl, *r),
1133+
ty::TySlice(_) => (mt.mutbl, *r),
11341134
_ => vec_slice_info(tcx, pat, mt.ty),
11351135
},
11361136

@@ -1669,10 +1669,10 @@ fn element_kind(t: Ty) -> ElementKind {
16691669
match t.sty {
16701670
ty::TyRef(_, ty::mt{ty, ..}) |
16711671
ty::TyBox(ty) => match ty.sty {
1672-
ty::TyArray(_, None) => VecElement,
1672+
ty::TySlice(_) => VecElement,
16731673
_ => OtherElement
16741674
},
1675-
ty::TyArray(..) => VecElement,
1675+
ty::TyArray(..) | ty::TySlice(_) => VecElement,
16761676
_ => OtherElement
16771677
}
16781678
}

trunk/src/librustc/middle/traits/coherence.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>,
306306
ty::TyStr(..) |
307307
ty::TyBareFn(..) |
308308
ty::TyArray(..) |
309+
ty::TySlice(..) |
309310
ty::TyRawPtr(..) |
310311
ty::TyRef(..) |
311312
ty::TyTuple(..) |

trunk/src/librustc/middle/traits/select.rs

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
14291429
}
14301430

14311431
// [T; n] -> [T].
1432-
(&ty::TyArray(_, Some(_)), &ty::TyArray(_, None)) => true,
1432+
(&ty::TyArray(_, _), &ty::TySlice(_)) => true,
14331433

14341434
// Struct<T> -> Struct<U>.
14351435
(&ty::TyStruct(def_id_a, _), &ty::TyStruct(def_id_b, _)) => {
@@ -1662,35 +1662,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16621662
}
16631663
}
16641664

1665-
ty::TyArray(element_ty, ref len) => {
1666-
// [T; n] and [T]
1665+
ty::TyArray(element_ty, _) => {
1666+
// [T; n]
16671667
match bound {
1668-
ty::BoundCopy => {
1669-
match *len {
1670-
// [T; n] is copy iff T is copy
1671-
Some(_) => ok_if(vec![element_ty]),
1672-
1673-
// [T] is unsized and hence affine
1674-
None => Err(Unimplemented),
1675-
}
1676-
}
1677-
1678-
ty::BoundSized => {
1679-
if len.is_some() {
1680-
ok_if(Vec::new())
1681-
} else {
1682-
Err(Unimplemented)
1683-
}
1684-
}
1685-
1668+
ty::BoundCopy => ok_if(vec![element_ty]),
1669+
ty::BoundSized => ok_if(Vec::new()),
16861670
ty::BoundSync | ty::BoundSend => {
16871671
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
16881672
}
16891673
}
16901674
}
16911675

1692-
ty::TyStr => {
1693-
// Equivalent to [u8]
1676+
ty::TyStr | ty::TySlice(_) => {
16941677
match bound {
16951678
ty::BoundSync | ty::BoundSend => {
16961679
self.tcx().sess.bug("Send/Sync shouldn't occur in builtin_bounds()");
@@ -1855,7 +1838,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
18551838
Some(vec![element_ty])
18561839
},
18571840

1858-
ty::TyArray(element_ty, _) => {
1841+
ty::TyArray(element_ty, _) | ty::TySlice(element_ty) => {
18591842
Some(vec![element_ty])
18601843
}
18611844

@@ -2510,7 +2493,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
25102493
}
25112494

25122495
// [T; n] -> [T].
2513-
(&ty::TyArray(a, Some(_)), &ty::TyArray(b, None)) => {
2496+
(&ty::TyArray(a, _), &ty::TySlice(b)) => {
25142497
let origin = infer::Misc(obligation.cause.span);
25152498
if self.infcx.sub_types(false, origin, a, b).is_err() {
25162499
return Err(Unimplemented);

0 commit comments

Comments
 (0)