Skip to content

Commit 10dab48

Browse files
committed
---
yaml --- r: 190295 b: refs/heads/master c: c62ae87 h: refs/heads/master i: 190293: 7261d40 190291: 8f83aee 190287: 856841b v: v3
1 parent 7f50140 commit 10dab48

Some content is hidden

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

51 files changed

+786
-700
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: 6e92f0580b0bfe8433df73a9139eaa72c47258b2
2+
refs/heads/master: c62ae87db20cf070c5546f5aa814164d2445ec37
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 270a677d4d698916f5ad103f0afc3c070b8dbeb4
55
refs/heads/try: 1c28ab65017d74fc13d003f7c7a73d1a48e5406f

trunk/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,11 @@ then
823823
LLVM_VERSION=$($LLVM_CONFIG --version)
824824

825825
case $LLVM_VERSION in
826-
(3.[2-6]*)
826+
(3.[5-6]*)
827827
msg "found ok version of LLVM: $LLVM_VERSION"
828828
;;
829829
(*)
830-
err "bad LLVM version: $LLVM_VERSION, need >=3.0svn"
830+
err "bad LLVM version: $LLVM_VERSION, need >=3.5"
831831
;;
832832
esac
833833
fi

trunk/mk/main.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
290290
LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
291291
LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
292292
LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
293+
LLVM_LIBDIR_RUSTFLAGS_$(1)=-L "$$(LLVM_LIBDIR_$(1))"
293294
LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
294295
LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
295296
# On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),

trunk/mk/target.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
8484
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \
8585
$$(RUST_LIB_FLAGS_ST$(1)) \
8686
-L "$$(RT_OUTPUT_DIR_$(2))" \
87-
-L "$$(LLVM_LIBDIR_$(2))" \
87+
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
8888
$$(LLVM_STDCPP_RUSTFLAGS_$(2)) \
8989
$$(RUSTFLAGS_$(4)) \
9090
--out-dir $$(@D) \

trunk/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
372372
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(3)) \
373373
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
374374
-L "$$(RT_OUTPUT_DIR_$(2))" \
375-
-L "$$(LLVM_LIBDIR_$(2))" \
375+
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
376376
$$(RUSTFLAGS_$(4))
377377

378378
endef

trunk/src/doc/trpl/closures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ is that a moving closure always takes ownership of all variables that
6868
it uses. Ordinary closures, in contrast, just create a reference into
6969
the enclosing stack frame. Moving closures are most useful with Rust's
7070
concurrency features, and so we'll just leave it at this for
71-
now. We'll talk about them more in the "Threads" section of the guide.
71+
now. We'll talk about them more in the "Concurrency" chapter of the book.
7272

7373
## Accepting closures as arguments
7474

trunk/src/doc/trpl/concurrency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ fn main() {
339339
});
340340
}
341341
342-
rx.recv().ok().expect("Could not recieve answer");
342+
rx.recv().ok().expect("Could not receive answer");
343343
}
344344
```
345345

trunk/src/doc/trpl/method-syntax.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ impl CircleBuilder {
187187
}
188188
189189
fn coordinate(&mut self, coordinate: f64) -> &mut CircleBuilder {
190-
self.coordinate = coordinate;
191-
self
190+
self.coordinate = coordinate;
191+
self
192192
}
193193
194194
fn radius(&mut self, radius: f64) -> &mut CircleBuilder {
195-
self.radius = radius;
196-
self
195+
self.radius = radius;
196+
self
197197
}
198198
199199
fn finalize(&self) -> Circle {

trunk/src/libcollections/btree/node.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,8 @@ impl<K, V> Node<K, V> {
348348
#[inline]
349349
pub fn as_slices<'a>(&'a self) -> (&'a [K], &'a [V]) {
350350
unsafe {(
351-
mem::transmute(raw::Slice {
352-
data: *self.keys as *const K,
353-
len: self.len()
354-
}),
355-
mem::transmute(raw::Slice {
356-
data: *self.vals as *const V,
357-
len: self.len()
358-
})
351+
slice::from_raw_parts(*self.keys, self.len()),
352+
slice::from_raw_parts(*self.vals, self.len()),
359353
)}
360354
}
361355

trunk/src/libcollections/string.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::iter::{IntoIterator, FromIterator};
2424
use core::mem;
2525
use core::ops::{self, Deref, Add, Index};
2626
use core::ptr;
27-
use core::raw::Slice as RawSlice;
27+
use core::slice;
2828
use unicode::str as unicode_str;
2929
use unicode::str::Utf16Item;
3030

@@ -468,11 +468,11 @@ impl String {
468468
unsafe {
469469
// Attempt to not use an intermediate buffer by just pushing bytes
470470
// directly onto this string.
471-
let slice = RawSlice {
472-
data: self.vec.as_ptr().offset(cur_len as isize),
473-
len: 4,
474-
};
475-
let used = ch.encode_utf8(mem::transmute(slice)).unwrap_or(0);
471+
let slice = slice::from_raw_parts_mut (
472+
self.vec.as_mut_ptr().offset(cur_len as isize),
473+
4
474+
);
475+
let used = ch.encode_utf8(slice).unwrap_or(0);
476476
self.vec.set_len(cur_len + used);
477477
}
478478
}

trunk/src/libcollections/vec.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ use core::ops::{Index, IndexMut, Deref, Add};
6464
use core::ops;
6565
use core::ptr;
6666
use core::ptr::Unique;
67-
use core::raw::Slice as RawSlice;
6867
use core::slice;
6968
use core::usize;
7069

@@ -435,10 +434,7 @@ impl<T> Vec<T> {
435434
unsafe {
436435
let ptr = *self.ptr;
437436
assume(!ptr.is_null());
438-
mem::transmute(RawSlice {
439-
data: ptr,
440-
len: self.len,
441-
})
437+
slice::from_raw_parts_mut(ptr, self.len)
442438
}
443439
}
444440

@@ -1560,10 +1556,7 @@ impl<T> AsSlice<T> for Vec<T> {
15601556
unsafe {
15611557
let p = *self.ptr;
15621558
assume(p != 0 as *mut T);
1563-
mem::transmute(RawSlice {
1564-
data: p,
1565-
len: self.len
1566-
})
1559+
slice::from_raw_parts(p, self.len)
15671560
}
15681561
}
15691562
}

trunk/src/libcollections/vec_deque.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use core::num::{Int, UnsignedInt};
2929
use core::num::wrapping::WrappingOps;
3030
use core::ops::{Index, IndexMut};
3131
use core::ptr::{self, Unique};
32-
use core::raw::Slice as RawSlice;
32+
use core::slice;
3333

3434
use core::hash::{Hash, Hasher};
3535
use core::cmp;
@@ -91,13 +91,13 @@ impl<T> VecDeque<T> {
9191
/// Turn ptr into a slice
9292
#[inline]
9393
unsafe fn buffer_as_slice(&self) -> &[T] {
94-
mem::transmute(RawSlice { data: *self.ptr as *const T, len: self.cap })
94+
slice::from_raw_parts(*self.ptr, self.cap)
9595
}
9696

9797
/// Turn ptr into a mut slice
9898
#[inline]
9999
unsafe fn buffer_as_mut_slice(&mut self) -> &mut [T] {
100-
mem::transmute(RawSlice { data: *self.ptr as *const T, len: self.cap })
100+
slice::from_raw_parts_mut(*self.ptr, self.cap)
101101
}
102102

103103
/// Moves an element out of the buffer

trunk/src/libcore/panicking.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ use fmt;
3535
#[cold] #[inline(never)] // this is the slow path, always
3636
#[lang="panic"]
3737
pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! {
38+
// Use Arguments::new_v1 instead of format_args!("{}", expr) to potentially
39+
// reduce size overhead. The format_args! macro uses str's Display trait to
40+
// write expr, which calls Formatter::pad, which must accommodate string
41+
// truncation and padding (even though none is used here). Using
42+
// Arguments::new_v1 may allow the compiler to omit Formatter::pad from the
43+
// output binary, saving up to a few kilobytes.
3844
let (expr, file, line) = *expr_file_line;
39-
panic_fmt(format_args!("{}", expr), &(file, line))
45+
panic_fmt(fmt::Arguments::new_v1(&[expr], &[]), &(file, line))
4046
}
4147

4248
#[cold] #[inline(never)]

trunk/src/libcore/slice.rs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,10 @@ impl<T> ops::Index<ops::Range<usize>> for [T] {
520520
assert!(index.start <= index.end);
521521
assert!(index.end <= self.len());
522522
unsafe {
523-
transmute(RawSlice {
524-
data: self.as_ptr().offset(index.start as isize),
525-
len: index.end - index.start
526-
})
523+
from_raw_parts (
524+
self.as_ptr().offset(index.start as isize),
525+
index.end - index.start
526+
)
527527
}
528528
}
529529
}
@@ -559,10 +559,10 @@ impl<T> ops::IndexMut<ops::Range<usize>> for [T] {
559559
assert!(index.start <= index.end);
560560
assert!(index.end <= self.len());
561561
unsafe {
562-
transmute(RawSlice {
563-
data: self.as_ptr().offset(index.start as isize),
564-
len: index.end - index.start
565-
})
562+
from_raw_parts_mut(
563+
self.as_mut_ptr().offset(index.start as isize),
564+
index.end - index.start
565+
)
566566
}
567567
}
568568
}
@@ -731,7 +731,21 @@ macro_rules! make_slice {
731731
diff / mem::size_of::<$t>()
732732
};
733733
unsafe {
734-
transmute::<_, $result>(RawSlice { data: $start, len: len })
734+
from_raw_parts($start, len)
735+
}
736+
}}
737+
}
738+
739+
macro_rules! make_mut_slice {
740+
($t: ty => $result: ty: $start: expr, $end: expr) => {{
741+
let diff = $end as usize - $start as usize;
742+
let len = if mem::size_of::<T>() == 0 {
743+
diff
744+
} else {
745+
diff / mem::size_of::<$t>()
746+
};
747+
unsafe {
748+
from_raw_parts_mut($start, len)
735749
}
736750
}}
737751
}
@@ -898,7 +912,7 @@ impl<'a, T> ops::IndexMut<ops::RangeFrom<usize>> for IterMut<'a, T> {
898912
impl<'a, T> ops::IndexMut<RangeFull> for IterMut<'a, T> {
899913
#[inline]
900914
fn index_mut(&mut self, _index: &RangeFull) -> &mut [T] {
901-
make_slice!(T => &mut [T]: self.ptr, self.end)
915+
make_mut_slice!(T => &mut [T]: self.ptr, self.end)
902916
}
903917
}
904918

@@ -912,7 +926,7 @@ impl<'a, T> IterMut<'a, T> {
912926
/// restricted lifetimes that do not consume the iterator.
913927
#[unstable(feature = "core")]
914928
pub fn into_slice(self) -> &'a mut [T] {
915-
make_slice!(T => &'a mut [T]: self.ptr, self.end)
929+
make_mut_slice!(T => &'a mut [T]: self.ptr, self.end)
916930
}
917931
}
918932

@@ -1404,16 +1418,15 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {}
14041418
#[unstable(feature = "core")]
14051419
pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
14061420
unsafe {
1407-
transmute(RawSlice { data: s, len: 1 })
1421+
from_raw_parts(s, 1)
14081422
}
14091423
}
14101424

14111425
/// Converts a pointer to A into a slice of length 1 (without copying).
14121426
#[unstable(feature = "core")]
14131427
pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
14141428
unsafe {
1415-
let ptr: *const A = transmute(s);
1416-
transmute(RawSlice { data: ptr, len: 1 })
1429+
from_raw_parts_mut(s, 1)
14171430
}
14181431
}
14191432

trunk/src/librustc/middle/check_match.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ fn is_useful(cx: &MatchCheckCtxt,
646646
if rows[0].len() == 0 {
647647
return NotUseful;
648648
}
649+
assert!(rows.iter().all(|r| r.len() == v.len()));
649650
let real_pat = match rows.iter().find(|r| (*r)[0].id != DUMMY_NODE_ID) {
650651
Some(r) => raw_pat(r[0]),
651652
None if v.len() == 0 => return NotUseful,
@@ -654,7 +655,12 @@ fn is_useful(cx: &MatchCheckCtxt,
654655
let left_ty = if real_pat.id == DUMMY_NODE_ID {
655656
ty::mk_nil(cx.tcx)
656657
} else {
657-
ty::pat_ty(cx.tcx, &*real_pat)
658+
let left_ty = ty::pat_ty(cx.tcx, &*real_pat);
659+
660+
match real_pat.node {
661+
ast::PatIdent(ast::BindByRef(..), _, _) => ty::deref(left_ty, false).unwrap().ty,
662+
_ => left_ty,
663+
}
658664
};
659665

660666
let max_slice_length = rows.iter().filter_map(|row| match row[0].node {

trunk/src/librustc/middle/dead.rs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct MarkSymbolVisitor<'a, 'tcx: 'a> {
4747
struct_has_extern_repr: bool,
4848
ignore_non_const_paths: bool,
4949
inherited_pub_visibility: bool,
50-
ignore_variant_stack: Vec<ast::NodeId>,
5150
}
5251

5352
impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
@@ -60,7 +59,6 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
6059
struct_has_extern_repr: false,
6160
ignore_non_const_paths: false,
6261
inherited_pub_visibility: false,
63-
ignore_variant_stack: vec![],
6462
}
6563
}
6664

@@ -81,9 +79,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
8179
def::DefPrimTy(_) => (),
8280
def::DefVariant(enum_id, variant_id, _) => {
8381
self.check_def_id(enum_id);
84-
if !self.ignore_variant_stack.contains(&variant_id.node) {
85-
self.check_def_id(variant_id);
86-
}
82+
self.check_def_id(variant_id);
8783
}
8884
_ => {
8985
self.check_def_id(def.def_id());
@@ -282,23 +278,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
282278
visit::walk_expr(self, expr);
283279
}
284280

285-
fn visit_arm(&mut self, arm: &ast::Arm) {
286-
if arm.pats.len() == 1 {
287-
let pat = &*arm.pats[0];
288-
let variants = pat_util::necessary_variants(&self.tcx.def_map, pat);
289-
290-
// Inside the body, ignore constructions of variants
291-
// necessary for the pattern to match. Those construction sites
292-
// can't be reached unless the variant is constructed elsewhere.
293-
let len = self.ignore_variant_stack.len();
294-
self.ignore_variant_stack.push_all(&*variants);
295-
visit::walk_arm(self, arm);
296-
self.ignore_variant_stack.truncate(len);
297-
} else {
298-
visit::walk_arm(self, arm);
299-
}
300-
}
301-
302281
fn visit_pat(&mut self, pat: &ast::Pat) {
303282
let def_map = &self.tcx.def_map;
304283
match pat.node {
@@ -418,11 +397,6 @@ fn create_and_seed_worklist(tcx: &ty::ctxt,
418397
worklist.push(*id);
419398
}
420399
for id in reachable_symbols {
421-
// Reachable variants can be dead, because we warn about
422-
// variants never constructed, not variants never used.
423-
if let Some(ast_map::NodeVariant(..)) = tcx.map.find(*id) {
424-
continue;
425-
}
426400
worklist.push(*id);
427401
}
428402

0 commit comments

Comments
 (0)