Skip to content

Commit 7c9ab9a

Browse files
committed
---
yaml --- r: 123663 b: refs/heads/try c: 8121c39 h: refs/heads/master i: 123661: 1d69674 123659: f9d54c4 123655: a8a558a 123647: 92b8802 v: v3
1 parent 6b4d074 commit 7c9ab9a

File tree

18 files changed

+102
-244
lines changed

18 files changed

+102
-244
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: da4e4e4e0a7778a85748aa4a303b13f603e96b4b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 8ddd286ea4ba4384a0dc9eae393ed515460a986e
5-
refs/heads/try: 6959931498820b2b784168164b53a79dceafc4da
5+
refs/heads/try: 8121c39a3ef6225c8500cdd9f4f14e6e4cc1456f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ endif
171171
# Main test targets
172172
######################################################################
173173

174-
check: cleantmptestlogs cleantestlibs tidy check-notidy
174+
check: cleantmptestlogs cleantestlibs check-notidy tidy
175175

176176
check-notidy: cleantmptestlogs cleantestlibs all check-stage2
177177
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log

branches/try/src/libcollections/vec.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ use {Collection, Mutable};
2727
use slice::{MutableOrdVector, MutableVectorAllocating, CloneableVector};
2828
use slice::{Items, MutItems};
2929

30-
31-
#[doc(hidden)]
32-
pub static PTR_MARKER: u8 = 0;
33-
3430
/// An owned, growable vector.
3531
///
3632
/// # Examples
@@ -75,11 +71,7 @@ impl<T> Vec<T> {
7571
/// ```
7672
#[inline]
7773
pub fn new() -> Vec<T> {
78-
// We want ptr to never be NULL so instead we set it to some arbitrary
79-
// non-null value which is fine since we never call deallocate on the ptr
80-
// if cap is 0. The reason for this is because the pointer of a slice
81-
// being NULL would break the null pointer optimization for enums.
82-
Vec { len: 0, cap: 0, ptr: &PTR_MARKER as *const _ as *mut T }
74+
Vec { len: 0, cap: 0, ptr: 0 as *mut T }
8375
}
8476

8577
/// Constructs a new, empty `Vec` with the specified capacity.
@@ -96,7 +88,7 @@ impl<T> Vec<T> {
9688
#[inline]
9789
pub fn with_capacity(capacity: uint) -> Vec<T> {
9890
if mem::size_of::<T>() == 0 {
99-
Vec { len: 0, cap: uint::MAX, ptr: &PTR_MARKER as *const _ as *mut T }
91+
Vec { len: 0, cap: uint::MAX, ptr: 0 as *mut T }
10092
} else if capacity == 0 {
10193
Vec::new()
10294
} else {
@@ -1214,7 +1206,15 @@ impl<T> Vec<T> {
12141206
/// would also make any pointers to it invalid.
12151207
#[inline]
12161208
pub fn as_ptr(&self) -> *const T {
1217-
self.ptr as *const T
1209+
// If we have a 0-sized vector, then the base pointer should not be NULL
1210+
// because an iterator over the slice will attempt to yield the base
1211+
// pointer as the first element in the vector, but this will end up
1212+
// being Some(NULL) which is optimized to None.
1213+
if mem::size_of::<T>() == 0 {
1214+
1 as *const T
1215+
} else {
1216+
self.ptr as *const T
1217+
}
12181218
}
12191219

12201220
/// Returns a mutable unsafe pointer to the vector's buffer.
@@ -1226,7 +1226,12 @@ impl<T> Vec<T> {
12261226
/// would also make any pointers to it invalid.
12271227
#[inline]
12281228
pub fn as_mut_ptr(&mut self) -> *mut T {
1229-
self.ptr
1229+
// see above for the 0-size check
1230+
if mem::size_of::<T>() == 0 {
1231+
1 as *mut T
1232+
} else {
1233+
self.ptr
1234+
}
12301235
}
12311236

12321237
/// Retains only the elements specified by the predicate.

branches/try/src/libcore/slice.rs

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -884,20 +884,17 @@ macro_rules! iterator {
884884
if self.ptr == self.end {
885885
None
886886
} else {
887-
if mem::size_of::<T>() == 0 {
887+
let old = self.ptr;
888+
self.ptr = if mem::size_of::<T>() == 0 {
888889
// purposefully don't use 'ptr.offset' because for
889890
// vectors with 0-size elements this would return the
890891
// same pointer.
891-
self.ptr = transmute(self.ptr as uint + 1);
892-
893-
// Use a non-null pointer value
894-
Some(transmute(1u))
892+
transmute(self.ptr as uint + 1)
895893
} else {
896-
let old = self.ptr;
897-
self.ptr = self.ptr.offset(1);
894+
self.ptr.offset(1)
895+
};
898896

899-
Some(transmute(old))
900-
}
897+
Some(transmute(old))
901898
}
902899
}
903900
}
@@ -919,17 +916,13 @@ macro_rules! iterator {
919916
if self.end == self.ptr {
920917
None
921918
} else {
922-
if mem::size_of::<T>() == 0 {
919+
self.end = if mem::size_of::<T>() == 0 {
923920
// See above for why 'ptr.offset' isn't used
924-
self.end = transmute(self.end as uint - 1);
925-
926-
// Use a non-null pointer value
927-
Some(transmute(1u))
921+
transmute(self.end as uint - 1)
928922
} else {
929-
self.end = self.end.offset(-1);
930-
931-
Some(transmute(self.end))
932-
}
923+
self.end.offset(-1)
924+
};
925+
Some(transmute(self.end))
933926
}
934927
}
935928
}
@@ -963,12 +956,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> {
963956
fn idx(&mut self, index: uint) -> Option<&'a T> {
964957
unsafe {
965958
if index < self.indexable() {
966-
if mem::size_of::<T>() == 0 {
967-
// Use a non-null pointer value
968-
Some(transmute(1u))
969-
} else {
970-
Some(transmute(self.ptr.offset(index as int)))
971-
}
959+
transmute(self.ptr.offset(index as int))
972960
} else {
973961
None
974962
}

branches/try/src/librustc/middle/check_match.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,13 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
283283
};
284284
if is_structure {
285285
let fields = ty::lookup_struct_fields(cx.tcx, vid);
286-
let field_pats: Vec<FieldPat> = fields.move_iter()
286+
let field_pats = fields.move_iter()
287287
.zip(pats.iter())
288-
.filter(|&(_, pat)| pat.node != PatWild)
289288
.map(|(field, pat)| FieldPat {
290289
ident: Ident::new(field.name),
291290
pat: pat.clone()
292291
}).collect();
293-
let has_more_fields = field_pats.len() < pats.len();
294-
PatStruct(def_to_path(cx.tcx, vid), field_pats, has_more_fields)
292+
PatStruct(def_to_path(cx.tcx, vid), field_pats, false)
295293
} else {
296294
PatEnum(def_to_path(cx.tcx, vid), Some(pats))
297295
}

branches/try/src/librustc/middle/resolve.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ enum BareIdentifierPatternResolution {
307307
#[deriving(PartialEq)]
308308
enum DuplicateCheckingMode {
309309
ForbidDuplicateModules,
310-
ForbidDuplicateTypesAndModules,
310+
ForbidDuplicateTypes,
311311
ForbidDuplicateValues,
312312
ForbidDuplicateTypesAndValues,
313313
OverwriteDuplicates
@@ -792,9 +792,10 @@ impl PrimitiveTypeTable {
792792

793793
fn namespace_error_to_str(ns: NamespaceError) -> &'static str {
794794
match ns {
795-
NoError => "",
796-
ModuleError | TypeError => "type or module",
797-
ValueError => "value",
795+
NoError => "",
796+
ModuleError => "module",
797+
TypeError => "type",
798+
ValueError => "value",
798799
}
799800
}
800801

@@ -1032,12 +1033,9 @@ impl<'a> Resolver<'a> {
10321033
}
10331034
Some(TypeNS)
10341035
}
1035-
ForbidDuplicateTypesAndModules => {
1036+
ForbidDuplicateTypes => {
10361037
match child.def_for_namespace(TypeNS) {
1037-
None => {}
1038-
Some(_) if child.get_module_if_available()
1039-
.map(|m| m.kind.get()) ==
1040-
Some(ImplModuleKind) => {}
1038+
Some(DefMod(_)) | None => {}
10411039
Some(_) => duplicate_type = TypeError
10421040
}
10431041
Some(TypeNS)
@@ -1179,10 +1177,7 @@ impl<'a> Resolver<'a> {
11791177
// These items live in the type namespace.
11801178
ItemTy(..) => {
11811179
let name_bindings =
1182-
self.add_child(ident,
1183-
parent.clone(),
1184-
ForbidDuplicateTypesAndModules,
1185-
sp);
1180+
self.add_child(ident, parent.clone(), ForbidDuplicateTypes, sp);
11861181

11871182
name_bindings.define_type
11881183
(DefTy(local_def(item.id)), sp, is_public);
@@ -1191,10 +1186,7 @@ impl<'a> Resolver<'a> {
11911186

11921187
ItemEnum(ref enum_definition, _) => {
11931188
let name_bindings =
1194-
self.add_child(ident,
1195-
parent.clone(),
1196-
ForbidDuplicateTypesAndModules,
1197-
sp);
1189+
self.add_child(ident, parent.clone(), ForbidDuplicateTypes, sp);
11981190

11991191
name_bindings.define_type
12001192
(DefTy(local_def(item.id)), sp, is_public);
@@ -1214,7 +1206,7 @@ impl<'a> Resolver<'a> {
12141206
// Adding to both Type and Value namespaces or just Type?
12151207
let (forbid, ctor_id) = match struct_def.ctor_id {
12161208
Some(ctor_id) => (ForbidDuplicateTypesAndValues, Some(ctor_id)),
1217-
None => (ForbidDuplicateTypesAndModules, None)
1209+
None => (ForbidDuplicateTypes, None)
12181210
};
12191211

12201212
let name_bindings = self.add_child(ident, parent.clone(), forbid, sp);
@@ -1335,10 +1327,7 @@ impl<'a> Resolver<'a> {
13351327

13361328
ItemTrait(_, _, _, ref methods) => {
13371329
let name_bindings =
1338-
self.add_child(ident,
1339-
parent.clone(),
1340-
ForbidDuplicateTypesAndModules,
1341-
sp);
1330+
self.add_child(ident, parent.clone(), ForbidDuplicateTypes, sp);
13421331

13431332
// Add all the methods within to a new module.
13441333
let parent_link = self.get_parent_link(parent.clone(), ident);

0 commit comments

Comments
 (0)