Skip to content

Commit 313f9e9

Browse files
committed
---
yaml --- r: 158515 b: refs/heads/try c: e5a8840 h: refs/heads/master i: 158513: 107877a 158511: 9d57677 v: v3
1 parent 0caa5db commit 313f9e9

Some content is hidden

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

61 files changed

+875
-174
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: a0a7ab461283322215f0343cd2b5e66fc19a7bd5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 1b2ad7831f1745bf4a4709a1fa1772afb47c933c
5-
refs/heads/try: 112c8a966fbdb52ff2a535dc8e6df3a8b3cb8fb2
5+
refs/heads/try: e5a8840033b44a5ce32562d6c12386c4ee7f4ec0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/mk/main.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ endif
100100
CFG_RUSTC_FLAGS := $(RUSTFLAGS)
101101
CFG_GCCISH_CFLAGS :=
102102
CFG_GCCISH_LINK_FLAGS :=
103-
CFG_JEMALLOC_FLAGS :=
103+
104+
# Turn off broken quarantine (see jemalloc/jemalloc#161)
105+
CFG_JEMALLOC_FLAGS := --disable-fill
104106

105107
ifdef CFG_DISABLE_OPTIMIZE
106108
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))

branches/try/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ fn find_rust_src_root(config: &Config) -> Option<Path> {
627627
let path_postfix = Path::new("src/etc/lldb_batchmode.py");
628628

629629
while path.pop() {
630-
if path.join(path_postfix.clone()).is_file() {
630+
if path.join(&path_postfix).is_file() {
631631
return Some(path);
632632
}
633633
}

branches/try/src/doc/guide-testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ The benchmarking runner offers two ways to avoid this. Either, the
287287
closure that the `iter` method receives can return an arbitrary value
288288
which forces the optimizer to consider the result used and ensures it
289289
cannot remove the computation entirely. This could be done for the
290-
example above by adjusting the `bh.iter` call to
290+
example above by adjusting the `b.iter` call to
291291

292292
~~~
293293
# struct X; impl X { fn iter<T>(&self, _: || -> T) {} } let b = X;

branches/try/src/doc/intro.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,14 @@ non-deterministic aspect:
494494
$ cargo run
495495
Compiling hello_world v0.0.1 (file:///Users/you/src/hello_world)
496496
Running `target/hello_world`
497-
numbers[1] is 2
498-
numbers[0] is 1
499-
numbers[2] is 3
497+
numbers[1] is 3
498+
numbers[0] is 2
499+
numbers[2] is 4
500500
$ cargo run
501501
Running `target/hello_world`
502-
numbers[2] is 3
503-
numbers[1] is 2
504-
numbers[0] is 1
502+
numbers[2] is 4
503+
numbers[1] is 3
504+
numbers[0] is 2
505505
```
506506

507507
Each time, we get a slightly different output, because each thread works in a

branches/try/src/doc/reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,11 @@ An _integer literal_ has one of four forms:
400400
* A _decimal literal_ starts with a *decimal digit* and continues with any
401401
mixture of *decimal digits* and _underscores_.
402402
* A _hex literal_ starts with the character sequence `U+0030` `U+0078`
403-
(`0x`) and continues as any mixture hex digits and underscores.
403+
(`0x`) and continues as any mixture of hex digits and underscores.
404404
* An _octal literal_ starts with the character sequence `U+0030` `U+006F`
405-
(`0o`) and continues as any mixture octal digits and underscores.
405+
(`0o`) and continues as any mixture of octal digits and underscores.
406406
* A _binary literal_ starts with the character sequence `U+0030` `U+0062`
407-
(`0b`) and continues as any mixture binary digits and underscores.
407+
(`0b`) and continues as any mixture of binary digits and underscores.
408408

409409
An integer literal may be followed (immediately, without any spaces) by an
410410
_integer suffix_, which changes the type of the literal. There are two kinds of

branches/try/src/doc/rust.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ body {
6262
font-size: 18px;
6363
color: #333;
6464
line-height: 1.428571429;
65+
66+
-webkit-font-feature-settings: "kern", "liga";
67+
-moz-font-feature-settings: "kern", "liga";
68+
font-feature-settings: "kern", "liga";
6569
}
6670
@media (min-width: 768px) {
6771
body {

branches/try/src/libcollections/str.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,18 @@
3333
//! }
3434
//! ```
3535
//!
36-
//! From the example above, you can see that Rust's string literals have the
36+
//! From the example above, you can guess that Rust's string literals have the
3737
//! `'static` lifetime. This is akin to C's concept of a static string.
38-
//!
39-
//! String literals are allocated statically in the rodata of the
40-
//! executable/library. The string then has the type `&'static str` meaning that
41-
//! the string is valid for the `'static` lifetime, otherwise known as the
42-
//! lifetime of the entire program. As can be inferred from the type, these static
43-
//! strings are not mutable.
38+
//! More precisely, string literals are immutable views with a 'static lifetime
39+
//! (otherwise known as the lifetime of the entire program), and thus have the
40+
//! type `&'static str`.
4441
//!
4542
//! # Representation
4643
//!
4744
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
4845
//! stream of UTF-8 bytes. All strings are guaranteed to be validly encoded UTF-8
49-
//! sequences. Additionally, strings are not null-terminated and can contain null
50-
//! bytes.
46+
//! sequences. Additionally, strings are not null-terminated and can thus contain
47+
//! null bytes.
5148
//!
5249
//! The actual representation of strings have direct mappings to slices: `&str`
5350
//! is the same as `&[u8]`.

branches/try/src/libcore/iter.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ type IterateState<'a, T> = (|T|: 'a -> T, Option<T>, bool);
21552155
/// from a given seed value.
21562156
pub type Iterate<'a, T> = Unfold<'a, T, IterateState<'a, T>>;
21572157

2158-
/// Creates a new iterator that produces an infinite sequence of
2158+
/// Create a new iterator that produces an infinite sequence of
21592159
/// repeated applications of the given function `f`.
21602160
pub fn iterate<'a, T: Clone>(seed: T, f: |T|: 'a -> T) -> Iterate<'a, T> {
21612161
Unfold::new((f, Some(seed), true), |st| {
@@ -2174,6 +2174,11 @@ pub fn iterate<'a, T: Clone>(seed: T, f: |T|: 'a -> T) -> Iterate<'a, T> {
21742174
})
21752175
}
21762176

2177+
/// Create a new iterator that endlessly repeats the element `elt`.
2178+
pub fn repeat<T: Clone>(elt: T) -> Repeat<T> {
2179+
Repeat::new(elt)
2180+
}
2181+
21772182
/// Functions for lexicographical ordering of sequences.
21782183
///
21792184
/// Lexicographical ordering through `<`, `<=`, `>=`, `>` requires

branches/try/src/libcore/prelude.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ pub use ops::{Shl, Shr};
3737
pub use ops::{Index, IndexMut};
3838
pub use ops::{Slice, SliceMut};
3939
pub use ops::{Fn, FnMut, FnOnce};
40-
pub use option::{Option, Some, None};
41-
pub use result::{Result, Ok, Err};
4240

4341
// Reexported functions
44-
pub use iter::range;
42+
pub use iter::{range, repeat};
4543
pub use mem::drop;
4644

4745
// Reexported types and traits
@@ -56,7 +54,9 @@ pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
5654
pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul};
5755
pub use num::{Signed, Unsigned, Float};
5856
pub use num::{Primitive, Int, ToPrimitive, FromPrimitive};
57+
pub use option::{Option, Some, None};
5958
pub use ptr::RawPtr;
59+
pub use result::{Result, Ok, Err};
6060
pub use str::{Str, StrSlice};
6161
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
6262
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};

branches/try/src/libcore/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ pub trait StrSlice for Sized? {
15261526
/// ```
15271527
fn ends_with(&self, needle: &str) -> bool;
15281528

1529-
/// Returns a string with characters that match `to_trim` removed.
1529+
/// Returns a string with characters that match `to_trim` removed from the left and the right.
15301530
///
15311531
/// # Arguments
15321532
///

branches/try/src/libcoretest/iter.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,14 @@ fn test_iterate() {
846846
assert_eq!(it.next(), Some(8u));
847847
}
848848

849+
#[test]
850+
fn test_repeat() {
851+
let mut it = repeat(42u);
852+
assert_eq!(it.next(), Some(42u));
853+
assert_eq!(it.next(), Some(42u));
854+
assert_eq!(it.next(), Some(42u));
855+
}
856+
849857
#[bench]
850858
fn bench_rposition(b: &mut Bencher) {
851859
let it: Vec<uint> = range(0u, 300).collect();

branches/try/src/librustc/driver/config.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use back::write;
2020
use back::target_strs;
2121
use back::{arm, x86, x86_64, mips, mipsel};
2222
use lint;
23+
use metadata::cstore;
2324

2425
use syntax::abi;
2526
use syntax::ast;
@@ -78,6 +79,7 @@ pub struct Options {
7879
// parsed code. It remains mutable in case its replacements wants to use
7980
// this.
8081
pub addl_lib_search_paths: RefCell<Vec<Path>>,
82+
pub libs: Vec<(String, cstore::NativeLibaryKind)>,
8183
pub maybe_sysroot: Option<Path>,
8284
pub target_triple: String,
8385
// User-specified cfg meta items. The compiler itself will add additional
@@ -130,6 +132,7 @@ pub fn basic_options() -> Options {
130132
externs: HashMap::new(),
131133
crate_name: None,
132134
alt_std_name: None,
135+
libs: Vec::new(),
133136
}
134137
}
135138

@@ -575,6 +578,10 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
575578
optflag("h", "help", "Display this message"),
576579
optmulti("", "cfg", "Configure the compilation environment", "SPEC"),
577580
optmulti("L", "", "Add a directory to the library search path", "PATH"),
581+
optmulti("l", "", "Link the generated crate(s) to the specified native
582+
library NAME. The optional KIND can be one of,
583+
static, dylib, or framework. If omitted, dylib is
584+
assumed.", "NAME[:KIND]"),
578585
optmulti("", "crate-type", "Comma separated list of types of crates
579586
for the compiler to emit",
580587
"[bin|lib|rlib|dylib|staticlib]"),
@@ -767,6 +774,23 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
767774
Path::new(s.as_slice())
768775
}).collect();
769776

777+
let libs = matches.opt_strs("l").into_iter().map(|s| {
778+
let mut parts = s.as_slice().rsplitn(1, ':');
779+
let kind = parts.next().unwrap();
780+
let (name, kind) = match (parts.next(), kind) {
781+
(None, name) |
782+
(Some(name), "dylib") => (name, cstore::NativeUnknown),
783+
(Some(name), "framework") => (name, cstore::NativeFramework),
784+
(Some(name), "static") => (name, cstore::NativeStatic),
785+
(_, s) => {
786+
early_error(format!("unknown library kind `{}`, expected \
787+
one of dylib, framework, or static",
788+
s).as_slice());
789+
}
790+
};
791+
(name.to_string(), kind)
792+
}).collect();
793+
770794
let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
771795
let test = matches.opt_present("test");
772796
let write_dependency_info = (matches.opt_present("dep-info"),
@@ -843,7 +867,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
843867
color: color,
844868
externs: externs,
845869
crate_name: crate_name,
846-
alt_std_name: None
870+
alt_std_name: None,
871+
libs: libs,
847872
}
848873
}
849874

branches/try/src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ fn write_out_deps(sess: &Session,
660660
_ => return,
661661
};
662662

663-
let result = (|| {
663+
let result = (|| -> io::IoResult<()> {
664664
// Build a list of files used to compile the output and
665665
// write Makefile-compatible dependency rules
666666
let files: Vec<String> = sess.codemap().files.borrow()

branches/try/src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ pub fn build_session_(sopts: config::Options,
231231
if path.is_absolute() {
232232
path.clone()
233233
} else {
234-
os::getcwd().join(path.clone())
234+
os::getcwd().join(&path)
235235
}
236236
);
237237

branches/try/src/librustc/lint/builtin.rs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use middle::def::*;
3030
use middle::typeck::astconv::ast_ty_to_ty;
3131
use middle::typeck::infer;
3232
use middle::{typeck, ty, def, pat_util, stability};
33+
use middle::const_eval::{eval_const_expr_partial, const_int, const_uint};
3334
use util::ppaux::{ty_to_string};
3435
use util::nodemap::NodeSet;
3536
use lint::{Context, LintPass, LintArray};
@@ -38,14 +39,16 @@ use std::cmp;
3839
use std::collections::HashMap;
3940
use std::collections::hash_map::{Occupied, Vacant};
4041
use std::slice;
41-
use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
42+
use std::{int, i8, i16, i32, i64, uint, u8, u16, u32, u64, f32, f64};
4243
use syntax::abi;
4344
use syntax::ast_map;
45+
use syntax::ast_util::is_shift_binop;
4446
use syntax::attr::AttrMetaMethods;
4547
use syntax::attr;
4648
use syntax::codemap::Span;
4749
use syntax::parse::token;
4850
use syntax::{ast, ast_util, visit};
51+
use syntax::ast::{TyI, TyU, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
4952
use syntax::ptr::P;
5053
use syntax::visit::Visitor;
5154

@@ -113,6 +116,9 @@ declare_lint!(UNUSED_COMPARISONS, Warn,
113116
declare_lint!(OVERFLOWING_LITERALS, Warn,
114117
"literal out of range for its type")
115118

119+
declare_lint!(EXCEEDING_BITSHIFTS, Deny,
120+
"shift exceeds the type's number of bits")
121+
116122
pub struct TypeLimits {
117123
/// Id of the last visited negated expression
118124
negated_expr_id: ast::NodeId,
@@ -128,7 +134,8 @@ impl TypeLimits {
128134

129135
impl LintPass for TypeLimits {
130136
fn get_lints(&self) -> LintArray {
131-
lint_array!(UNSIGNED_NEGATION, UNUSED_COMPARISONS, OVERFLOWING_LITERALS)
137+
lint_array!(UNSIGNED_NEGATION, UNUSED_COMPARISONS, OVERFLOWING_LITERALS,
138+
EXCEEDING_BITSHIFTS)
132139
}
133140

134141
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
@@ -170,6 +177,31 @@ impl LintPass for TypeLimits {
170177
cx.span_lint(UNUSED_COMPARISONS, e.span,
171178
"comparison is useless due to type limits");
172179
}
180+
181+
if is_shift_binop(binop) {
182+
let opt_ty_bits = match ty::get(ty::expr_ty(cx.tcx, &**l)).sty {
183+
ty::ty_int(t) => Some(int_ty_bits(t)),
184+
ty::ty_uint(t) => Some(uint_ty_bits(t)),
185+
_ => None
186+
};
187+
188+
if let Some(bits) = opt_ty_bits {
189+
let exceeding = if let ast::ExprLit(ref lit) = r.node {
190+
if let ast::LitInt(shift, _) = lit.node { shift > bits }
191+
else { false }
192+
} else {
193+
match eval_const_expr_partial(cx.tcx, &**r) {
194+
Ok(const_int(shift)) => { shift as u64 > bits },
195+
Ok(const_uint(shift)) => { shift > bits },
196+
_ => { false }
197+
}
198+
};
199+
if exceeding {
200+
cx.span_lint(EXCEEDING_BITSHIFTS, e.span,
201+
"bitshift exceeds the type's number of bits");
202+
}
203+
};
204+
}
173205
},
174206
ast::ExprLit(ref lit) => {
175207
match ty::get(ty::expr_ty(cx.tcx, e)).sty {
@@ -280,6 +312,26 @@ impl LintPass for TypeLimits {
280312
}
281313
}
282314

315+
fn int_ty_bits(int_ty: ast::IntTy) -> u64 {
316+
match int_ty {
317+
ast::TyI => int::BITS as u64,
318+
ast::TyI8 => i8::BITS as u64,
319+
ast::TyI16 => i16::BITS as u64,
320+
ast::TyI32 => i32::BITS as u64,
321+
ast::TyI64 => i64::BITS as u64
322+
}
323+
}
324+
325+
fn uint_ty_bits(uint_ty: ast::UintTy) -> u64 {
326+
match uint_ty {
327+
ast::TyU => uint::BITS as u64,
328+
ast::TyU8 => u8::BITS as u64,
329+
ast::TyU16 => u16::BITS as u64,
330+
ast::TyU32 => u32::BITS as u64,
331+
ast::TyU64 => u64::BITS as u64
332+
}
333+
}
334+
283335
fn check_limits(tcx: &ty::ctxt, binop: ast::BinOp,
284336
l: &ast::Expr, r: &ast::Expr) -> bool {
285337
let (lit, expr, swap) = match (&l.node, &r.node) {

0 commit comments

Comments
 (0)