Skip to content

Commit 3aa51ed

Browse files
committed
---
yaml --- r: 272805 b: refs/heads/beta c: 25e5de3 h: refs/heads/master i: 272803: 490dcdb
1 parent 799d7e8 commit 3aa51ed

File tree

20 files changed

+118
-249
lines changed

20 files changed

+118
-249
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: da0ccd8cc98b5a4f2edcaf1e4f67738f720bc86b
26+
refs/heads/beta: 25e5de3f7ea6f81599b567c3a14e762e4e90cd7a
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/bootstrap/build/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn check(build: &mut Build) {
7979
}
8080

8181
// Make sure musl-root is valid if specified
82-
if target.contains("musl") && target.contains("x86_64") {
82+
if target.contains("musl") {
8383
match build.config.musl_root {
8484
Some(ref root) => {
8585
if fs::metadata(root.join("lib/libc.a")).is_err() {

branches/beta/src/doc/book/vectors.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,36 +115,6 @@ for i in v {
115115
}
116116
```
117117

118-
Note: You cannot use the vector again once you have iterated by taking ownership of the vector.
119-
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
120-
For example, the following code does not compile.
121-
122-
```rust,ignore
123-
let mut v = vec![1, 2, 3, 4, 5];
124-
125-
for i in v {
126-
println!("Take ownership of the vector and its element {}", i);
127-
}
128-
129-
for i in v {
130-
println!("Take ownership of the vector and its element {}", i);
131-
}
132-
```
133-
134-
Whereas the following works perfectly,
135-
136-
```rust
137-
let mut v = vec![1, 2, 3, 4, 5];
138-
139-
for i in &v {
140-
println!("This is a reference to {}", i);
141-
}
142-
143-
for i in &v {
144-
println!("This is a reference to {}", i);
145-
}
146-
```
147-
148118
Vectors have many more useful methods, which you can read about in [their
149119
API documentation][vec].
150120

branches/beta/src/libcore/iter.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ pub trait Iterator {
15321532
/// An iterator adaptor that applies a function, producing a single, final value.
15331533
///
15341534
/// `fold()` takes two arguments: an initial value, and a closure with two
1535-
/// arguments: an 'accumulator', and an element. The closure returns the value that
1535+
/// arguments: an 'accumulator', and an element. It returns the value that
15361536
/// the accumulator should have for the next iteration.
15371537
///
15381538
/// The initial value is the value the accumulator will have on the first
@@ -3851,6 +3851,17 @@ impl<I> Iterator for Skip<I> where I: Iterator {
38513851
#[stable(feature = "rust1", since = "1.0.0")]
38523852
impl<I> ExactSizeIterator for Skip<I> where I: ExactSizeIterator {}
38533853

3854+
#[stable(feature = "double_ended_skip_iterator", since = "1.8.0")]
3855+
impl<I> DoubleEndedIterator for Skip<I> where I: DoubleEndedIterator + ExactSizeIterator {
3856+
fn next_back(&mut self) -> Option<Self::Item> {
3857+
if self.len() > 0 {
3858+
self.iter.next_back()
3859+
} else {
3860+
None
3861+
}
3862+
}
3863+
}
3864+
38543865
/// An iterator that only iterates over the first `n` iterations of `iter`.
38553866
///
38563867
/// This `struct` is created by the [`take()`] method on [`Iterator`]. See its

branches/beta/src/libcore/str/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,8 @@ fn eq_slice(a: &str, b: &str) -> bool {
10951095
/// faster than comparing each byte in a loop.
10961096
#[inline]
10971097
unsafe fn cmp_slice(a: &str, b: &str, len: usize) -> i32 {
1098+
// NOTE: In theory n should be libc::size_t and not usize, but libc is not available here
1099+
#[allow(improper_ctypes)]
10981100
extern { fn memcmp(s1: *const i8, s2: *const i8, n: usize) -> i32; }
10991101
memcmp(a.as_ptr() as *const i8, b.as_ptr() as *const i8, len)
11001102
}

branches/beta/src/libcoretest/iter.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,44 @@ fn test_iterator_skip() {
303303
assert_eq!(it.len(), 0);
304304
}
305305

306+
#[test]
307+
fn test_iterator_skip_doubleended() {
308+
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
309+
let mut it = xs.iter().rev().skip(5);
310+
assert_eq!(it.next(), Some(&15));
311+
assert_eq!(it.by_ref().rev().next(), Some(&0));
312+
assert_eq!(it.next(), Some(&13));
313+
assert_eq!(it.by_ref().rev().next(), Some(&1));
314+
assert_eq!(it.next(), Some(&5));
315+
assert_eq!(it.by_ref().rev().next(), Some(&2));
316+
assert_eq!(it.next(), Some(&3));
317+
assert_eq!(it.next(), None);
318+
let mut it = xs.iter().rev().skip(5).rev();
319+
assert_eq!(it.next(), Some(&0));
320+
assert_eq!(it.rev().next(), Some(&15));
321+
let mut it_base = xs.iter();
322+
{
323+
let mut it = it_base.by_ref().skip(5).rev();
324+
assert_eq!(it.next(), Some(&30));
325+
assert_eq!(it.next(), Some(&20));
326+
assert_eq!(it.next(), Some(&19));
327+
assert_eq!(it.next(), Some(&17));
328+
assert_eq!(it.next(), Some(&16));
329+
assert_eq!(it.next(), Some(&15));
330+
assert_eq!(it.next(), Some(&13));
331+
assert_eq!(it.next(), None);
332+
}
333+
// make sure the skipped parts have not been consumed
334+
assert_eq!(it_base.next(), Some(&0));
335+
assert_eq!(it_base.next(), Some(&1));
336+
assert_eq!(it_base.next(), Some(&2));
337+
assert_eq!(it_base.next(), Some(&3));
338+
assert_eq!(it_base.next(), Some(&5));
339+
assert_eq!(it_base.next(), None);
340+
let it = xs.iter().skip(5).rev();
341+
assert_eq!(it.last(), Some(&13));
342+
}
343+
306344
#[test]
307345
fn test_iterator_skip_nth() {
308346
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];

branches/beta/src/librustc_trans/trans/consts.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,13 @@ pub fn addr_of(ccx: &CrateContext,
161161
gv
162162
}
163163

164-
/// Deref a constant pointer
165-
fn load_const(cx: &CrateContext, v: ValueRef, t: Ty) -> ValueRef {
164+
fn const_deref_ptr(cx: &CrateContext, v: ValueRef) -> ValueRef {
166165
let v = match cx.const_unsized().borrow().get(&v) {
167166
Some(&v) => v,
168167
None => v
169168
};
170-
let d = unsafe { llvm::LLVMGetInitializer(v) };
171-
if t.is_bool() {
172-
unsafe { llvm::LLVMConstTrunc(d, Type::i1(cx).to_ref()) }
173-
} else {
174-
d
169+
unsafe {
170+
llvm::LLVMGetInitializer(v)
175171
}
176172
}
177173

@@ -182,7 +178,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
182178
match ty.builtin_deref(true, ty::NoPreference) {
183179
Some(mt) => {
184180
if type_is_sized(cx.tcx(), mt.ty) {
185-
(load_const(cx, v, mt.ty), mt.ty)
181+
(const_deref_ptr(cx, v), mt.ty)
186182
} else {
187183
// Derefing a fat pointer does not change the representation,
188184
// just the type to the unsized contents.
@@ -592,10 +588,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
592588
let is_float = ty.is_fp();
593589
let signed = ty.is_signed();
594590

595-
let (te2, ty2) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst));
596-
debug!("const_expr_unadjusted: te2={}, ty={:?}",
597-
cx.tn().val_to_string(te2),
598-
ty2);
591+
let (te2, _) = try!(const_expr(cx, &e2, param_substs, fn_args, trueconst));
599592

600593
try!(check_binary_expr_validity(cx, e, ty, te1, te2, trueconst));
601594

@@ -678,13 +671,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
678671
};
679672
let (arr, len) = match bt.sty {
680673
ty::TyArray(_, u) => (bv, C_uint(cx, u)),
681-
ty::TySlice(..) | ty::TyStr => {
674+
ty::TySlice(_) | ty::TyStr => {
682675
let e1 = const_get_elt(cx, bv, &[0]);
683-
(load_const(cx, e1, bt), const_get_elt(cx, bv, &[1]))
676+
(const_deref_ptr(cx, e1), const_get_elt(cx, bv, &[1]))
684677
},
685678
ty::TyRef(_, mt) => match mt.ty.sty {
686679
ty::TyArray(_, u) => {
687-
(load_const(cx, bv, mt.ty), C_uint(cx, u))
680+
(const_deref_ptr(cx, bv), C_uint(cx, u))
688681
},
689682
_ => cx.sess().span_bug(base.span,
690683
&format!("index-expr base must be a vector \
@@ -898,8 +891,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
898891
expr::trans_def_fn_unadjusted(cx, e, def, param_substs).val
899892
}
900893
Def::Const(def_id) | Def::AssociatedConst(def_id) => {
901-
load_const(cx, try!(get_const_val(cx, def_id, e, param_substs)),
902-
ety)
894+
const_deref_ptr(cx, try!(get_const_val(cx, def_id, e, param_substs)))
903895
}
904896
Def::Variant(enum_did, variant_did) => {
905897
let vinfo = cx.tcx().lookup_adt_def(enum_did).variant_with_id(variant_did);

branches/beta/src/librustc_typeck/check/_match.rs

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
203203
check_pat_enum(pcx, pat, path, subpats.as_ref().map(|v| &v[..]), expected, true);
204204
}
205205
PatKind::Path(ref path) => {
206-
check_pat_enum(pcx, pat, path, Some(&[]), expected, false);
206+
check_pat_enum(pcx, pat, path, None, expected, false);
207207
}
208208
PatKind::QPath(ref qself, ref path) => {
209209
let self_ty = fcx.to_ty(&qself.ty);
@@ -597,12 +597,12 @@ fn bad_struct_kind_err(sess: &Session, pat: &hir::Pat, path: &hir::Path, lint: b
597597
}
598598
}
599599

600-
fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
601-
pat: &hir::Pat,
602-
path: &hir::Path,
603-
subpats: Option<&'tcx [P<hir::Pat>]>,
604-
expected: Ty<'tcx>,
605-
is_tuple_struct_pat: bool)
600+
pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
601+
pat: &hir::Pat,
602+
path: &hir::Path,
603+
subpats: Option<&'tcx [P<hir::Pat>]>,
604+
expected: Ty<'tcx>,
605+
is_tuple_struct_pat: bool)
606606
{
607607
// Typecheck the path.
608608
let fcx = pcx.fcx;
@@ -685,41 +685,59 @@ fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
685685
demand::eqtype(fcx, pat.span, expected, pat_ty);
686686

687687
let real_path_ty = fcx.node_ty(pat.id);
688-
let (kind_name, variant, expected_substs) = match real_path_ty.sty {
688+
let (arg_tys, kind_name): (Vec<_>, &'static str) = match real_path_ty.sty {
689689
ty::TyEnum(enum_def, expected_substs) => {
690690
let variant = enum_def.variant_of_def(def);
691-
("variant", variant, expected_substs)
691+
if variant.kind() == ty::VariantKind::Struct {
692+
report_bad_struct_kind(false);
693+
return;
694+
}
695+
if is_tuple_struct_pat && variant.kind() != ty::VariantKind::Tuple {
696+
// Matching unit variants with tuple variant patterns (`UnitVariant(..)`)
697+
// is allowed for backward compatibility.
698+
let is_special_case = variant.kind() == ty::VariantKind::Unit;
699+
report_bad_struct_kind(is_special_case);
700+
if !is_special_case {
701+
return
702+
}
703+
}
704+
(variant.fields
705+
.iter()
706+
.map(|f| fcx.instantiate_type_scheme(pat.span,
707+
expected_substs,
708+
&f.unsubst_ty()))
709+
.collect(),
710+
"variant")
692711
}
693712
ty::TyStruct(struct_def, expected_substs) => {
694713
let variant = struct_def.struct_variant();
695-
("struct", variant, expected_substs)
714+
if is_tuple_struct_pat && variant.kind() != ty::VariantKind::Tuple {
715+
// Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
716+
// is allowed for backward compatibility.
717+
let is_special_case = variant.kind() == ty::VariantKind::Unit;
718+
report_bad_struct_kind(is_special_case);
719+
return;
720+
}
721+
(variant.fields
722+
.iter()
723+
.map(|f| fcx.instantiate_type_scheme(pat.span,
724+
expected_substs,
725+
&f.unsubst_ty()))
726+
.collect(),
727+
"struct")
696728
}
697729
_ => {
698730
report_bad_struct_kind(false);
699731
return;
700732
}
701733
};
702734

703-
match (is_tuple_struct_pat, variant.kind()) {
704-
(true, ty::VariantKind::Unit) => {
705-
// Matching unit structs with tuple variant patterns (`UnitVariant(..)`)
706-
// is allowed for backward compatibility.
707-
report_bad_struct_kind(true);
708-
}
709-
(_, ty::VariantKind::Struct) => {
710-
report_bad_struct_kind(false);
711-
return
712-
}
713-
_ => {}
714-
}
715-
716735
if let Some(subpats) = subpats {
717-
if subpats.len() == variant.fields.len() {
718-
for (subpat, field) in subpats.iter().zip(&variant.fields) {
719-
let field_ty = fcx.field_ty(subpat.span, field, expected_substs);
720-
check_pat(pcx, &subpat, field_ty);
736+
if subpats.len() == arg_tys.len() {
737+
for (subpat, arg_ty) in subpats.iter().zip(arg_tys) {
738+
check_pat(pcx, &subpat, arg_ty);
721739
}
722-
} else if variant.fields.is_empty() {
740+
} else if arg_tys.is_empty() {
723741
span_err!(tcx.sess, pat.span, E0024,
724742
"this pattern has {} field{}, but the corresponding {} has no fields",
725743
subpats.len(), if subpats.len() == 1 {""} else {"s"}, kind_name);
@@ -732,7 +750,7 @@ fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
732750
"this pattern has {} field{}, but the corresponding {} has {} field{}",
733751
subpats.len(), if subpats.len() == 1 {""} else {"s"},
734752
kind_name,
735-
variant.fields.len(), if variant.fields.len() == 1 {""} else {"s"});
753+
arg_tys.len(), if arg_tys.len() == 1 {""} else {"s"});
736754

737755
for pat in subpats {
738756
check_pat(pcx, &pat, tcx.types.err);

branches/beta/src/librustdoc/html/static/rustdoc.css

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -616,19 +616,15 @@ a.test-arrow {
616616
}
617617

618618
.sidebar .location {
619-
float: right;
619+
float: left;
620620
margin: 0px;
621-
padding: 3px 10px 1px 10px;
622-
min-height: 39px;
621+
padding: 5px;
622+
width: 60%;
623623
background: inherit;
624624
text-align: left;
625625
font-size: 24px;
626626
}
627627

628-
.sidebar .location:empty {
629-
padding: 0;
630-
}
631-
632628
.sidebar img {
633629
width: 35px;
634630
margin-top: 5px;

branches/beta/src/libstd/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
}
2929

3030
if target.contains("unknown-linux") {
31-
if target.contains("musl") && target.contains("x86_64") {
31+
if target.contains("musl") {
3232
println!("cargo:rustc-link-lib=static=unwind");
3333
} else {
3434
println!("cargo:rustc-link-lib=dl");

branches/beta/src/libsyntax/ext/base.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,6 @@ pub struct ExtCtxt<'a> {
552552

553553
pub syntax_env: SyntaxEnv,
554554
pub recursion_count: usize,
555-
556-
pub filename: Option<String>,
557-
pub mod_path_stack: Vec<InternedString>,
558-
pub in_block: bool,
559555
}
560556

561557
impl<'a> ExtCtxt<'a> {
@@ -574,10 +570,6 @@ impl<'a> ExtCtxt<'a> {
574570
exported_macros: Vec::new(),
575571
syntax_env: env,
576572
recursion_count: 0,
577-
578-
filename: None,
579-
mod_path_stack: Vec::new(),
580-
in_block: false,
581573
}
582574
}
583575

0 commit comments

Comments
 (0)