Skip to content

Commit 2c88bec

Browse files
committed
---
yaml --- r: 42006 b: refs/heads/master c: 85a34c2 h: refs/heads/master v: v3
1 parent 2c62c25 commit 2c88bec

34 files changed

+67
-97
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: 4a7e1ab3745f519536ef6e0377427fc41e47f7c6
2+
refs/heads/master: 85a34c2898b6a64f319f288e69b8cd433a660a17
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn parse_config(args: ~[~str]) -> config {
7070
getopts::optopt(~"logfile"),
7171
getopts::optflag(~"jit")];
7272

73-
assert (vec::is_not_empty(args));
73+
assert !args.is_empty();
7474
let args_ = vec::tail(args);
7575
let matches =
7676
&match getopts::getopts(args_, opts) {

trunk/src/compiletest/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ fn run_cfail_test(config: config, props: test_props, testfile: &Path) {
5959
check_correct_failure_status(procres);
6060
6161
let expected_errors = errors::load_errors(testfile);
62-
if vec::is_not_empty(expected_errors) {
63-
if vec::is_not_empty(props.error_patterns) {
62+
if !expected_errors.is_empty() {
63+
if !props.error_patterns.is_empty() {
6464
fatal(~"both error pattern and expected errors specified");
6565
}
6666
check_expected_errors(expected_errors, testfile, procres);
@@ -440,7 +440,7 @@ fn compose_and_run_compiler(
440440
args: procargs,
441441
input: Option<~str>) -> procres {
442442

443-
if props.aux_builds.is_not_empty() {
443+
if !props.aux_builds.is_empty() {
444444
ensure_dir(&aux_output_dir_name(config, testfile));
445445
}
446446

trunk/src/libcore/core.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ pub use path::PosixPath;
190190

191191
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
192192
pub use str::{StrSlice, Trimmable};
193-
pub use vec::{ConstVector, CopyableVector, ImmutableVector};
193+
pub use container::{Container, Mutable};
194+
pub use vec::{CopyableVector, ImmutableVector};
194195
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
195196
pub use vec::{OwnedVector, OwnedCopyableVector};
196197
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};

trunk/src/libcore/dlist.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ impl<T> DList<T> {
208208
pure fn len(@self) -> uint { self.size }
209209
/// Returns true if the list is empty. O(1).
210210
pure fn is_empty(@self) -> bool { self.len() == 0 }
211-
/// Returns true if the list is not empty. O(1).
212-
pure fn is_not_empty(@self) -> bool { self.len() != 0 }
213211
214212
/// Add data to the head of the list. O(1).
215213
fn push_head(@self, data: T) {
@@ -648,8 +646,6 @@ mod tests {
648646
let full1 = from_vec(~[1,2,3]);
649647
assert empty.is_empty();
650648
assert !full1.is_empty();
651-
assert !empty.is_not_empty();
652-
assert full1.is_not_empty();
653649
}
654650
#[test]
655651
fn test_dlist_head_tail() {

trunk/src/libcore/float.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub pure fn to_str_common(num: float, digits: uint, exact: bool) -> ~str {
157157

158158
// turn digits into string
159159
// using stack of digits
160-
while fractionalParts.is_not_empty() {
160+
while !fractionalParts.is_empty() {
161161
// Bleh; shouldn't need to be unsafe
162162
let mut adjusted_digit = carry + unsafe { fractionalParts.pop() };
163163

trunk/src/libcore/prelude.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ pub use path::PosixPath;
2929

3030
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
3131
pub use str::{StrSlice, Trimmable};
32-
pub use vec::{ConstVector, CopyableVector, ImmutableVector};
32+
pub use container::{Container, Mutable};
33+
pub use vec::{CopyableVector, ImmutableVector};
3334
pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
3435
pub use vec::{OwnedVector, OwnedCopyableVector};
3536
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};

trunk/src/libcore/str.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,9 +1419,6 @@ pub pure fn is_ascii(s: &str) -> bool {
14191419
/// Returns true if the string has length 0
14201420
pub pure fn is_empty(s: &str) -> bool { len(s) == 0u }
14211421

1422-
/// Returns true if the string has length greater than 0
1423-
pub pure fn is_not_empty(s: &str) -> bool { !is_empty(s) }
1424-
14251422
/**
14261423
* Returns true if the string contains only whitespace
14271424
*
@@ -2167,7 +2164,6 @@ pub trait StrSlice {
21672164
pure fn each_chari(it: fn(uint, char) -> bool);
21682165
pure fn ends_with(needle: &str) -> bool;
21692166
pure fn is_empty() -> bool;
2170-
pure fn is_not_empty() -> bool;
21712167
pure fn is_whitespace() -> bool;
21722168
pure fn is_alphanumeric() -> bool;
21732169
pure fn len() -> uint;
@@ -2229,9 +2225,6 @@ impl &str: StrSlice {
22292225
/// Returns true if the string has length 0
22302226
#[inline]
22312227
pure fn is_empty() -> bool { is_empty(self) }
2232-
/// Returns true if the string has length greater than 0
2233-
#[inline]
2234-
pure fn is_not_empty() -> bool { is_not_empty(self) }
22352228
/**
22362229
* Returns true if the string contains only whitespace
22372230
*
@@ -2739,12 +2732,6 @@ mod tests {
27392732
assert (!is_empty(~"a"));
27402733
}
27412734

2742-
#[test]
2743-
fn test_is_not_empty() {
2744-
assert (is_not_empty(~"a"));
2745-
assert (!is_not_empty(~""));
2746-
}
2747-
27482735
#[test]
27492736
fn test_replace() {
27502737
let a = ~"a";

trunk/src/libcore/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ terminate normally, but instead directly return from a function.
8484
8585
~~~
8686
fn choose_weighted_item(v: &[Item]) -> Item {
87-
assert v.is_not_empty();
87+
assert !v.is_empty();
8888
let mut so_far = 0u;
8989
for v.each |item| {
9090
so_far += item.weight;

trunk/src/libcore/vec.rs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#[forbid(deprecated_pattern)];
1515
#[warn(non_camel_case_types)];
1616

17+
use container::{Container, Mutable};
1718
use cast::transmute;
1819
use cast;
1920
use cmp::{Eq, Ord};
@@ -48,11 +49,6 @@ pub pure fn is_empty<T>(v: &[const T]) -> bool {
4849
as_const_buf(v, |_p, len| len == 0u)
4950
}
5051

51-
/// Returns true if a vector contains some elements
52-
pub pure fn is_not_empty<T>(v: &[const T]) -> bool {
53-
as_const_buf(v, |_p, len| len > 0u)
54-
}
55-
5652
/// Returns true if two vectors have the same length
5753
pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
5854
len(xs) == len(ys)
@@ -453,7 +449,7 @@ pub pure fn partitioned<T: Copy>(v: &[T], f: fn(&T) -> bool) -> (~[T], ~[T]) {
453449
/// Removes the first element from a vector and return it
454450
pub fn shift<T>(v: &mut ~[T]) -> T {
455451
unsafe {
456-
assert v.is_not_empty();
452+
assert !v.is_empty();
457453

458454
if v.len() == 1 { return v.pop() }
459455

@@ -1647,20 +1643,11 @@ pub mod traits {
16471643
}
16481644
}
16491645

1650-
pub trait ConstVector {
1651-
pure fn is_empty(&self) -> bool;
1652-
pure fn is_not_empty(&self) -> bool;
1653-
pure fn len(&self) -> uint;
1654-
}
1655-
1656-
/// Extension methods for vectors
1657-
impl<T> &[const T]: ConstVector {
1646+
impl<T> &[const T]: Container {
16581647
/// Returns true if a vector contains no elements
16591648
#[inline]
16601649
pure fn is_empty(&self) -> bool { is_empty(*self) }
1661-
/// Returns true if a vector contains some elements
1662-
#[inline]
1663-
pure fn is_not_empty(&self) -> bool { is_not_empty(*self) }
1650+
16641651
/// Returns the length of a vector
16651652
#[inline]
16661653
pure fn len(&self) -> uint { len(*self) }
@@ -1949,6 +1936,11 @@ impl<T> ~[T]: OwnedVector<T> {
19491936
}
19501937
}
19511938

1939+
impl<T> ~[T]: Mutable {
1940+
/// Clear the vector, removing all values.
1941+
fn clear(&mut self) { self.truncate(0) }
1942+
}
1943+
19521944
pub trait OwnedCopyableVector<T: Copy> {
19531945
fn push_all(&mut self, rhs: &[const T]);
19541946
fn grow(&mut self, n: uint, initval: &T);
@@ -2518,12 +2510,6 @@ mod tests {
25182510
assert (!is_empty(~[0]));
25192511
}
25202512

2521-
#[test]
2522-
fn test_is_not_empty() {
2523-
assert (is_not_empty(~[0]));
2524-
assert (!is_not_empty::<int>(~[]));
2525-
}
2526-
25272513
#[test]
25282514
fn test_len_divzero() {
25292515
type Z = [i8 * 0];
@@ -2700,6 +2686,14 @@ mod tests {
27002686
// If the unsafe block didn't drop things properly, we blow up here.
27012687
}
27022688

2689+
#[test]
2690+
fn test_clear() {
2691+
let mut v = ~[@6,@5,@4];
2692+
v.clear();
2693+
assert(v.len() == 0);
2694+
// If the unsafe block didn't drop things properly, we blow up here.
2695+
}
2696+
27032697
#[test]
27042698
fn test_dedup() {
27052699
fn case(a: ~[uint], b: ~[uint]) {

trunk/src/librustc/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
167167

168168
path.push_all(vec::view(split2, start_idx, len2 - 1));
169169

170-
if vec::is_not_empty(path) {
170+
if !path.is_empty() {
171171
return Path("").push_many(path);
172172
} else {
173173
return Path(".");

trunk/src/librustc/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) ->
147147
}
148148

149149
fn is_test_fn(i: @ast::item) -> bool {
150-
let has_test_attr = attr::find_attrs_by_name(i.attrs,
151-
~"test").is_not_empty();
150+
let has_test_attr = !attr::find_attrs_by_name(i.attrs,
151+
~"test").is_empty();
152152

153153
fn has_test_signature(i: @ast::item) -> bool {
154154
match &i.node {
@@ -171,7 +171,7 @@ fn is_ignored(cx: test_ctxt, i: @ast::item) -> bool {
171171
let ignoreitems = attr::attr_metas(ignoreattrs);
172172
let cfg_metas = vec::concat(vec::filter_map(ignoreitems,
173173
|i| attr::get_meta_item_list(*i)));
174-
return if vec::is_not_empty(ignoreitems) {
174+
return if !ignoreitems.is_empty() {
175175
config::metas_in_cfg(/*bad*/copy cx.crate.node.config, cfg_metas)
176176
} else {
177177
false

trunk/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ fn type_to_str_inner(names: type_names, +outer0: ~[TypeRef], ty: TypeRef) ->
13311331
Struct => {
13321332
let n_elts = llvm::LLVMCountStructElementTypes(ty) as uint;
13331333
let mut elts = vec::from_elem(n_elts, 0 as TypeRef);
1334-
if elts.is_not_empty() {
1334+
if !elts.is_empty() {
13351335
llvm::LLVMGetStructElementTypes(
13361336
ty, ptr::to_mut_unsafe_ptr(&mut elts[0]));
13371337
}

trunk/src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn warn_if_multiple_versions(e: env, diag: span_handler,
9595
}
9696
}));
9797

98-
assert matches.is_not_empty();
98+
assert !matches.is_empty();
9999

100100
if matches.len() != 1u {
101101
diag.handler().warn(
@@ -168,7 +168,7 @@ fn visit_item(e: env, i: @ast::item) {
168168
already_added = !cstore::add_used_library(cstore,
169169
foreign_name);
170170
}
171-
if link_args.is_not_empty() && already_added {
171+
if !link_args.is_empty() && already_added {
172172
e.diag.span_fatal(i.span, ~"library '" + foreign_name +
173173
~"' already added: can't specify link_args.");
174174
}

trunk/src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,8 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
10181018
fn synthesize_link_attr(ecx: @encode_ctxt, +items: ~[@meta_item]) ->
10191019
attribute {
10201020

1021-
assert ecx.link_meta.name.is_not_empty();
1022-
assert ecx.link_meta.vers.is_not_empty();
1021+
assert !ecx.link_meta.name.is_empty();
1022+
assert !ecx.link_meta.vers.is_empty();
10231023

10241024
let name_item =
10251025
attr::mk_name_value_item_str(~"name",

trunk/src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn crate_matches(crate_data: @~[u8], +metas: ~[@ast::meta_item],
179179
hash: ~str) -> bool {
180180
let attrs = decoder::get_crate_attributes(crate_data);
181181
let linkage_metas = attr::find_linkage_metas(attrs);
182-
if hash.is_not_empty() {
182+
if !hash.is_empty() {
183183
let chash = decoder::get_crate_hash(crate_data);
184184
if chash != hash { return false; }
185185
}

trunk/src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn raw_pat(p: @pat) -> @pat {
132132
}
133133

134134
fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
135-
assert(pats.is_not_empty());
135+
assert(!pats.is_empty());
136136
let ext = match is_useful(cx, vec::map(pats, |p| ~[*p]), ~[wild()]) {
137137
not_useful => return, // This is good, wildcard pattern isn't reachable
138138
useful_ => None,

trunk/src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
820820
fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
821821
fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool {
822822
let ident = cx.sess.str_of(ident);
823-
assert ident.is_not_empty();
823+
assert !ident.is_empty();
824824
let ident = ident_without_trailing_underscores(ident);
825825
let ident = ident_without_leading_underscores(ident);
826826
char::is_uppercase(str::char_at(ident, 0)) &&

trunk/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ fn get_res_dtor(ccx: @crate_ctxt, did: ast::def_id,
459459
parent_id: ast::def_id, substs: ~[ty::t])
460460
-> ValueRef {
461461
let _icx = ccx.insn_ctxt("trans_res_dtor");
462-
if (substs.is_not_empty()) {
462+
if !substs.is_empty() {
463463
let did = if did.crate != ast::local_crate {
464464
inline::maybe_instantiate_inline(ccx, did, true)
465465
} else { did };

trunk/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
635635
} else {
636636
for m.items.each |item| {
637637
let tpt = ty::lookup_item_type(ccx.tcx, local_def(item.id));
638-
if (*tpt.bounds).is_not_empty() {
638+
if !tpt.bounds.is_empty() {
639639
ccx.tcx.sess.span_err(
640640
item.span,
641641
fmt!("foreign items may not have type parameters"));

trunk/src/librustc/middle/typeck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
356356
Some(ast_map::node_item(it,_)) => {
357357
match it.node {
358358
ast::item_fn(_, _, ref ps, _)
359-
if vec::is_not_empty(*ps) => {
359+
if !ps.is_empty() => {
360360
tcx.sess.span_err(
361361
main_span,
362362
~"main function is not allowed \

trunk/src/librustdoc/attr_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
127127
match attr::get_meta_item_list(*meta) {
128128
Some(metas) => {
129129
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
130-
vec::is_not_empty(hiddens)
130+
!hiddens.is_empty()
131131
}
132132
None => false
133133
}

trunk/src/librustdoc/desc_to_brief_pass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn parse_desc(desc: ~str) -> Option<~str> {
143143

144144
fn first_sentence(s: ~str) -> Option<~str> {
145145
let paras = paragraphs(s);
146-
if vec::is_not_empty(paras) {
146+
if !paras.is_empty() {
147147
let first_para = vec::head(paras);
148148
Some(str::replace(first_sentence_(first_para), ~"\n", ~" "))
149149
} else {
@@ -193,7 +193,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
193193
whitespace_lines += 1;
194194
} else {
195195
if whitespace_lines > 0 {
196-
if str::is_not_empty(accum) {
196+
if !accum.is_empty() {
197197
res += ~[accum];
198198
accum = ~"";
199199
}
@@ -211,7 +211,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
211211
res
212212
};
213213

214-
if str::is_not_empty(accum) {
214+
if !accum.is_empty() {
215215
paras + ~[accum]
216216
} else {
217217
paras

trunk/src/librustdoc/unindent_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn unindent(s: ~str) -> ~str {
7878
}
7979
};
8080

81-
if vec::is_not_empty(lines) {
81+
if !lines.is_empty() {
8282
let unindented = ~[str::trim(vec::head(lines))]
8383
+ do par::map(vec::tail(lines)) |line| {
8484
if str::is_whitespace(*line) {

trunk/src/libstd/bigint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub impl BigUint {
402402
}
403403

404404
pure fn is_zero(&self) -> bool { self.data.is_empty() }
405-
pure fn is_not_zero(&self) -> bool { self.data.is_not_empty() }
405+
pure fn is_not_zero(&self) -> bool { !self.data.is_empty() }
406406
pure fn is_positive(&self) -> bool { self.is_not_zero() }
407407
pure fn is_negative(&self) -> bool { false }
408408
pure fn is_nonpositive(&self) -> bool { self.is_zero() }

0 commit comments

Comments
 (0)