Skip to content

Commit a8a486f

Browse files
committed
---
yaml --- r: 234705 b: refs/heads/tmp c: 9526813 h: refs/heads/master i: 234703: a42f4c5 v: v3
1 parent b695aa1 commit a8a486f

Some content is hidden

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

48 files changed

+292
-375
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 0b5b029da1eb37b0478ce45587db7dc8f66b39b7
28+
refs/heads/tmp: 9526813f5bc088261201934d7d6e574231eb252e
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version 1.3.0 (2015-09-17)
1+
Version 1.3.0 (September 2015)
22
==============================
33

44
* ~900 changes, numerous bugfixes

branches/tmp/configure

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,12 +1095,6 @@ envopt CPP
10951095
envopt CFLAGS
10961096
envopt CXXFLAGS
10971097

1098-
# stdc++ name in use
1099-
# used to manage non-standard name (on OpenBSD for example)
1100-
program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p")
1101-
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
1102-
putvar CFG_STDCPP_NAME
1103-
11041098
# a little post-processing of various config values
11051099
CFG_PREFIX=${CFG_PREFIX%/}
11061100
CFG_MANDIR=${CFG_MANDIR%/}

branches/tmp/mk/llvm.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
7373

7474
ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
7575
LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
76-
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
76+
-print-file-name=libstdc++.a))"
7777
else
7878
LLVM_STDCPP_RUSTFLAGS_$(1) =
7979
endif
@@ -83,7 +83,7 @@ endif
8383
LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
8484
$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
8585
$(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
86-
$$(LLVM_CONFIG_$(1)) "$(CFG_STDCPP_NAME)"
86+
$$(LLVM_CONFIG_$(1))
8787
endef
8888

8989
$(foreach host,$(CFG_HOST), \

branches/tmp/src/doc/reference.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,22 +1178,11 @@ let px: i32 = match p { Point(x, _) => x };
11781178
```
11791179

11801180
A _unit-like struct_ is a structure without any fields, defined by leaving off
1181-
the list of fields entirely. Such a structure implicitly defines a constant of
1182-
its type with the same name. For example:
1181+
the list of fields entirely. Such types will have a single value. For example:
11831182

11841183
```
1185-
# #![feature(braced_empty_structs)]
11861184
struct Cookie;
1187-
let c = [Cookie, Cookie {}, Cookie, Cookie {}];
1188-
```
1189-
1190-
is equivalent to
1191-
1192-
```
1193-
# #![feature(braced_empty_structs)]
1194-
struct Cookie {}
1195-
const Cookie: Cookie = Cookie {};
1196-
let c = [Cookie, Cookie {}, Cookie, Cookie {}];
1185+
let c = [Cookie, Cookie, Cookie, Cookie];
11971186
```
11981187

11991188
The precise memory layout of a structure is not specified. One can specify a
@@ -2422,7 +2411,6 @@ The currently implemented features of the reference compiler are:
24222411
terms of encapsulation).
24232412
* - `default_type_parameter_fallback` - Allows type parameter defaults to
24242413
influence type inference.
2425-
* - `braced_empty_structs` - Allows use of empty structs with braces.
24262414

24272415
If a feature is promoted to a language feature, then all existing programs will
24282416
start to receive compilation warnings about `#![feature]` directives which enabled

branches/tmp/src/doc/trpl/error-handling.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
8787
Here's another example that is slightly less contrived. A program that accepts
8888
an integer as an argument, doubles it and prints it.
8989

90-
<div id="code-unwrap-double">
90+
<a name="code-unwrap-double"/>
9191
```rust,should_panic
9292
9393
use std::env;
@@ -99,7 +99,6 @@ fn main() {
9999
println!("{}", 2 * n);
100100
}
101101
```
102-
</div>
103102

104103
If you give this program zero arguments (error 1) or if the first argument
105104
isn't an integer (error 2), the program will panic just like in the first
@@ -140,7 +139,7 @@ system is an important concept because it will cause the compiler to force the
140139
programmer to handle that absence. Let's take a look at an example that tries
141140
to find a character in a string:
142141

143-
<div id="code-option-ex-string-find">
142+
<a name="code-option-ex-string-find"/>
144143
```rust
145144
// Searches `haystack` for the Unicode character `needle`. If one is found, the
146145
// byte offset of the character is returned. Otherwise, `None` is returned.
@@ -153,7 +152,6 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
153152
None
154153
}
155154
```
156-
</div>
157155

158156
Notice that when this function finds a matching character, it doen't just
159157
return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or

branches/tmp/src/etc/mklldeps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
components = sys.argv[2].split() # splits on whitespace
1818
enable_static = sys.argv[3]
1919
llvm_config = sys.argv[4]
20-
stdcpp_name = sys.argv[5]
2120

2221
f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2322
// file at the top-level directory of this distribution and at
@@ -78,15 +77,15 @@ def run(args):
7877
out = run([llvm_config, '--cxxflags'])
7978
if enable_static == '1':
8079
assert('stdlib=libc++' not in out)
81-
f.write("#[link(name = \"" + stdcpp_name + "\", kind = \"static\")]\n")
80+
f.write("#[link(name = \"stdc++\", kind = \"static\")]\n")
8281
else:
8382
# Note that we use `cfg_attr` here because on MSVC the C++ standard library
8483
# is not c++ or stdc++, but rather the linker takes care of linking the
8584
# right standard library.
8685
if 'stdlib=libc++' in out:
8786
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"c++\"))]\n")
8887
else:
89-
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"" + stdcpp_name + "\"))]\n")
88+
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"stdc++\"))]\n")
9089

9190
# Attach everything to an extern block
9291
f.write("extern {}\n")

branches/tmp/src/libcollections/btree/node.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ fn calculate_allocation_generic<K, V>(capacity: usize, is_leaf: bool) -> (usize,
164164
let (keys_size, keys_align) = (capacity * mem::size_of::<K>(), mem::align_of::<K>());
165165
let (vals_size, vals_align) = (capacity * mem::size_of::<V>(), mem::align_of::<V>());
166166
let (edges_size, edges_align) = if is_leaf {
167-
(0, 1)
167+
// allocate one edge to ensure that we don't pass size 0 to `heap::allocate`
168+
if mem::size_of::<K>() == 0 && mem::size_of::<V>() == 0 {
169+
(1, mem::align_of::<Node<K, V>>())
170+
} else {
171+
(0, 1)
172+
}
168173
} else {
169174
((capacity + 1) * mem::size_of::<Node<K, V>>(), mem::align_of::<Node<K, V>>())
170175
};

branches/tmp/src/libcollections/vec_deque.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
use core::cmp::Ordering;
2222
use core::fmt;
2323
use core::iter::{repeat, FromIterator};
24-
use core::mem;
2524
use core::ops::{Index, IndexMut};
2625
use core::ptr;
2726
use core::slice;
28-
use core::usize;
2927

3028
use core::hash::{Hash, Hasher};
3129
use core::cmp;
@@ -34,7 +32,6 @@ use alloc::raw_vec::RawVec;
3432

3533
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
3634
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
37-
const MAXIMUM_ZST_CAPACITY: usize = 1 << (usize::BITS - 1); // Largest possible power of two
3835

3936
/// `VecDeque` is a growable ring buffer, which can be used as a
4037
/// double-ended queue efficiently.
@@ -86,12 +83,7 @@ impl<T> VecDeque<T> {
8683
/// Marginally more convenient
8784
#[inline]
8885
fn cap(&self) -> usize {
89-
if mem::size_of::<T>() == 0 {
90-
// For zero sized types, we are always at maximum capacity
91-
MAXIMUM_ZST_CAPACITY
92-
} else {
93-
self.buf.cap()
94-
}
86+
self.buf.cap()
9587
}
9688

9789
/// Turn ptr into a slice
@@ -1473,7 +1465,6 @@ impl<T: Clone> VecDeque<T> {
14731465
#[inline]
14741466
fn wrap_index(index: usize, size: usize) -> usize {
14751467
// size is always a power of 2
1476-
debug_assert!(size.is_power_of_two());
14771468
index & (size - 1)
14781469
}
14791470

@@ -2041,34 +2032,4 @@ mod tests {
20412032
}
20422033
}
20432034
}
2044-
2045-
#[test]
2046-
fn test_zst_push() {
2047-
const N: usize = 8;
2048-
2049-
// Zero sized type
2050-
struct Zst;
2051-
2052-
// Test that for all possible sequences of push_front / push_back,
2053-
// we end up with a deque of the correct size
2054-
2055-
for len in 0..N {
2056-
let mut tester = VecDeque::with_capacity(len);
2057-
assert_eq!(tester.len(), 0);
2058-
assert!(tester.capacity() >= len);
2059-
for case in 0..(1 << len) {
2060-
assert_eq!(tester.len(), 0);
2061-
for bit in 0..len {
2062-
if case & (1 << bit) != 0 {
2063-
tester.push_front(Zst);
2064-
} else {
2065-
tester.push_back(Zst);
2066-
}
2067-
}
2068-
assert_eq!(tester.len(), len);
2069-
assert_eq!(tester.iter().count(), len);
2070-
tester.clear();
2071-
}
2072-
}
2073-
}
20742035
}

branches/tmp/src/libcollectionstest/btree/map.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,59 @@ fn test_extend_ref() {
294294
assert_eq!(a[&3], "three");
295295
}
296296

297+
#[test]
298+
fn test_zst() {
299+
let mut m = BTreeMap::new();
300+
assert_eq!(m.len(), 0);
301+
302+
assert_eq!(m.insert((), ()), None);
303+
assert_eq!(m.len(), 1);
304+
305+
assert_eq!(m.insert((), ()), Some(()));
306+
assert_eq!(m.len(), 1);
307+
assert_eq!(m.iter().count(), 1);
308+
309+
m.clear();
310+
assert_eq!(m.len(), 0);
311+
312+
for _ in 0..100 {
313+
m.insert((), ());
314+
}
315+
316+
assert_eq!(m.len(), 1);
317+
assert_eq!(m.iter().count(), 1);
318+
}
319+
320+
// This test's only purpose is to ensure that zero-sized keys with nonsensical orderings
321+
// do not cause segfaults when used with zero-sized values. All other map behavior is
322+
// undefined.
323+
#[test]
324+
fn test_bad_zst() {
325+
use std::cmp::Ordering;
326+
327+
struct Bad;
328+
329+
impl PartialEq for Bad {
330+
fn eq(&self, _: &Self) -> bool { false }
331+
}
332+
333+
impl Eq for Bad {}
334+
335+
impl PartialOrd for Bad {
336+
fn partial_cmp(&self, _: &Self) -> Option<Ordering> { Some(Ordering::Less) }
337+
}
338+
339+
impl Ord for Bad {
340+
fn cmp(&self, _: &Self) -> Ordering { Ordering::Less }
341+
}
342+
343+
let mut m = BTreeMap::new();
344+
345+
for _ in 0..100 {
346+
m.insert(Bad, Bad);
347+
}
348+
}
349+
297350
mod bench {
298351
use std::collections::BTreeMap;
299352
use std::__rand::{Rng, thread_rng};

branches/tmp/src/librustc_front/fold.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ pub fn noop_fold_foreign_mod<T: Folder>(ForeignMod {abi, items}: ForeignMod,
415415
}
416416

417417
pub fn noop_fold_variant<T: Folder>(v: P<Variant>, fld: &mut T) -> P<Variant> {
418-
v.map(|Spanned {node: Variant_ {id, name, attrs, kind, disr_expr}, span}| Spanned {
418+
v.map(|Spanned {node: Variant_ {id, name, attrs, kind, disr_expr, vis}, span}| Spanned {
419419
node: Variant_ {
420420
id: fld.new_id(id),
421421
name: name,
@@ -430,6 +430,7 @@ pub fn noop_fold_variant<T: Folder>(v: P<Variant>, fld: &mut T) -> P<Variant> {
430430
}
431431
},
432432
disr_expr: disr_expr.map(|e| fld.fold_expr(e)),
433+
vis: vis,
433434
},
434435
span: fld.new_span(span),
435436
})

branches/tmp/src/librustc_front/hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ pub struct Variant_ {
10521052
pub id: NodeId,
10531053
/// Explicit discriminant, eg `Foo = 1`
10541054
pub disr_expr: Option<P<Expr>>,
1055+
pub vis: Visibility,
10551056
}
10561057

10571058
pub type Variant = Spanned<Variant_>;

branches/tmp/src/librustc_front/lowering.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub fn lower_variant(v: &Variant) -> P<hir::Variant> {
147147
}
148148
},
149149
disr_expr: v.node.disr_expr.as_ref().map(|e| lower_expr(e)),
150+
vis: lower_visibility(v.node.vis),
150151
},
151152
span: v.span,
152153
})

branches/tmp/src/librustc_front/print/pprust.rs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ impl<'a> State<'a> {
944944
}
945945

946946
pub fn print_variant(&mut self, v: &hir::Variant) -> io::Result<()> {
947+
try!(self.print_visibility(v.node.vis));
947948
match v.node.kind {
948949
hir::TupleVariantKind(ref args) => {
949950
try!(self.print_ident(v.node.name));
@@ -1217,34 +1218,34 @@ impl<'a> State<'a> {
12171218
fields: &[hir::Field],
12181219
wth: &Option<P<hir::Expr>>) -> io::Result<()> {
12191220
try!(self.print_path(path, true, 0));
1220-
try!(word(&mut self.s, "{"));
1221-
try!(self.commasep_cmnt(
1222-
Consistent,
1223-
&fields[..],
1224-
|s, field| {
1225-
try!(s.ibox(indent_unit));
1226-
try!(s.print_ident(field.ident.node));
1227-
try!(s.word_space(":"));
1228-
try!(s.print_expr(&*field.expr));
1229-
s.end()
1230-
},
1231-
|f| f.span));
1232-
match *wth {
1233-
Some(ref expr) => {
1234-
try!(self.ibox(indent_unit));
1235-
if !fields.is_empty() {
1236-
try!(word(&mut self.s, ","));
1237-
try!(space(&mut self.s));
1221+
if !(fields.is_empty() && wth.is_none()) {
1222+
try!(word(&mut self.s, "{"));
1223+
try!(self.commasep_cmnt(
1224+
Consistent,
1225+
&fields[..],
1226+
|s, field| {
1227+
try!(s.ibox(indent_unit));
1228+
try!(s.print_ident(field.ident.node));
1229+
try!(s.word_space(":"));
1230+
try!(s.print_expr(&*field.expr));
1231+
s.end()
1232+
},
1233+
|f| f.span));
1234+
match *wth {
1235+
Some(ref expr) => {
1236+
try!(self.ibox(indent_unit));
1237+
if !fields.is_empty() {
1238+
try!(word(&mut self.s, ","));
1239+
try!(space(&mut self.s));
1240+
}
1241+
try!(word(&mut self.s, ".."));
1242+
try!(self.print_expr(&**expr));
1243+
try!(self.end());
12381244
}
1239-
try!(word(&mut self.s, ".."));
1240-
try!(self.print_expr(&**expr));
1241-
try!(self.end());
1242-
}
1243-
_ => if !fields.is_empty() {
1244-
try!(word(&mut self.s, ","))
1245+
_ => try!(word(&mut self.s, ",")),
12451246
}
1247+
try!(word(&mut self.s, "}"));
12461248
}
1247-
try!(word(&mut self.s, "}"));
12481249
Ok(())
12491250
}
12501251

0 commit comments

Comments
 (0)