Auto merge of #23031 - Manishearth:rollup, r=Manishearth

This commit is contained in:
bors 2015-03-05 21:03:10 +00:00
commit b0746ff19b
373 changed files with 1674 additions and 1532 deletions

View File

@ -428,7 +428,8 @@ fn main() {
let guards: Vec<_> = (0..3).map(|i| {
Thread::scoped(move || {
for j in 0..3 { numbers[j] += 1 }
numbers[i] += 1;
println!("numbers[{}] is {}", i, numbers[i]);
});
}).collect();
}
@ -437,10 +438,12 @@ fn main() {
It gives us this error:
```text
7:29: 9:10 error: cannot move out of captured outer variable in an `FnMut` closure
7 Thread::scoped(move || {
8 for j in 0..3 { numbers[j] += 1 }
9 });
7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
7 Thread::scoped(move || {
8 numbers[i] += 1;
9 println!("numbers[{}] is {}", i, numbers[i]);
10 });
error: aborting due to previous error
```
It mentions that "captured outer variable in an `FnMut` closure".

View File

@ -6,8 +6,8 @@ strings, but next, let's talk about some more complicated ways of storing data.
## Tuples
The first compound data type we're going to talk about are called *tuples*.
Tuples are an ordered list of a fixed size. Like this:
The first compound data type we're going to talk about is called the *tuple*.
A tuple is an ordered list of fixed size. Like this:
```rust
let x = (1, "hello");
@ -229,7 +229,7 @@ enum Character {
```
An `enum` variant can be defined as most normal types. Below are some example
types have been listed which also would be allowed in an `enum`.
types which also would be allowed in an `enum`.
```rust
struct Empty;

View File

@ -13,7 +13,7 @@ import fileinput
import subprocess
import re
import os
from licenseck import *
from licenseck import check_license
import snapshot
err = 0
@ -22,13 +22,8 @@ cr_flag = "ignore-tidy-cr"
tab_flag = "ignore-tidy-tab"
linelength_flag = "ignore-tidy-linelength"
# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
stdout=subprocess.PIPE)
result = config_proc.communicate()[0]
true = "true".encode('utf8')
autocrlf = result.strip() == true if result is not None else False
interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
uninteresting_files = ['miniz.c', 'jquery', 'rust_android_dummy']
def report_error_name_no(name, no, s):
@ -51,6 +46,34 @@ def do_license_check(name, contents):
if not check_license(name, contents):
report_error_name_no(name, 1, "incorrect license")
def update_counts(current_name):
global file_counts
global count_other_linted_files
_, ext = os.path.splitext(current_name)
if ext in interesting_files:
file_counts[ext] += 1
else:
count_other_linted_files += 1
def interesting_file(f):
if any(x in f for x in uninteresting_files):
return False
return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc = subprocess.Popen(["git", "config", "core.autocrlf"],
stdout=subprocess.PIPE)
result = config_proc.communicate()[0]
true = "true".encode('utf8')
autocrlf = result.strip() == true if result is not None else False
current_name = ""
current_contents = ""
check_tab = True
@ -63,28 +86,16 @@ if len(sys.argv) < 2:
src_dir = sys.argv[1]
count_lines = 0
count_non_blank_lines = 0
count_other_linted_files = 0
file_counts = {ext: 0 for ext in interesting_files}
all_paths = set()
try:
count_lines = 0
count_non_blank_lines = 0
interesting_files = ['.rs', '.py', '.js', '.sh', '.c', '.h']
file_counts = {ext: 0 for ext in interesting_files}
file_counts['other'] = 0
def update_counts(current_name):
global file_counts
_, ext = os.path.splitext(current_name)
if ext in file_counts:
file_counts[ext] += 1
else:
file_counts['other'] += 1
all_paths = set()
for (dirpath, dirnames, filenames) in os.walk(src_dir):
# Skip some third-party directories
skippable_dirs = {
'src/jemalloc',
@ -103,14 +114,6 @@ try:
if any(d in dirpath for d in skippable_dirs):
continue
def interesting_file(f):
if "miniz.c" in f \
or "jquery" in f \
or "rust_android_dummy" in f:
return False
return any(os.path.splitext(f)[1] == ext for ext in interesting_files)
file_names = [os.path.join(dirpath, f) for f in filenames
if interesting_file(f)
and not f.endswith("_gen.rs")
@ -196,10 +199,11 @@ except UnicodeDecodeError as e:
report_err("UTF-8 decoding error " + str(e))
print
for ext in file_counts:
print "* linted " + str(file_counts[ext]) + " " + ext + " files"
print "* total lines of code: " + str(count_lines)
print "* total non-blank lines of code: " + str(count_non_blank_lines)
for ext in sorted(file_counts, key=file_counts.get, reverse=True):
print "* linted {} {} files".format(file_counts[ext], ext)
print "* linted {} other files".format(count_other_linted_files)
print "* total lines of code: {}".format(count_lines)
print "* total non-blank lines of code: {}".format(count_non_blank_lines)
print
sys.exit(err)

View File

@ -84,8 +84,8 @@ def fetch(f):
sys.stderr.write("cannot load %s" % f)
exit(1)
def is_valid_unicode(n):
return 0 <= n <= 0xD7FF or 0xE000 <= n <= 0x10FFFF
def is_surrogate(n):
return 0xD800 <= n <= 0xDFFF
def load_unicode_data(f):
fetch(f)
@ -96,19 +96,28 @@ def load_unicode_data(f):
canon_decomp = {}
compat_decomp = {}
udict = {};
range_start = -1;
for line in fileinput.input(f):
fields = line.split(";")
if len(fields) != 15:
data = line.split(';');
if len(data) != 15:
continue
[code, name, gencat, combine, bidi,
cp = int(data[0], 16);
if is_surrogate(cp):
continue
if range_start >= 0:
for i in xrange(range_start, cp):
udict[i] = data;
range_start = -1;
if data[1].endswith(", First>"):
range_start = cp;
continue;
udict[cp] = data;
for code in udict:
[code_org, name, gencat, combine, bidi,
decomp, deci, digit, num, mirror,
old, iso, upcase, lowcase, titlecase ] = fields
code_org = code
code = int(code, 16)
if not is_valid_unicode(code):
continue
old, iso, upcase, lowcase, titlecase ] = udict[code];
# generate char to char direct common and simple conversions
# uppercase to lowercase

View File

@ -152,6 +152,12 @@ extern char *yytext;
%precedence MOD_SEP
%precedence RARROW ':'
// In where clauses, "for" should have greater precedence when used as
// a higher ranked constraint than when used as the beginning of a
// for_in_type (which is a ty)
%precedence FORTYPE
%precedence FOR
// Binops & unops, and their precedences
%precedence BOX
%precedence BOXPLACE
@ -582,6 +588,14 @@ item_impl
{
$$ = mk_node("ItemImplNeg", 7, $1, $3, $5, $7, $8, $10, $11);
}
| maybe_unsafe IMPL generic_params trait_ref FOR DOTDOT '{' '}'
{
$$ = mk_node("ItemImplDefault", 3, $1, $3, $4);
}
| maybe_unsafe IMPL generic_params '!' trait_ref FOR DOTDOT '{' '}'
{
$$ = mk_node("ItemImplDefaultNeg", 3, $1, $3, $4);
}
;
maybe_impl_items
@ -769,10 +783,14 @@ where_predicates
;
where_predicate
: lifetime ':' bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
| ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 2, $1, $3); }
: maybe_for_lifetimes lifetime ':' bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
| maybe_for_lifetimes ty ':' ty_param_bounds { $$ = mk_node("WherePredicate", 3, $1, $2, $4); }
;
maybe_for_lifetimes
: FOR '<' lifetimes '>' { $$ = mk_none(); }
| %prec FORTYPE %empty { $$ = mk_none(); }
ty_params
: ty_param { $$ = mk_node("TyParams", 1, $1); }
| ty_params ',' ty_param { $$ = ext_node($1, 1, $3); }
@ -1024,7 +1042,8 @@ ty_qualified_path_and_generic_values
}
| ty_qualified_path ',' ty_sums maybe_bindings
{
$$ = mk_node("GenericValues", 3, mk_none(), ext_node(mk_node("TySums", 1, $1), 1, $3), $4); }
$$ = mk_node("GenericValues", 3, mk_none(), mk_node("TySums", 2, $1, $3), $4);
}
;
ty_qualified_path
@ -1513,31 +1532,35 @@ nonblock_prefix_expr
;
expr_qualified_path
: '<' ty_sum AS trait_ref '>' MOD_SEP ident
: '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident
{
$$ = mk_node("ExprQualifiedPath", 3, $2, $4, $7);
$$ = mk_node("ExprQualifiedPath", 3, $2, $3, $6);
}
| '<' ty_sum AS trait_ref '>' MOD_SEP ident generic_args
| '<' ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
$$ = mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8);
$$ = mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident
{
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12);
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident
{
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13);
$$ = mk_node("ExprQualifiedPath", 3, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident AS trait_ref '>' MOD_SEP ident generic_args
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $4, $7), $9, $12, $13);
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 3, $2, $3, $6), $7, $10, $11);
}
| SHL ty_sum AS trait_ref '>' MOD_SEP ident generic_args AS trait_ref '>' MOD_SEP ident generic_args
| SHL ty_sum maybe_as_trait_ref '>' MOD_SEP ident generic_args maybe_as_trait_ref '>' MOD_SEP ident generic_args
{
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $4, $7, $8), $10, $13, $14);
$$ = mk_node("ExprQualifiedPath", 4, mk_node("ExprQualifiedPath", 4, $2, $3, $6, $7), $8, $11, $12);
}
maybe_as_trait_ref
: AS trait_ref { $$ = $2; }
| %empty { $$ = mk_none(); }
;
lambda_expr
: %prec LAMBDA

@ -1 +1 @@
Subproject commit b001609960ca33047e5cbc5a231c1e24b6041d4b
Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922

View File

@ -42,7 +42,7 @@
//! }
//! ```
//!
//! This will print `Cons(1i32, Box(Cons(2i32, Box(Nil))))`.
//! This will print `Cons(1, Box(Cons(2, Box(Nil))))`.
#![stable(feature = "rust1", since = "1.0.0")]

View File

@ -72,13 +72,13 @@ fn test_show() {
#[test]
fn deref() {
fn homura<T: Deref<Target=i32>>(_: T) { }
homura(Box::new(765i32));
homura(Box::new(765));
}
#[test]
fn raw_sized() {
unsafe {
let x = Box::new(17i32);
let x = Box::new(17);
let p = boxed::into_raw(x);
assert_eq!(17, *p);
*p = 19;

View File

@ -118,11 +118,11 @@ fn match_words <'a,'b>(a: &'a BitVec, b: &'b BitVec) -> (MatchWords<'a>, MatchWo
// have to uselessly pretend to pad the longer one for type matching
if a_len < b_len {
(a.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(b_len).skip(a_len)),
b.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(0).skip(0)))
(a.blocks().enumerate().chain(iter::repeat(0).enumerate().take(b_len).skip(a_len)),
b.blocks().enumerate().chain(iter::repeat(0).enumerate().take(0).skip(0)))
} else {
(a.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(0).skip(0)),
b.blocks().enumerate().chain(iter::repeat(0u32).enumerate().take(a_len).skip(b_len)))
(a.blocks().enumerate().chain(iter::repeat(0).enumerate().take(0).skip(0)),
b.blocks().enumerate().chain(iter::repeat(0).enumerate().take(a_len).skip(b_len)))
}
}
@ -199,7 +199,7 @@ fn blocks_for_bits(bits: usize) -> usize {
/// Computes the bitmask for the final word of the vector
fn mask_for_bits(bits: usize) -> u32 {
// Note especially that a perfect multiple of u32::BITS should mask all 1s.
!0u32 >> (u32::BITS as usize - bits % u32::BITS as usize) % u32::BITS as usize
!0 >> (u32::BITS as usize - bits % u32::BITS as usize) % u32::BITS as usize
}
impl BitVec {
@ -275,7 +275,7 @@ impl BitVec {
pub fn from_elem(nbits: usize, bit: bool) -> BitVec {
let nblocks = blocks_for_bits(nbits);
let mut bit_vec = BitVec {
storage: repeat(if bit { !0u32 } else { 0u32 }).take(nblocks).collect(),
storage: repeat(if bit { !0 } else { 0 }).take(nblocks).collect(),
nbits: nbits
};
bit_vec.fix_last_block();
@ -330,7 +330,7 @@ impl BitVec {
}
if extra_bytes > 0 {
let mut last_word = 0u32;
let mut last_word = 0;
for (i, &byte) in bytes[complete_words*4..].iter().enumerate() {
last_word |= (reverse_bits(byte) as u32) << (i * 8);
}
@ -431,7 +431,7 @@ impl BitVec {
/// ```
#[inline]
pub fn set_all(&mut self) {
for w in &mut self.storage { *w = !0u32; }
for w in &mut self.storage { *w = !0; }
self.fix_last_block();
}
@ -566,12 +566,12 @@ impl BitVec {
/// assert_eq!(bv.all(), false);
/// ```
pub fn all(&self) -> bool {
let mut last_word = !0u32;
let mut last_word = !0;
// Check that every block but the last is all-ones...
self.blocks().all(|elem| {
let tmp = last_word;
last_word = elem;
tmp == !0u32
tmp == !0
// and then check the last one has enough ones
}) && (last_word == mask_for_bits(self.nbits))
}
@ -912,7 +912,7 @@ impl BitVec {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self) {
for w in &mut self.storage { *w = 0u32; }
for w in &mut self.storage { *w = 0; }
}
}
@ -2313,7 +2313,7 @@ mod tests {
assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), bools);
let long: Vec<_> = (0i32..10000).map(|i| i % 2 == 0).collect();
let long: Vec<_> = (0..10000).map(|i| i % 2 == 0).collect();
let bit_vec: BitVec = long.iter().map(|n| *n).collect();
assert_eq!(bit_vec.iter().collect::<Vec<bool>>(), long)
}

View File

@ -226,7 +226,7 @@
//! Some examples of the output from both traits:
//!
//! ```
//! assert_eq!(format!("{} {:?}", 3i32, 4i32), "3 4");
//! assert_eq!(format!("{} {:?}", 3, 4), "3 4");
//! assert_eq!(format!("{} {:?}", 'a', 'b'), "a 'b'");
//! assert_eq!(format!("{} {:?}", "foo\n", "bar\n"), "foo\n \"bar\\n\"");
//! ```

View File

@ -2639,7 +2639,7 @@ mod tests {
#[test]
fn test_bytes_set_memory() {
use slice::bytes::MutableByteVector;
let mut values = [1u8,2,3,4,5];
let mut values = [1,2,3,4,5];
values[0..5].set_memory(0xAB);
assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
values[2..4].set_memory(0xFF);
@ -2809,26 +2809,26 @@ mod tests {
fn test_mut_chunks() {
use core::iter::ExactSizeIterator;
let mut v = [0u8, 1, 2, 3, 4, 5, 6];
let mut v = [0, 1, 2, 3, 4, 5, 6];
assert_eq!(v.chunks_mut(2).len(), 4);
for (i, chunk) in v.chunks_mut(3).enumerate() {
for x in chunk {
*x = i as u8;
}
}
let result = [0u8, 0, 0, 1, 1, 1, 2];
let result = [0, 0, 0, 1, 1, 1, 2];
assert!(v == result);
}
#[test]
fn test_mut_chunks_rev() {
let mut v = [0u8, 1, 2, 3, 4, 5, 6];
let mut v = [0, 1, 2, 3, 4, 5, 6];
for (i, chunk) in v.chunks_mut(3).rev().enumerate() {
for x in chunk {
*x = i as u8;
}
}
let result = [2u8, 2, 2, 1, 1, 1, 0];
let result = [2, 2, 2, 1, 1, 1, 0];
assert!(v == result);
}

View File

@ -10,12 +10,15 @@
//
// ignore-lexer-test FIXME #15679
//! Unicode string manipulation (the `str` type).
//! Unicode string manipulation (the [`str`](../primitive.str.html) type).
//!
//! Rust's `str` type is one of the core primitive types of the language. `&str` is the borrowed
//! string type. This type of string can only be created from other strings, unless it is a static
//! string (see below). As the word "borrowed" implies, this type of string is owned elsewhere, and
//! this string cannot be moved out of.
//! Rust's [`str`](../primitive.str.html) type is one of the core primitive types of the
//! language. `&str` is the borrowed string type. This type of string can only be created
//! from other strings, unless it is a `&'static str` (see below). It is not possible to
//! move out of borrowed strings because they are owned elsewhere.
//!
//! Basic operations are implemented directly by the compiler, but more advanced operations are
//! defined on the [`StrExt`](trait.StrExt.html) trait.
//!
//! # Examples
//!
@ -383,7 +386,7 @@ macro_rules! utf8_first_byte {
// return the value of $ch updated with continuation byte $byte
macro_rules! utf8_acc_cont_byte {
($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32)
($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63) as u32)
}
#[stable(feature = "rust1", since = "1.0.0")]
@ -2300,8 +2303,8 @@ mod tests {
#[test]
fn test_chars_decoding() {
let mut bytes = [0u8; 4];
for c in (0u32..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let mut bytes = [0; 4];
for c in (0..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
if Some(c) != s.chars().next() {
@ -2312,8 +2315,8 @@ mod tests {
#[test]
fn test_chars_rev_decoding() {
let mut bytes = [0u8; 4];
for c in (0u32..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let mut bytes = [0; 4];
for c in (0..0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(&mut bytes).unwrap_or(0);
let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
if Some(c) != s.chars().rev().next() {

View File

@ -153,7 +153,7 @@ impl String {
}
}
const TAG_CONT_U8: u8 = 128u8;
const TAG_CONT_U8: u8 = 128;
const REPLACEMENT: &'static [u8] = b"\xEF\xBF\xBD"; // U+FFFD in UTF-8
let total = v.len();
fn unsafe_get(xs: &[u8], i: usize) -> u8 {
@ -195,14 +195,14 @@ impl String {
}
})}
if byte < 128u8 {
if byte < 128 {
// subseqidx handles this
} else {
let w = unicode_str::utf8_char_width(byte);
match w {
2 => {
if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
@ -220,7 +220,7 @@ impl String {
}
}
i += 1;
if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
@ -237,12 +237,12 @@ impl String {
}
}
i += 1;
if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
i += 1;
if safe_get(v, i, total) & 192u8 != TAG_CONT_U8 {
if safe_get(v, i, total) & 192 != TAG_CONT_U8 {
error!();
continue;
}
@ -1084,40 +1084,40 @@ mod tests {
fn test_from_utf16() {
let pairs =
[(String::from_str("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n"),
vec![0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16,
0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16,
0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16,
0xd800_u16, 0xdf30_u16, 0x000a_u16]),
vec![0xd800, 0xdf45, 0xd800, 0xdf3f,
0xd800, 0xdf3b, 0xd800, 0xdf46,
0xd800, 0xdf39, 0xd800, 0xdf3b,
0xd800, 0xdf30, 0x000a]),
(String::from_str("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n"),
vec![0xd801_u16, 0xdc12_u16, 0xd801_u16,
0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16,
0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16,
0xdc4b_u16, 0x0020_u16, 0xd801_u16, 0xdc0f_u16,
0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16,
0x000a_u16]),
vec![0xd801, 0xdc12, 0xd801,
0xdc49, 0xd801, 0xdc2e, 0xd801,
0xdc40, 0xd801, 0xdc32, 0xd801,
0xdc4b, 0x0020, 0xd801, 0xdc0f,
0xd801, 0xdc32, 0xd801, 0xdc4d,
0x000a]),
(String::from_str("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n"),
vec![0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16,
0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16,
0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16,
0x00b7_u16, 0xd800_u16, 0xdf0c_u16, 0xd800_u16,
0xdf04_u16, 0xd800_u16, 0xdf15_u16, 0xd800_u16,
0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16,
0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]),
vec![0xd800, 0xdf00, 0xd800, 0xdf16,
0xd800, 0xdf0b, 0xd800, 0xdf04,
0xd800, 0xdf11, 0xd800, 0xdf09,
0x00b7, 0xd800, 0xdf0c, 0xd800,
0xdf04, 0xd800, 0xdf15, 0xd800,
0xdf04, 0xd800, 0xdf0b, 0xd800,
0xdf09, 0xd800, 0xdf11, 0x000a ]),
(String::from_str("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n"),
vec![0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16,
0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16,
0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16,
0x0020_u16, 0xd801_u16, 0xdc95_u16, 0xd801_u16,
0xdc93_u16, 0x0020_u16, 0xd801_u16, 0xdc88_u16,
0xd801_u16, 0xdc9a_u16, 0xd801_u16, 0xdc8d_u16,
0x0020_u16, 0xd801_u16, 0xdc8f_u16, 0xd801_u16,
0xdc9c_u16, 0xd801_u16, 0xdc92_u16, 0xd801_u16,
0xdc96_u16, 0xd801_u16, 0xdc86_u16, 0x0020_u16,
0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
0x000a_u16 ]),
vec![0xd801, 0xdc8b, 0xd801, 0xdc98,
0xd801, 0xdc88, 0xd801, 0xdc91,
0xd801, 0xdc9b, 0xd801, 0xdc92,
0x0020, 0xd801, 0xdc95, 0xd801,
0xdc93, 0x0020, 0xd801, 0xdc88,
0xd801, 0xdc9a, 0xd801, 0xdc8d,
0x0020, 0xd801, 0xdc8f, 0xd801,
0xdc9c, 0xd801, 0xdc92, 0xd801,
0xdc96, 0xd801, 0xdc86, 0x0020,
0xd801, 0xdc95, 0xd801, 0xdc86,
0x000a ]),
// Issue #12318, even-numbered non-BMP planes
(String::from_str("\u{20000}"),
vec![0xD840, 0xDC00])];
@ -1303,7 +1303,7 @@ mod tests {
assert_eq!(1.to_string(), "1");
assert_eq!((-1).to_string(), "-1");
assert_eq!(200.to_string(), "200");
assert_eq!(2u8.to_string(), "2");
assert_eq!(2.to_string(), "2");
assert_eq!(true.to_string(), "true");
assert_eq!(false.to_string(), "false");
assert_eq!(("hi".to_string()).to_string(), "hi");
@ -1421,7 +1421,7 @@ mod tests {
#[bench]
fn from_utf8_lossy_100_invalid(b: &mut Bencher) {
let s = repeat(0xf5u8).take(100).collect::<Vec<_>>();
let s = repeat(0xf5).take(100).collect::<Vec<_>>();
b.iter(|| {
let _ = String::from_utf8_lossy(&s);
});

View File

@ -22,13 +22,13 @@ use option::Option;
use slice::SliceExt;
// UTF-8 ranges and tags for encoding characters
const TAG_CONT: u8 = 0b1000_0000u8;
const TAG_TWO_B: u8 = 0b1100_0000u8;
const TAG_THREE_B: u8 = 0b1110_0000u8;
const TAG_FOUR_B: u8 = 0b1111_0000u8;
const MAX_ONE_B: u32 = 0x80u32;
const MAX_TWO_B: u32 = 0x800u32;
const MAX_THREE_B: u32 = 0x10000u32;
const TAG_CONT: u8 = 0b1000_0000;
const TAG_TWO_B: u8 = 0b1100_0000;
const TAG_THREE_B: u8 = 0b1110_0000;
const TAG_FOUR_B: u8 = 0b1111_0000;
const MAX_ONE_B: u32 = 0x80;
const MAX_TWO_B: u32 = 0x800;
const MAX_THREE_B: u32 = 0x10000;
/*
Lu Uppercase_Letter an uppercase letter
@ -413,7 +413,7 @@ impl CharExt for char {
#[stable(feature = "rust1", since = "1.0.0")]
fn len_utf16(self) -> usize {
let ch = self as u32;
if (ch & 0xFFFF_u32) == ch { 1 } else { 2 }
if (ch & 0xFFFF) == ch { 1 } else { 2 }
}
#[inline]
@ -444,19 +444,19 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
dst[0] = code as u8;
Some(1)
} else if code < MAX_TWO_B && dst.len() >= 2 {
dst[0] = (code >> 6 & 0x1F_u32) as u8 | TAG_TWO_B;
dst[1] = (code & 0x3F_u32) as u8 | TAG_CONT;
dst[0] = (code >> 6 & 0x1F) as u8 | TAG_TWO_B;
dst[1] = (code & 0x3F) as u8 | TAG_CONT;
Some(2)
} else if code < MAX_THREE_B && dst.len() >= 3 {
dst[0] = (code >> 12 & 0x0F_u32) as u8 | TAG_THREE_B;
dst[1] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code & 0x3F_u32) as u8 | TAG_CONT;
dst[0] = (code >> 12 & 0x0F) as u8 | TAG_THREE_B;
dst[1] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
dst[2] = (code & 0x3F) as u8 | TAG_CONT;
Some(3)
} else if dst.len() >= 4 {
dst[0] = (code >> 18 & 0x07_u32) as u8 | TAG_FOUR_B;
dst[1] = (code >> 12 & 0x3F_u32) as u8 | TAG_CONT;
dst[2] = (code >> 6 & 0x3F_u32) as u8 | TAG_CONT;
dst[3] = (code & 0x3F_u32) as u8 | TAG_CONT;
dst[0] = (code >> 18 & 0x07) as u8 | TAG_FOUR_B;
dst[1] = (code >> 12 & 0x3F) as u8 | TAG_CONT;
dst[2] = (code >> 6 & 0x3F) as u8 | TAG_CONT;
dst[3] = (code & 0x3F) as u8 | TAG_CONT;
Some(4)
} else {
None
@ -472,15 +472,15 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option<usize> {
#[unstable(feature = "core")]
pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option<usize> {
// Marked #[inline] to allow llvm optimizing it away
if (ch & 0xFFFF_u32) == ch && dst.len() >= 1 {
if (ch & 0xFFFF) == ch && dst.len() >= 1 {
// The BMP falls through (assuming non-surrogate, as it should)
dst[0] = ch as u16;
Some(1)
} else if dst.len() >= 2 {
// Supplementary planes break into surrogates.
ch -= 0x1_0000_u32;
dst[0] = 0xD800_u16 | ((ch >> 10) as u16);
dst[1] = 0xDC00_u16 | ((ch as u16) & 0x3FF_u16);
ch -= 0x1_0000;
dst[0] = 0xD800 | ((ch >> 10) as u16);
dst[1] = 0xDC00 | ((ch as u16) & 0x3FF);
Some(2)
} else {
None

View File

@ -123,13 +123,13 @@ pub fn float_to_str_bytes_common<T: Float, U, F>(
// For an f64 the exponent is in the range of [-1022, 1023] for base 2, so
// we may have up to that many digits. Give ourselves some extra wiggle room
// otherwise as well.
let mut buf = [0u8; 1536];
let mut buf = [0; 1536];
let mut end = 0;
let radix_gen: T = cast(radix as int).unwrap();
let (num, exp) = match exp_format {
ExpNone => (num, 0i32),
ExpDec if num == _0 => (num, 0i32),
ExpNone => (num, 0),
ExpDec if num == _0 => (num, 0),
ExpDec => {
let (exp, exp_base) = match exp_format {
ExpDec => (num.abs().log10().floor(), cast::<f64, T>(10.0f64).unwrap()),

View File

@ -565,7 +565,7 @@ impl<'a> Formatter<'a> {
Alignment::Center => (padding / 2, (padding + 1) / 2),
};
let mut fill = [0u8; 4];
let mut fill = [0; 4];
let len = self.fill.encode_utf8(&mut fill).unwrap_or(0);
let fill = unsafe { str::from_utf8_unchecked(&fill[..len]) };
@ -689,7 +689,7 @@ impl Debug for char {
#[stable(feature = "rust1", since = "1.0.0")]
impl Display for char {
fn fmt(&self, f: &mut Formatter) -> Result {
let mut utf8 = [0u8; 4];
let mut utf8 = [0; 4];
let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
let s: &str = unsafe { mem::transmute(&utf8[..amt]) };
Display::fmt(s, f)

View File

@ -38,7 +38,7 @@ trait GenericRadix {
// characters for a base 2 number.
let zero = Int::zero();
let is_positive = x >= zero;
let mut buf = [0u8; 64];
let mut buf = [0; 64];
let mut curr = buf.len();
let base = cast(self.base()).unwrap();
if is_positive {

View File

@ -60,7 +60,7 @@ macro_rules! u8to64_le {
($buf:expr, $i:expr, $len:expr) =>
({
let mut t = 0;
let mut out = 0u64;
let mut out = 0;
while t < $len {
out |= ($buf[t+$i] as u64) << t*8;
t += 1;

View File

@ -230,7 +230,7 @@ extern "rust-intrinsic" {
/// use std::mem;
///
/// let v: &[u8] = unsafe { mem::transmute("L") };
/// assert!(v == [76u8]);
/// assert!(v == [76]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn transmute<T,U>(e: T) -> U;

View File

@ -1149,7 +1149,7 @@ pub trait AdditiveIterator<A> {
/// ```
/// use std::iter::AdditiveIterator;
///
/// let a = [1i32, 2, 3, 4, 5];
/// let a = [1, 2, 3, 4, 5];
/// let mut it = a.iter().cloned();
/// assert!(it.sum() == 15);
/// ```

View File

@ -227,7 +227,7 @@ macro_rules! writeln {
///
/// ```rust
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
/// for i in std::iter::count(0_u32, 1) {
/// for i in std::iter::count(0, 1) {
/// if 3*i < i { panic!("u32 overflow"); }
/// if x < 3*i { return i-1; }
/// }

View File

@ -913,6 +913,7 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize }
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Index<Idx: ?Sized> {
/// The returned type after indexing
#[stable(feature = "rust1", since = "1.0.0")]
type Output: ?Sized;
/// The method for the indexing (`Foo[Bar]`) operation

View File

@ -385,7 +385,7 @@ impl<T> Option<T> {
/// # Example
///
/// ```
/// let k = 10i32;
/// let k = 10;
/// assert_eq!(Some(4).unwrap_or_else(|| 2 * k), 4);
/// assert_eq!(None.unwrap_or_else(|| 2 * k), 20);
/// ```

View File

@ -1119,9 +1119,9 @@ pub struct CharRange {
}
/// Mask of the value bits of a continuation byte
const CONT_MASK: u8 = 0b0011_1111u8;
const CONT_MASK: u8 = 0b0011_1111;
/// Value of the tag bits (tag mask is !CONT_MASK) of a continuation byte
const TAG_CONT_U8: u8 = 0b1000_0000u8;
const TAG_CONT_U8: u8 = 0b1000_0000;
/*
Section: Trait implementations
@ -1568,7 +1568,7 @@ impl StrExt for str {
if index == self.len() { return true; }
match self.as_bytes().get(index) {
None => false,
Some(&b) => b < 128u8 || b >= 192u8,
Some(&b) => b < 128 || b >= 192,
}
}
@ -1680,7 +1680,7 @@ impl StrExt for str {
#[inline]
#[unstable(feature = "core")]
pub fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) {
if bytes[i] < 128u8 {
if bytes[i] < 128 {
return (bytes[i] as u32, i + 1);
}

View File

@ -165,7 +165,7 @@ fn test_escape_unicode() {
#[test]
fn test_encode_utf8() {
fn check(input: char, expect: &[u8]) {
let mut buf = [0u8; 4];
let mut buf = [0; 4];
let n = input.encode_utf8(&mut buf).unwrap_or(0);
assert_eq!(&buf[..n], expect);
}
@ -179,7 +179,7 @@ fn test_encode_utf8() {
#[test]
fn test_encode_utf16() {
fn check(input: char, expect: &[u16]) {
let mut buf = [0u16; 2];
let mut buf = [0; 2];
let n = input.encode_utf16(&mut buf).unwrap_or(0);
assert_eq!(&buf[..n], expect);
}

View File

@ -62,10 +62,10 @@ fn test_writer_hasher() {
// FIXME (#18283) Enable test
//let s: Box<str> = box "a";
//assert_eq!(hasher.hash(& s), 97 + 0xFF);
let cs: &[u8] = &[1u8, 2u8, 3u8];
let cs: &[u8] = &[1, 2, 3];
assert_eq!(hash(& cs), 9);
// FIXME (#22405): Replace `Box::new` with `box` here when/if possible.
let cs: Box<[u8]> = Box::new([1u8, 2u8, 3u8]);
let cs: Box<[u8]> = Box::new([1, 2, 3]);
assert_eq!(hash(& cs), 9);
// FIXME (#18248) Add tests for hashing Rc<str> and Rc<[T]>

View File

@ -100,8 +100,8 @@ fn test_siphash() {
[ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, ]
];
let k0 = 0x_07_06_05_04_03_02_01_00_u64;
let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08_u64;
let k0 = 0x_07_06_05_04_03_02_01_00;
let k1 = 0x_0f_0e_0d_0c_0b_0a_09_08;
let mut buf = Vec::new();
let mut t = 0;
let mut state_inc = SipState::new_with_keys(k0, k1);
@ -230,8 +230,8 @@ fn test_hash_no_concat_alias() {
assert!(s != t && t != u);
assert!(hash(&s) != hash(&t) && hash(&s) != hash(&u));
let v: (&[u8], &[u8], &[u8]) = (&[1u8], &[0u8, 0], &[0u8]);
let w: (&[u8], &[u8], &[u8]) = (&[1u8, 0, 0, 0], &[], &[]);
let v: (&[u8], &[u8], &[u8]) = (&[1], &[0, 0], &[0]);
let w: (&[u8], &[u8], &[u8]) = (&[1, 0, 0, 0], &[], &[]);
assert!(v != w);
assert!(hash(&v) != hash(&w));

View File

@ -778,9 +778,9 @@ fn test_range_step() {
assert_eq!(range_step(0, 20, 5).collect::<Vec<int>>(), [0, 5, 10, 15]);
assert_eq!(range_step(20, 0, -5).collect::<Vec<int>>(), [20, 15, 10, 5]);
assert_eq!(range_step(20, 0, -6).collect::<Vec<int>>(), [20, 14, 8, 2]);
assert_eq!(range_step(200u8, 255, 50).collect::<Vec<u8>>(), [200u8, 250]);
assert_eq!(range_step(200i, -5, 1).collect::<Vec<int>>(), []);
assert_eq!(range_step(200i, 200, 1).collect::<Vec<int>>(), []);
assert_eq!(range_step(200, 255, 50).collect::<Vec<u8>>(), [200, 250]);
assert_eq!(range_step(200, -5, 1).collect::<Vec<int>>(), []);
assert_eq!(range_step(200, 200, 1).collect::<Vec<int>>(), []);
}
#[test]
@ -788,7 +788,7 @@ fn test_range_step_inclusive() {
assert_eq!(range_step_inclusive(0, 20, 5).collect::<Vec<int>>(), [0, 5, 10, 15, 20]);
assert_eq!(range_step_inclusive(20, 0, -5).collect::<Vec<int>>(), [20, 15, 10, 5, 0]);
assert_eq!(range_step_inclusive(20, 0, -6).collect::<Vec<int>>(), [20, 14, 8, 2]);
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>(), [200u8, 250]);
assert_eq!(range_step_inclusive(200, 255, 50).collect::<Vec<u8>>(), [200, 250]);
assert_eq!(range_step_inclusive(200, -5, 1).collect::<Vec<int>>(), []);
assert_eq!(range_step_inclusive(200, 200, 1).collect::<Vec<int>>(), [200]);
}

View File

@ -103,7 +103,7 @@ fn test_transmute() {
}
unsafe {
assert_eq!([76u8], transmute::<_, Vec<u8>>("L".to_string()));
assert_eq!([76], transmute::<_, Vec<u8>>("L".to_string()));
}
}

View File

@ -88,7 +88,7 @@ mod test {
#[test]
fn test_int_from_str_overflow() {
let mut i8_val: i8 = 127_i8;
let mut i8_val: i8 = 127;
assert_eq!("127".parse::<i8>().ok(), Some(i8_val));
assert_eq!("128".parse::<i8>().ok(), None);
@ -96,7 +96,7 @@ mod test {
assert_eq!("-128".parse::<i8>().ok(), Some(i8_val));
assert_eq!("-129".parse::<i8>().ok(), None);
let mut i16_val: i16 = 32_767_i16;
let mut i16_val: i16 = 32_767;
assert_eq!("32767".parse::<i16>().ok(), Some(i16_val));
assert_eq!("32768".parse::<i16>().ok(), None);
@ -104,7 +104,7 @@ mod test {
assert_eq!("-32768".parse::<i16>().ok(), Some(i16_val));
assert_eq!("-32769".parse::<i16>().ok(), None);
let mut i32_val: i32 = 2_147_483_647_i32;
let mut i32_val: i32 = 2_147_483_647;
assert_eq!("2147483647".parse::<i32>().ok(), Some(i32_val));
assert_eq!("2147483648".parse::<i32>().ok(), None);
@ -112,7 +112,7 @@ mod test {
assert_eq!("-2147483648".parse::<i32>().ok(), Some(i32_val));
assert_eq!("-2147483649".parse::<i32>().ok(), None);
let mut i64_val: i64 = 9_223_372_036_854_775_807_i64;
let mut i64_val: i64 = 9_223_372_036_854_775_807;
assert_eq!("9223372036854775807".parse::<i64>().ok(), Some(i64_val));
assert_eq!("9223372036854775808".parse::<i64>().ok(), None);

View File

@ -139,12 +139,12 @@ fn test_ptr_addition() {
fn test_ptr_subtraction() {
unsafe {
let xs = vec![0,1,2,3,4,5,6,7,8,9];
let mut idx = 9i8;
let mut idx = 9;
let ptr = xs.as_ptr();
while idx >= 0i8 {
while idx >= 0 {
assert_eq!(*(ptr.offset(idx as int)), idx as int);
idx = idx - 1i8;
idx = idx - 1;
}
let mut xs_mut = xs;

View File

@ -10,13 +10,10 @@
#![crate_name = "libc"]
#![crate_type = "rlib"]
#![cfg_attr(not(feature = "cargo-build"),
unstable(feature = "libc"))]
#![cfg_attr(not(feature = "cargo-build"), feature(staged_api))]
#![cfg_attr(not(feature = "cargo-build"), unstable(feature = "libc"))]
#![cfg_attr(not(feature = "cargo-build"), feature(staged_api, core, no_std))]
#![cfg_attr(not(feature = "cargo-build"), staged_api)]
#![cfg_attr(not(feature = "cargo-build"), feature(core))]
#![feature(no_std)]
#![no_std]
#![cfg_attr(not(feature = "cargo-build"), no_std)]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
@ -2203,11 +2200,11 @@ pub mod consts {
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 4;
pub const _IOLBF : c_int = 64;
pub const BUFSIZ : c_uint = 512_u32;
pub const FOPEN_MAX : c_uint = 20_u32;
pub const FILENAME_MAX : c_uint = 260_u32;
pub const L_tmpnam : c_uint = 16_u32;
pub const TMP_MAX : c_uint = 32767_u32;
pub const BUFSIZ : c_uint = 512;
pub const FOPEN_MAX : c_uint = 20;
pub const FILENAME_MAX : c_uint = 260;
pub const L_tmpnam : c_uint = 16;
pub const TMP_MAX : c_uint = 32767;
pub const WSAEINTR: c_int = 10004;
pub const WSAEBADF: c_int = 10009;
@ -2584,11 +2581,11 @@ pub mod consts {
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
pub const BUFSIZ : c_uint = 8192_u32;
pub const FOPEN_MAX : c_uint = 16_u32;
pub const FILENAME_MAX : c_uint = 4096_u32;
pub const L_tmpnam : c_uint = 20_u32;
pub const TMP_MAX : c_uint = 238328_u32;
pub const BUFSIZ : c_uint = 8192;
pub const FOPEN_MAX : c_uint = 16;
pub const FILENAME_MAX : c_uint = 4096;
pub const L_tmpnam : c_uint = 20;
pub const TMP_MAX : c_uint = 238328;
}
pub mod c99 {
}
@ -3450,11 +3447,11 @@ pub mod consts {
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
pub const BUFSIZ : c_uint = 1024_u32;
pub const FOPEN_MAX : c_uint = 20_u32;
pub const FILENAME_MAX : c_uint = 1024_u32;
pub const L_tmpnam : c_uint = 1024_u32;
pub const TMP_MAX : c_uint = 308915776_u32;
pub const BUFSIZ : c_uint = 1024;
pub const FOPEN_MAX : c_uint = 20;
pub const FILENAME_MAX : c_uint = 1024;
pub const L_tmpnam : c_uint = 1024;
pub const TMP_MAX : c_uint = 308915776;
}
pub mod c99 {
}
@ -3858,11 +3855,11 @@ pub mod consts {
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
pub const BUFSIZ : c_uint = 1024_u32;
pub const FOPEN_MAX : c_uint = 20_u32;
pub const FILENAME_MAX : c_uint = 1024_u32;
pub const L_tmpnam : c_uint = 1024_u32;
pub const TMP_MAX : c_uint = 308915776_u32;
pub const BUFSIZ : c_uint = 1024;
pub const FOPEN_MAX : c_uint = 20;
pub const FILENAME_MAX : c_uint = 1024;
pub const L_tmpnam : c_uint = 1024;
pub const TMP_MAX : c_uint = 308915776;
}
pub mod c99 {
}
@ -4236,11 +4233,11 @@ pub mod consts {
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
pub const BUFSIZ : c_uint = 1024_u32;
pub const FOPEN_MAX : c_uint = 20_u32;
pub const FILENAME_MAX : c_uint = 1024_u32;
pub const L_tmpnam : c_uint = 1024_u32;
pub const TMP_MAX : c_uint = 308915776_u32;
pub const BUFSIZ : c_uint = 1024;
pub const FOPEN_MAX : c_uint = 20;
pub const FILENAME_MAX : c_uint = 1024;
pub const L_tmpnam : c_uint = 1024;
pub const TMP_MAX : c_uint = 308915776;
}
pub mod c99 {
}

View File

@ -173,7 +173,7 @@ impl<'a> SeedableRng<&'a [u32]> for ChaChaRng {
fn reseed(&mut self, seed: &'a [u32]) {
// reset state
self.init(&[0u32; KEY_WORDS]);
self.init(&[0; KEY_WORDS]);
// set key in place
let key = &mut self.state[4 .. 4+KEY_WORDS];
for (k, s) in key.iter_mut().zip(seed.iter()) {
@ -245,7 +245,7 @@ mod test {
fn test_rng_true_values() {
// Test vectors 1 and 2 from
// http://tools.ietf.org/html/draft-nir-cfrg-chacha20-poly1305-04
let seed : &[_] = &[0u32; 8];
let seed : &[_] = &[0; 8];
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
let v = (0..16).map(|_| ra.next_u32()).collect::<Vec<_>>();
@ -285,7 +285,7 @@ mod test {
#[test]
fn test_rng_clone() {
let seed : &[_] = &[0u32; 8];
let seed : &[_] = &[0; 8];
let mut rng: ChaChaRng = SeedableRng::from_seed(seed);
let mut clone = rng.clone();
for _ in 0..16 {

View File

@ -23,8 +23,8 @@ use distributions::{Sample, IndependentSample};
///
/// This gives a uniform distribution (assuming the RNG used to sample
/// it is itself uniform & the `SampleRange` implementation for the
/// given type is correct), even for edge cases like `low = 0u8`,
/// `high = 170u8`, for which a naive modulo operation would return
/// given type is correct), even for edge cases like `low = 0`,
/// `high = 170`, for which a naive modulo operation would return
/// numbers less than 85 with double the probability to those greater
/// than 85.
///

View File

@ -217,7 +217,7 @@ impl<'a> SeedableRng<&'a [u32]> for IsaacRng {
fn reseed(&mut self, seed: &'a [u32]) {
// make the seed into [seed[0], seed[1], ..., seed[seed.len()
// - 1], 0, 0, ...], to fill rng.rsl.
let seed_iter = seed.iter().cloned().chain(repeat(0u32));
let seed_iter = seed.iter().cloned().chain(repeat(0));
for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
*rsl_elem = seed_elem;
@ -460,7 +460,7 @@ impl<'a> SeedableRng<&'a [u64]> for Isaac64Rng {
fn reseed(&mut self, seed: &'a [u64]) {
// make the seed into [seed[0], seed[1], ..., seed[seed.len()
// - 1], 0, 0, ...], to fill rng.rsl.
let seed_iter = seed.iter().cloned().chain(repeat(0u64));
let seed_iter = seed.iter().cloned().chain(repeat(0));
for (rsl_elem, seed_elem) in self.rsl.iter_mut().zip(seed_iter) {
*rsl_elem = seed_elem;

View File

@ -149,7 +149,7 @@ pub trait Rng : Sized {
/// ```rust
/// use std::rand::{thread_rng, Rng};
///
/// let mut v = [0u8; 13579];
/// let mut v = [0; 13579];
/// thread_rng().fill_bytes(&mut v);
/// println!("{:?}", v.as_slice());
/// ```

View File

@ -215,7 +215,7 @@ mod test {
const FILL_BYTES_V_LEN: uint = 13579;
#[test]
fn test_rng_fill_bytes() {
let mut v = repeat(0u8).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
let mut v = repeat(0).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();
::test::rng().fill_bytes(&mut v);
// Sanity test: if we've gotten here, `fill_bytes` has not infinitely

View File

@ -290,22 +290,22 @@ pub mod reader {
#[inline(never)]
fn vuint_at_slow(data: &[u8], start: uint) -> DecodeResult<Res> {
let a = data[start];
if a & 0x80u8 != 0u8 {
return Ok(Res {val: (a & 0x7fu8) as uint, next: start + 1});
if a & 0x80 != 0 {
return Ok(Res {val: (a & 0x7f) as uint, next: start + 1});
}
if a & 0x40u8 != 0u8 {
return Ok(Res {val: ((a & 0x3fu8) as uint) << 8 |
if a & 0x40 != 0 {
return Ok(Res {val: ((a & 0x3f) as uint) << 8 |
(data[start + 1] as uint),
next: start + 2});
}
if a & 0x20u8 != 0u8 {
return Ok(Res {val: ((a & 0x1fu8) as uint) << 16 |
if a & 0x20 != 0 {
return Ok(Res {val: ((a & 0x1f) as uint) << 16 |
(data[start + 1] as uint) << 8 |
(data[start + 2] as uint),
next: start + 3});
}
if a & 0x10u8 != 0u8 {
return Ok(Res {val: ((a & 0x0fu8) as uint) << 24 |
if a & 0x10 != 0 {
return Ok(Res {val: ((a & 0x0f) as uint) << 24 |
(data[start + 1] as uint) << 16 |
(data[start + 2] as uint) << 8 |
(data[start + 3] as uint),
@ -877,11 +877,11 @@ pub mod writer {
fn write_sized_vuint<W: Writer>(w: &mut W, n: uint, size: uint) -> EncodeResult {
match size {
1 => w.write_all(&[0x80u8 | (n as u8)]),
2 => w.write_all(&[0x40u8 | ((n >> 8) as u8), n as u8]),
3 => w.write_all(&[0x20u8 | ((n >> 16) as u8), (n >> 8) as u8,
1 => w.write_all(&[0x80 | (n as u8)]),
2 => w.write_all(&[0x40 | ((n >> 8) as u8), n as u8]),
3 => w.write_all(&[0x20 | ((n >> 16) as u8), (n >> 8) as u8,
n as u8]),
4 => w.write_all(&[0x10u8 | ((n >> 24) as u8), (n >> 16) as u8,
4 => w.write_all(&[0x10 | ((n >> 24) as u8), (n >> 16) as u8,
(n >> 8) as u8, n as u8]),
_ => Err(old_io::IoError {
kind: old_io::OtherIoError,
@ -930,7 +930,7 @@ pub mod writer {
// Write a placeholder four-byte size.
self.size_positions.push(try!(self.writer.tell()) as uint);
let zeroes: &[u8] = &[0u8, 0u8, 0u8, 0u8];
let zeroes: &[u8] = &[0, 0, 0, 0];
self.writer.write_all(zeroes)
}
@ -1422,9 +1422,9 @@ mod bench {
#[bench]
pub fn vuint_at_A_aligned(b: &mut Bencher) {
let data = (0i32..4*100).map(|i| {
let data = (0..4*100).map(|i| {
match i % 2 {
0 => 0x80u8,
0 => 0x80,
_ => i as u8,
}
}).collect::<Vec<_>>();
@ -1440,9 +1440,9 @@ mod bench {
#[bench]
pub fn vuint_at_A_unaligned(b: &mut Bencher) {
let data = (0i32..4*100+1).map(|i| {
let data = (0..4*100+1).map(|i| {
match i % 2 {
1 => 0x80u8,
1 => 0x80,
_ => i as u8
}
}).collect::<Vec<_>>();
@ -1458,11 +1458,11 @@ mod bench {
#[bench]
pub fn vuint_at_D_aligned(b: &mut Bencher) {
let data = (0i32..4*100).map(|i| {
let data = (0..4*100).map(|i| {
match i % 4 {
0 => 0x10u8,
0 => 0x10,
3 => i as u8,
_ => 0u8
_ => 0
}
}).collect::<Vec<_>>();
let mut sum = 0;
@ -1477,11 +1477,11 @@ mod bench {
#[bench]
pub fn vuint_at_D_unaligned(b: &mut Bencher) {
let data = (0i32..4*100+1).map(|i| {
let data = (0..4*100+1).map(|i| {
match i % 4 {
1 => 0x10u8,
1 => 0x10,
0 => i as u8,
_ => 0u8
_ => 0
}
}).collect::<Vec<_>>();
let mut sum = 0;

View File

@ -354,7 +354,7 @@ impl<'a> Context<'a> {
}
}
if self.rejected_via_kind.len() > 0 {
self.sess.span_help(self.span, "please recompile this crate using \
self.sess.fileline_help(self.span, "please recompile this crate using \
--crate-type lib");
let mismatches = self.rejected_via_kind.iter();
for (i, &CrateMismatch { ref path, .. }) in mismatches.enumerate() {

View File

@ -84,7 +84,7 @@ impl<'a, 'v> Visitor<'v> for MacroLoader<'a> {
}
"plugin" => {
self.sess.span_err(attr.span, "#[plugin] on `extern crate` is deprecated");
self.sess.span_help(attr.span, &format!("use a crate attribute instead, \
self.sess.fileline_help(attr.span, &format!("use a crate attribute instead, \
i.e. #![plugin({})]",
item.ident.as_str()));
}

View File

@ -246,7 +246,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
"pattern binding `{}` is named the same as one \
of the variants of the type `{}`",
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
span_help!(cx.tcx.sess, p.span,
fileline_help!(cx.tcx.sess, p.span,
"if you meant to match on a variant, \
consider making the path in the pattern qualified: `{}::{}`",
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));

View File

@ -537,7 +537,7 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
ast::ExprBlock(ref block) => {
match block.expr {
Some(ref expr) => try!(eval_const_expr_partial(tcx, &**expr, ety)),
None => const_int(0i64)
None => const_int(0)
}
}
ast::ExprTupField(ref base, index) => {

View File

@ -444,7 +444,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
// Does the required lifetime have a nice name we can print?
span_err!(self.tcx.sess, origin.span(), E0309,
"{} may not live long enough", labeled_user_string);
self.tcx.sess.span_help(
self.tcx.sess.fileline_help(
origin.span(),
&format!(
"consider adding an explicit lifetime bound `{}: {}`...",
@ -456,7 +456,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
// Does the required lifetime have a nice name we can print?
span_err!(self.tcx.sess, origin.span(), E0310,
"{} may not live long enough", labeled_user_string);
self.tcx.sess.span_help(
self.tcx.sess.fileline_help(
origin.span(),
&format!(
"consider adding an explicit lifetime bound `{}: 'static`...",
@ -468,7 +468,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
span_err!(self.tcx.sess, origin.span(), E0311,
"{} may not live long enough",
labeled_user_string);
self.tcx.sess.span_help(
self.tcx.sess.fileline_help(
origin.span(),
&format!(
"consider adding an explicit lifetime bound for `{}`",

View File

@ -45,7 +45,7 @@ pub fn lev_distance(me: &str, t: &str) -> uint {
fn test_lev_distance() {
use std::char::{ from_u32, MAX };
// Test bytelength agnosticity
for c in (0u32..MAX as u32)
for c in (0..MAX as u32)
.filter_map(|i| from_u32(i))
.map(|i| i.to_string()) {
assert_eq!(lev_distance(&c[..], &c[..]), 0);

View File

@ -119,7 +119,7 @@ impl FixedBuffer64 {
/// Create a new FixedBuffer64
fn new() -> FixedBuffer64 {
return FixedBuffer64 {
buffer: [0u8; 64],
buffer: [0; 64],
buffer_idx: 0
};
}
@ -258,7 +258,7 @@ pub trait Digest {
/// Convenience function that retrieves the result of a digest as a
/// newly allocated vec of bytes.
fn result_bytes(&mut self) -> Vec<u8> {
let mut buf: Vec<u8> = repeat(0u8).take((self.output_bits()+7)/8).collect();
let mut buf: Vec<u8> = repeat(0).take((self.output_bits()+7)/8).collect();
self.result(&mut buf);
buf
}
@ -342,7 +342,7 @@ impl Engine256State {
let mut g = self.h6;
let mut h = self.h7;
let mut w = [0u32; 64];
let mut w = [0; 64];
// Sha-512 and Sha-256 use basically the same calculations which are implemented
// by these macros. Inlining the calculations seems to result in better generated code.
@ -660,7 +660,7 @@ mod bench {
#[bench]
pub fn sha256_10(b: &mut Bencher) {
let mut sh = Sha256::new();
let bytes = [1u8; 10];
let bytes = [1; 10];
b.iter(|| {
sh.input(&bytes);
});
@ -670,7 +670,7 @@ mod bench {
#[bench]
pub fn sha256_1k(b: &mut Bencher) {
let mut sh = Sha256::new();
let bytes = [1u8; 1024];
let bytes = [1; 1024];
b.iter(|| {
sh.input(&bytes);
});
@ -680,7 +680,7 @@ mod bench {
#[bench]
pub fn sha256_64k(b: &mut Bencher) {
let mut sh = Sha256::new();
let bytes = [1u8; 65536];
let bytes = [1; 65536];
b.iter(|| {
sh.input(&bytes);
});

View File

@ -316,7 +316,7 @@ mod tests {
bitflags! {
flags AnotherSetOfFlags: i8 {
const AnotherFlag = -1_i8,
const AnotherFlag = -1,
}
}
@ -327,7 +327,7 @@ mod tests {
assert_eq!(FlagABC.bits(), 0b00000111);
assert_eq!(AnotherSetOfFlags::empty().bits(), 0b00);
assert_eq!(AnotherFlag.bits(), !0_i8);
assert_eq!(AnotherFlag.bits(), !0);
}
#[test]
@ -338,7 +338,7 @@ mod tests {
assert!(Flags::from_bits(0b11) == Some(FlagA | FlagB));
assert!(Flags::from_bits(0b1000) == None);
assert!(AnotherSetOfFlags::from_bits(!0_i8) == Some(AnotherFlag));
assert!(AnotherSetOfFlags::from_bits(!0) == Some(AnotherFlag));
}
#[test]
@ -350,7 +350,7 @@ mod tests {
assert!(Flags::from_bits_truncate(0b1000) == Flags::empty());
assert!(Flags::from_bits_truncate(0b1001) == FlagA);
assert!(AnotherSetOfFlags::from_bits_truncate(0_i8) == AnotherSetOfFlags::empty());
assert!(AnotherSetOfFlags::from_bits_truncate(0) == AnotherSetOfFlags::empty());
}
#[test]

View File

@ -165,7 +165,7 @@ fn note_move_destination(bccx: &BorrowckCtxt,
bccx.span_note(
move_to_span,
"attempting to move value to here");
bccx.span_help(
bccx.fileline_help(
move_to_span,
&format!("to prevent the move, \
use `ref {0}` or `ref mut {0}` to capture value by \

View File

@ -643,7 +643,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
ol,
moved_lp_msg,
pat_ty.user_string(self.tcx)));
self.tcx.sess.span_help(span,
self.tcx.sess.fileline_help(span,
"use `ref` to override");
}
@ -675,7 +675,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
moved_lp_msg,
expr_ty.user_string(self.tcx),
suggestion));
self.tcx.sess.span_help(expr_span, help);
self.tcx.sess.fileline_help(expr_span, help);
}
}
@ -741,6 +741,10 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
self.tcx.sess.span_help(s, m);
}
pub fn fileline_help(&self, s: Span, m: &str) {
self.tcx.sess.fileline_help(s, m);
}
pub fn bckerr_to_string(&self, err: &BckError<'tcx>) -> String {
match err.code {
err_mutbl => {
@ -870,7 +874,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
if is_closure {
self.tcx.sess.span_help(
self.tcx.sess.fileline_help(
span,
"closures behind references must be called via `&mut`");
}

View File

@ -1921,7 +1921,8 @@ impl LintPass for UnconditionalRecursion {
for call in &self_call_spans {
sess.span_note(*call, "recursive call site")
}
sess.span_help(sp, "a `loop` may express intention better if this is on purpose")
sess.fileline_help(sp, "a `loop` may express intention \
better if this is on purpose")
}
}

View File

@ -4115,10 +4115,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
uses it like a function name",
path_name));
self.session.span_help(expr.span,
&format!("Did you mean to write: \
`{} {{ /* fields */ }}`?",
path_name));
let msg = format!("Did you mean to write: \
`{} {{ /* fields */ }}`?",
path_name);
if self.emit_errors {
self.session.fileline_help(expr.span, &msg);
} else {
self.session.span_help(expr.span, &msg);
}
} else {
// Write the result into the def map.
debug!("(resolving expr) resolved `{}`",
@ -4146,18 +4150,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
match type_res.map(|r| r.base_def) {
Some(DefTy(struct_id, _))
if self.structs.contains_key(&struct_id) => {
self.resolve_error(expr.span,
self.resolve_error(expr.span,
&format!("`{}` is a structure name, but \
this expression \
uses it like a function name",
path_name));
self.session.span_help(expr.span,
&format!("Did you mean to write: \
`{} {{ /* fields */ }}`?",
path_name));
}
let msg = format!("Did you mean to write: \
`{} {{ /* fields */ }}`?",
path_name);
if self.emit_errors {
self.session.fileline_help(expr.span, &msg);
} else {
self.session.span_help(expr.span, &msg);
}
}
_ => {
// Keep reporting some errors even if they're ignored above.
self.resolve_path(expr.id, path, 0, ValueNS, true);

View File

@ -833,11 +833,11 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
let (is_zero, is_signed) = match rhs_t.sty {
ty::ty_int(t) => {
let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0u64, false);
let zero = C_integral(Type::int_from_ty(cx.ccx(), t), 0, false);
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), true)
}
ty::ty_uint(t) => {
let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0u64, false);
let zero = C_integral(Type::uint_from_ty(cx.ccx(), t), 0, false);
(ICmp(cx, llvm::IntEQ, rhs, zero, debug_loc), false)
}
_ => {

View File

@ -117,7 +117,7 @@ fn classify_arg_ty(ccx: &CrateContext, ty: Type) -> ArgType {
let size = ty_size(ty);
if size <= 16 {
let llty = if size == 0 {
Type::array(&Type::i64(ccx), 0u64)
Type::array(&Type::i64(ccx), 0)
} else if size == 1 {
Type::i8(ccx)
} else if size == 2 {

View File

@ -440,7 +440,7 @@ fn gate_simd_ffi(tcx: &ty::ctxt, decl: &ast::FnDecl, ty: &ty::BareFnTy) {
&format!("use of SIMD type `{}` in FFI is highly experimental and \
may result in invalid code",
pprust::ty_to_string(ast_ty)));
tcx.sess.span_help(ast_ty.span,
tcx.sess.fileline_help(ast_ty.span,
"add #![feature(simd_ffi)] to the crate attributes to enable");
}
};

View File

@ -229,18 +229,18 @@ pub fn opt_ast_region_to_region<'tcx>(
}
}
if len == 1 {
span_help!(this.tcx().sess, default_span,
fileline_help!(this.tcx().sess, default_span,
"this function's return type contains a borrowed value, but \
the signature does not say which {} it is borrowed from",
m);
} else if len == 0 {
span_help!(this.tcx().sess, default_span,
fileline_help!(this.tcx().sess, default_span,
"this function's return type contains a borrowed value, but \
there is no value for it to be borrowed from");
span_help!(this.tcx().sess, default_span,
fileline_help!(this.tcx().sess, default_span,
"consider giving it a 'static lifetime");
} else {
span_help!(this.tcx().sess, default_span,
fileline_help!(this.tcx().sess, default_span,
"this function's return type contains a borrowed value, but \
the signature does not say whether it is borrowed from {}",
m);
@ -722,7 +722,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
span_err!(this.tcx().sess, span, E0215,
"angle-bracket notation is not stable when \
used with the `Fn` family of traits, use parentheses");
span_help!(this.tcx().sess, span,
fileline_help!(this.tcx().sess, span,
"add `#![feature(unboxed_closures)]` to \
the crate attributes to enable");
}
@ -736,7 +736,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
span_err!(this.tcx().sess, span, E0216,
"parenthetical notation is only stable when \
used with the `Fn` family of traits");
span_help!(this.tcx().sess, span,
fileline_help!(this.tcx().sess, span,
"add `#![feature(unboxed_closures)]` to \
the crate attributes to enable");
}
@ -963,14 +963,14 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>,
pprust::ty_to_string(ty));
match ty.node {
ast::TyRptr(None, ref mut_ty) => {
span_help!(this.tcx().sess, ty.span,
fileline_help!(this.tcx().sess, ty.span,
"perhaps you meant `&{}({} +{})`? (per RFC 438)",
ppaux::mutability_to_string(mut_ty.mutbl),
pprust::ty_to_string(&*mut_ty.ty),
pprust::bounds_to_string(bounds));
}
ast::TyRptr(Some(ref lt), ref mut_ty) => {
span_help!(this.tcx().sess, ty.span,
fileline_help!(this.tcx().sess, ty.span,
"perhaps you meant `&{} {}({} +{})`? (per RFC 438)",
pprust::lifetime_to_string(lt),
ppaux::mutability_to_string(mut_ty.mutbl),
@ -979,7 +979,7 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>,
}
_ => {
span_help!(this.tcx().sess, ty.span,
fileline_help!(this.tcx().sess, ty.span,
"perhaps you forgot parentheses? (per RFC 438)");
}
}

View File

@ -63,7 +63,7 @@ pub fn check_legal_trait_for_method_call(ccx: &CrateCtxt, span: Span, trait_id:
span_err!(tcx.sess, span, E0174,
"explicit use of unboxed closure method `{}` is experimental",
method);
span_help!(tcx.sess, span,
fileline_help!(tcx.sess, span,
"add `#![feature(unboxed_closures)]` to the crate attributes to enable");
}
}

View File

@ -22,6 +22,7 @@ use syntax::ast;
use syntax::codemap::Span;
use util::common::ErrorReported;
use util::nodemap::FnvHashSet;
use util::ppaux::Repr;
// Helper functions related to manipulating region types.
@ -40,6 +41,7 @@ struct Implicator<'a, 'tcx: 'a> {
stack: Vec<(ty::Region, Option<Ty<'tcx>>)>,
span: Span,
out: Vec<Implication<'tcx>>,
visited: FnvHashSet<Ty<'tcx>>,
}
/// This routine computes the well-formedness constraints that must hold for the type `ty` to
@ -65,7 +67,8 @@ pub fn implications<'a,'tcx>(
body_id: body_id,
span: span,
stack: stack,
out: Vec::new() };
out: Vec::new(),
visited: FnvHashSet() };
wf.accumulate_from_ty(ty);
debug!("implications: out={}", wf.out.repr(closure_typer.tcx()));
wf.out
@ -80,6 +83,12 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> {
debug!("accumulate_from_ty(ty={})",
ty.repr(self.tcx()));
// When expanding out associated types, we can visit a cyclic
// set of types. Issue #23003.
if !self.visited.insert(ty) {
return;
}
match ty.sty {
ty::ty_bool |
ty::ty_char |

View File

@ -3112,7 +3112,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
},
expr_t, None);
tcx.sess.span_help(field.span,
tcx.sess.fileline_help(field.span,
"maybe a `()` to call it is missing? \
If not, try an anonymous function");
} else {
@ -4494,7 +4494,7 @@ pub fn check_instantiable(tcx: &ty::ctxt,
span_err!(tcx.sess, sp, E0073,
"this type cannot be instantiated without an \
instance of itself");
span_help!(tcx.sess, sp, "consider using `Option<{}>`",
fileline_help!(tcx.sess, sp, "consider using `Option<{}>`",
ppaux::ty_to_string(tcx, item_ty));
false
} else {

View File

@ -401,7 +401,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
match suggested_marker_id {
Some(def_id) => {
self.tcx().sess.span_help(
self.tcx().sess.fileline_help(
span,
format!("consider removing `{}` or using a marker such as `{}`",
param_name.user_string(self.tcx()),

View File

@ -524,7 +524,7 @@ fn enforce_trait_manually_implementable(tcx: &ty::ctxt, sp: Span, trait_def_id:
return // everything OK
};
span_err!(tcx.sess, sp, E0183, "manual implementations of `{}` are experimental", trait_name);
span_help!(tcx.sess, sp,
fileline_help!(tcx.sess, sp,
"add `#![feature(unboxed_closures)]` to the crate attributes to enable");
}

View File

@ -1342,7 +1342,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
it.span,
"the `#[rustc_paren_sugar]` attribute is a temporary means of controlling \
which traits can use parenthetical notation");
span_help!(ccx.tcx.sess, it.span,
fileline_help!(ccx.tcx.sess, it.span,
"add `#![feature(unboxed_closures)]` to \
the crate attributes to use it");
}

View File

@ -117,7 +117,7 @@ impl FromHex for str {
// This may be an overestimate if there is any whitespace
let mut b = Vec::with_capacity(self.len() / 2);
let mut modulus = 0;
let mut buf = 0u8;
let mut buf = 0;
for (idx, byte) in self.bytes().enumerate() {
buf <<= 4;

View File

@ -1653,7 +1653,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
let mut i = 0;
let mut n = 0u16;
let mut n = 0;
while i < 4 && !self.eof() {
self.bump();
n = match self.ch_or_null() {

View File

@ -186,7 +186,7 @@ impl OwnedAsciiExt for Vec<u8> {
impl AsciiExt for u8 {
type Owned = u8;
#[inline]
fn is_ascii(&self) -> bool { *self & 128 == 0u8 }
fn is_ascii(&self) -> bool { *self & 128 == 0 }
#[inline]
fn to_ascii_uppercase(&self) -> u8 { ASCII_UPPERCASE_MAP[*self as usize] }
#[inline]
@ -398,7 +398,7 @@ mod tests {
assert_eq!("url()URL()uRl()ürl".to_ascii_uppercase(), "URL()URL()URL()üRL");
assert_eq!("hıß".to_ascii_uppercase(), "Hıß");
for i in 0u32..501 {
for i in 0..501 {
let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_uppercase(),
@ -412,7 +412,7 @@ mod tests {
// Dotted capital I, Kelvin sign, Sharp S.
assert_eq!("ß".to_ascii_lowercase(), "ß");
for i in 0u32..501 {
for i in 0..501 {
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().to_ascii_lowercase(),
@ -426,7 +426,7 @@ mod tests {
"URL()URL()URL()üRL".to_string());
assert_eq!(("hıß".to_string()).into_ascii_uppercase(), "Hıß");
for i in 0u32..501 {
for i in 0..501 {
let upper = if 'a' as u32 <= i && i <= 'z' as u32 { i + 'A' as u32 - 'a' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_uppercase(),
@ -441,7 +441,7 @@ mod tests {
// Dotted capital I, Kelvin sign, Sharp S.
assert_eq!(("ß".to_string()).into_ascii_lowercase(), "ß");
for i in 0u32..501 {
for i in 0..501 {
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
else { i };
assert_eq!((from_u32(i).unwrap()).to_string().into_ascii_lowercase(),
@ -459,7 +459,7 @@ mod tests {
assert!(!"".eq_ignore_ascii_case("k"));
assert!(!"ß".eq_ignore_ascii_case("s"));
for i in 0u32..501 {
for i in 0..501 {
let lower = if 'A' as u32 <= i && i <= 'Z' as u32 { i + 'a' as u32 - 'A' as u32 }
else { i };
assert!((from_u32(i).unwrap()).to_string().eq_ignore_ascii_case(

View File

@ -28,7 +28,7 @@ use ptr::{self, PtrExt, Unique};
use rt::heap::{allocate, deallocate, EMPTY};
use collections::hash_state::HashState;
const EMPTY_BUCKET: u64 = 0u64;
const EMPTY_BUCKET: u64 = 0;
/// The raw hashtable, providing safe-ish access to the unzipped and highly
/// optimized arrays of hashes, keys, and values.
@ -149,7 +149,7 @@ pub fn make_hash<T: ?Sized, S>(hash_state: &S, t: &T) -> SafeHash
{
let mut state = hash_state.hasher();
t.hash(&mut state);
// We need to avoid 0u64 in order to prevent collisions with
// We need to avoid 0 in order to prevent collisions with
// EMPTY_HASH. We can maintain our precious uniform distribution
// of initial indexes by unconditionally setting the MSB,
// effectively reducing 64-bits hashes to 63 bits.

View File

@ -78,7 +78,7 @@
//! * You want a bit vector.
//!
//! ### Use a `BitSet` when:
//! * You want a `VecSet`.
//! * You want a `BitVec`, but want `Set` properties
//!
//! ### Use a `BinaryHeap` when:
//! * You want to store a bunch of elements, but only ever want to process the "biggest"
@ -89,7 +89,8 @@
//!
//! Choosing the right collection for the job requires an understanding of what each collection
//! is good at. Here we briefly summarize the performance of different collections for certain
//! important operations. For further details, see each type's documentation.
//! important operations. For further details, see each type's documentation, and note that the
//! names of actual methods may differ from the tables below on certain collections.
//!
//! Throughout the documentation, we will follow a few conventions. For all operations,
//! the collection's size is denoted by n. If another collection is involved in the operation, it
@ -280,16 +281,16 @@
//! a variant of the `Entry` enum.
//!
//! If a `Vacant(entry)` is yielded, then the key *was not* found. In this case the
//! only valid operation is to `set` the value of the entry. When this is done,
//! only valid operation is to `insert` a value into the entry. When this is done,
//! the vacant entry is consumed and converted into a mutable reference to the
//! the value that was inserted. This allows for further manipulation of the value
//! beyond the lifetime of the search itself. This is useful if complex logic needs to
//! be performed on the value regardless of whether the value was just inserted.
//!
//! If an `Occupied(entry)` is yielded, then the key *was* found. In this case, the user
//! has several options: they can `get`, `set`, or `take` the value of the occupied
//! has several options: they can `get`, `insert`, or `remove` the value of the occupied
//! entry. Additionally, they can convert the occupied entry into a mutable reference
//! to its value, providing symmetry to the vacant `set` case.
//! to its value, providing symmetry to the vacant `insert` case.
//!
//! ### Examples
//!
@ -329,7 +330,7 @@
//! use std::collections::btree_map::{BTreeMap, Entry};
//!
//! // A client of the bar. They have an id and a blood alcohol level.
//! struct Person { id: u32, blood_alcohol: f32 };
//! struct Person { id: u32, blood_alcohol: f32 }
//!
//! // All the orders made to the bar, by client id.
//! let orders = vec![1,2,1,2,3,4,1,2,2,3,4,1,1,1];

View File

@ -616,6 +616,9 @@ mod os {
mod os {
pub const FAMILY: &'static str = "unix";
pub const OS: &'static str = "ios";
pub const DLL_PREFIX: &'static str = "lib";
pub const DLL_SUFFIX: &'static str = ".dylib";
pub const DLL_EXTENSION: &'static str = "dylib";
pub const EXE_SUFFIX: &'static str = "";
pub const EXE_EXTENSION: &'static str = "";
}

View File

@ -1053,7 +1053,7 @@ mod tests {
check!(w.write(msg));
}
let files = check!(fs::read_dir(dir));
let mut mem = [0u8; 4];
let mut mem = [0; 4];
for f in files {
let f = f.unwrap().path();
{
@ -1083,7 +1083,7 @@ mod tests {
check!(File::create(&dir2.join("14")));
let files = check!(fs::walk_dir(dir));
let mut cur = [0u8; 2];
let mut cur = [0; 2];
for f in files {
let f = f.unwrap().path();
let stem = f.file_stem().unwrap().to_str().unwrap();

View File

@ -616,14 +616,14 @@ mod tests {
#[test]
fn read_char_buffered() {
let buf = [195u8, 159u8];
let buf = [195, 159];
let reader = BufReader::with_capacity(1, &buf[..]);
assert_eq!(reader.chars().next(), Some(Ok('ß')));
}
#[test]
fn test_chars() {
let buf = [195u8, 159u8, b'a'];
let buf = [195, 159, b'a'];
let reader = BufReader::with_capacity(1, &buf[..]);
let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß')));

View File

@ -237,7 +237,7 @@ mod tests {
#[test]
fn test_mem_reader() {
let mut reader = Cursor::new(vec!(0u8, 1, 2, 3, 4, 5, 6, 7));
let mut reader = Cursor::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.position(), 0);
@ -259,7 +259,7 @@ mod tests {
#[test]
fn read_to_end() {
let mut reader = Cursor::new(vec!(0u8, 1, 2, 3, 4, 5, 6, 7));
let mut reader = Cursor::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
let mut v = Vec::new();
reader.read_to_end(&mut v).ok().unwrap();
assert_eq!(v, [0, 1, 2, 3, 4, 5, 6, 7]);
@ -267,7 +267,7 @@ mod tests {
#[test]
fn test_slice_reader() {
let in_buf = vec![0u8, 1, 2, 3, 4, 5, 6, 7];
let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = &mut in_buf.as_slice();
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
@ -289,7 +289,7 @@ mod tests {
#[test]
fn test_buf_reader() {
let in_buf = vec![0u8, 1, 2, 3, 4, 5, 6, 7];
let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = Cursor::new(in_buf.as_slice());
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
@ -335,7 +335,7 @@ mod tests {
assert_eq!(r.seek(SeekFrom::Start(10)), Ok(10));
assert_eq!(r.read(&mut [0]), Ok(0));
let mut r = Cursor::new(vec!(10u8));
let mut r = Cursor::new(vec!(10));
assert_eq!(r.seek(SeekFrom::Start(10)), Ok(10));
assert_eq!(r.read(&mut [0]), Ok(0));
@ -347,11 +347,11 @@ mod tests {
#[test]
fn seek_before_0() {
let buf = [0xff_u8];
let buf = [0xff];
let mut r = Cursor::new(&buf[..]);
assert!(r.seek(SeekFrom::End(-2)).is_err());
let mut r = Cursor::new(vec!(10u8));
let mut r = Cursor::new(vec!(10));
assert!(r.seek(SeekFrom::End(-2)).is_err());
let mut buf = [0];

View File

@ -562,7 +562,7 @@ mod tests {
#[test]
fn to_socket_addr_ipaddr_u16() {
let a = IpAddr::new_v4(77, 88, 21, 11);
let p = 12345u16;
let p = 12345;
let e = SocketAddr::new(a, p);
assert_eq!(Ok(vec![e]), tsa((a, p)));
}
@ -570,13 +570,13 @@ mod tests {
#[test]
fn to_socket_addr_str_u16() {
let a = SocketAddr::new(IpAddr::new_v4(77, 88, 21, 11), 24352);
assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352u16)));
assert_eq!(Ok(vec![a]), tsa(("77.88.21.11", 24352)));
let a = SocketAddr::new(IpAddr::new_v6(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53);
assert_eq!(Ok(vec![a]), tsa(("2a02:6b8:0:1::1", 53)));
let a = SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1), 23924);
assert!(tsa(("localhost", 23924u16)).unwrap().contains(&a));
assert!(tsa(("localhost", 23924)).unwrap().contains(&a));
}
#[test]

View File

@ -136,7 +136,7 @@ impl<'a> Parser<'a> {
}
fn read_number_impl(&mut self, radix: u8, max_digits: u32, upto: u32) -> Option<u32> {
let mut r = 0u32;
let mut r = 0;
let mut digit_count = 0;
loop {
match self.read_digit(radix) {
@ -164,7 +164,7 @@ impl<'a> Parser<'a> {
}
fn read_ipv4_addr_impl(&mut self) -> Option<Ipv4Addr> {
let mut bs = [0u8; 4];
let mut bs = [0; 4];
let mut i = 0;
while i < 4 {
if i != 0 && self.read_given_char('.').is_none() {
@ -189,7 +189,7 @@ impl<'a> Parser<'a> {
fn read_ipv6_addr_impl(&mut self) -> Option<Ipv6Addr> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> Ipv6Addr {
assert!(head.len() + tail.len() <= 8);
let mut gs = [0u16; 8];
let mut gs = [0; 8];
gs.clone_from_slice(head);
gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
Ipv6Addr::new(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
@ -231,7 +231,7 @@ impl<'a> Parser<'a> {
(i, false)
}
let mut head = [0u16; 8];
let mut head = [0; 8];
let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
if head_size == 8 {
@ -250,7 +250,7 @@ impl<'a> Parser<'a> {
return None;
}
let mut tail = [0u16; 8];
let mut tail = [0; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size]))
}

View File

@ -824,14 +824,14 @@ mod tests {
#[test]
fn test_integer_decode() {
assert_eq!(3.14159265359f32.integer_decode(), (13176795u64, -22i16, 1i8));
assert_eq!((-8573.5918555f32).integer_decode(), (8779358u64, -10i16, -1i8));
assert_eq!(2f32.powf(100.0).integer_decode(), (8388608u64, 77i16, 1i8));
assert_eq!(0f32.integer_decode(), (0u64, -150i16, 1i8));
assert_eq!((-0f32).integer_decode(), (0u64, -150i16, -1i8));
assert_eq!(INFINITY.integer_decode(), (8388608u64, 105i16, 1i8));
assert_eq!(NEG_INFINITY.integer_decode(), (8388608u64, 105i16, -1i8));
assert_eq!(NAN.integer_decode(), (12582912u64, 105i16, 1i8));
assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1));
assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1));
assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1));
assert_eq!(0f32.integer_decode(), (0, -150, 1));
assert_eq!((-0f32).integer_decode(), (0, -150, -1));
assert_eq!(INFINITY.integer_decode(), (8388608, 105, 1));
assert_eq!(NEG_INFINITY.integer_decode(), (8388608, 105, -1));
assert_eq!(NAN.integer_decode(), (12582912, 105, 1));
}
#[test]

View File

@ -826,14 +826,14 @@ mod tests {
#[test]
fn test_integer_decode() {
assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906u64, -51i16, 1i8));
assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931u64, -39i16, -1i8));
assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496u64, 48i16, 1i8));
assert_eq!(0f64.integer_decode(), (0u64, -1075i16, 1i8));
assert_eq!((-0f64).integer_decode(), (0u64, -1075i16, -1i8));
assert_eq!(INFINITY.integer_decode(), (4503599627370496u64, 972i16, 1i8));
assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1));
assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1));
assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1));
assert_eq!(0f64.integer_decode(), (0, -1075, 1));
assert_eq!((-0f64).integer_decode(), (0, -1075, -1));
assert_eq!(INFINITY.integer_decode(), (4503599627370496, 972, 1));
assert_eq!(NEG_INFINITY.integer_decode(), (4503599627370496, 972, -1));
assert_eq!(NAN.integer_decode(), (6755399441055744u64, 972i16, 1i8));
assert_eq!(NAN.integer_decode(), (6755399441055744, 972, 1));
}
#[test]

View File

@ -312,7 +312,7 @@ pub trait Float
///
/// let num = 2.0f32;
///
/// // (8388608u64, -22i16, 1i8)
/// // (8388608, -22, 1)
/// let (mantissa, exponent, sign) = num.integer_decode();
/// let sign_f = sign as f32;
/// let mantissa_f = mantissa as f32;
@ -1755,25 +1755,25 @@ mod tests {
#[test]
fn test_uint_to_str_overflow() {
let mut u8_val: u8 = 255_u8;
let mut u8_val: u8 = 255;
assert_eq!(u8_val.to_string(), "255");
u8_val = u8_val.wrapping_add(1);
assert_eq!(u8_val.to_string(), "0");
let mut u16_val: u16 = 65_535_u16;
let mut u16_val: u16 = 65_535;
assert_eq!(u16_val.to_string(), "65535");
u16_val = u16_val.wrapping_add(1);
assert_eq!(u16_val.to_string(), "0");
let mut u32_val: u32 = 4_294_967_295_u32;
let mut u32_val: u32 = 4_294_967_295;
assert_eq!(u32_val.to_string(), "4294967295");
u32_val = u32_val.wrapping_add(1);
assert_eq!(u32_val.to_string(), "0");
let mut u64_val: u64 = 18_446_744_073_709_551_615_u64;
let mut u64_val: u64 = 18_446_744_073_709_551_615;
assert_eq!(u64_val.to_string(), "18446744073709551615");
u64_val = u64_val.wrapping_add(1);
@ -1786,7 +1786,7 @@ mod tests {
#[test]
fn test_uint_from_str_overflow() {
let mut u8_val: u8 = 255_u8;
let mut u8_val: u8 = 255;
assert_eq!(from_str::<u8>("255"), Some(u8_val));
assert_eq!(from_str::<u8>("256"), None);
@ -1794,7 +1794,7 @@ mod tests {
assert_eq!(from_str::<u8>("0"), Some(u8_val));
assert_eq!(from_str::<u8>("-1"), None);
let mut u16_val: u16 = 65_535_u16;
let mut u16_val: u16 = 65_535;
assert_eq!(from_str::<u16>("65535"), Some(u16_val));
assert_eq!(from_str::<u16>("65536"), None);
@ -1802,7 +1802,7 @@ mod tests {
assert_eq!(from_str::<u16>("0"), Some(u16_val));
assert_eq!(from_str::<u16>("-1"), None);
let mut u32_val: u32 = 4_294_967_295_u32;
let mut u32_val: u32 = 4_294_967_295;
assert_eq!(from_str::<u32>("4294967295"), Some(u32_val));
assert_eq!(from_str::<u32>("4294967296"), None);
@ -1810,7 +1810,7 @@ mod tests {
assert_eq!(from_str::<u32>("0"), Some(u32_val));
assert_eq!(from_str::<u32>("-1"), None);
let mut u64_val: u64 = 18_446_744_073_709_551_615_u64;
let mut u64_val: u64 = 18_446_744_073_709_551_615;
assert_eq!(from_str::<u64>("18446744073709551615"), Some(u64_val));
assert_eq!(from_str::<u64>("18446744073709551616"), None);

View File

@ -104,7 +104,7 @@ fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F
// This is just for integral types, the largest of which is a u64. The
// smallest base that we can have is 2, so the most number of digits we're
// ever going to have is 64
let mut buf = [0u8; 64];
let mut buf = [0; 64];
let mut cur = 0;
// Loop at least once to make sure at least a `0` gets emitted.
@ -221,10 +221,10 @@ pub fn float_to_str_bytes_common<T: Float>(
let radix_gen: T = num::cast(radix as int).unwrap();
let (num, exp) = match exp_format {
ExpNone => (num, 0i32),
ExpNone => (num, 0),
ExpDec | ExpBin => {
if num == _0 {
(num, 0i32)
(num, 0)
} else {
let (exp, exp_base) = match exp_format {
ExpDec => (num.abs().log10().floor(), num::cast::<f64, T>(10.0f64).unwrap()),
@ -432,25 +432,25 @@ mod tests {
#[test]
fn test_int_to_str_overflow() {
let mut i8_val: i8 = 127_i8;
let mut i8_val: i8 = 127;
assert_eq!(i8_val.to_string(), "127");
i8_val = i8_val.wrapping_add(1);
assert_eq!(i8_val.to_string(), "-128");
let mut i16_val: i16 = 32_767_i16;
let mut i16_val: i16 = 32_767;
assert_eq!(i16_val.to_string(), "32767");
i16_val = i16_val.wrapping_add(1);
assert_eq!(i16_val.to_string(), "-32768");
let mut i32_val: i32 = 2_147_483_647_i32;
let mut i32_val: i32 = 2_147_483_647;
assert_eq!(i32_val.to_string(), "2147483647");
i32_val = i32_val.wrapping_add(1);
assert_eq!(i32_val.to_string(), "-2147483648");
let mut i64_val: i64 = 9_223_372_036_854_775_807_i64;
let mut i64_val: i64 = 9_223_372_036_854_775_807;
assert_eq!(i64_val.to_string(), "9223372036854775807");
i64_val = i64_val.wrapping_add(1);

View File

@ -642,14 +642,14 @@ mod test {
#[test]
fn read_char_buffered() {
let buf = [195u8, 159u8];
let buf = [195, 159];
let mut reader = BufferedReader::with_capacity(1, &buf[..]);
assert_eq!(reader.read_char(), Ok('ß'));
}
#[test]
fn test_chars() {
let buf = [195u8, 159u8, b'a'];
let buf = [195, 159, b'a'];
let mut reader = BufferedReader::with_capacity(1, &buf[..]);
let mut it = reader.chars();
assert_eq!(it.next(), Some(Ok('ß')));

View File

@ -30,7 +30,7 @@ use vec::Vec;
/// # drop(tx);
/// let mut reader = ChanReader::new(rx);
///
/// let mut buf = [0u8; 100];
/// let mut buf = [0; 100];
/// match reader.read(&mut buf) {
/// Ok(nread) => println!("Read {} bytes", nread),
/// Err(e) => println!("read error: {}", e),
@ -167,15 +167,15 @@ mod test {
fn test_rx_reader() {
let (tx, rx) = channel();
thread::spawn(move|| {
tx.send(vec![1u8, 2u8]).unwrap();
tx.send(vec![1, 2]).unwrap();
tx.send(vec![]).unwrap();
tx.send(vec![3u8, 4u8]).unwrap();
tx.send(vec![5u8, 6u8]).unwrap();
tx.send(vec![7u8, 8u8]).unwrap();
tx.send(vec![3, 4]).unwrap();
tx.send(vec![5, 6]).unwrap();
tx.send(vec![7, 8]).unwrap();
});
let mut reader = ChanReader::new(rx);
let mut buf = [0u8; 3];
let mut buf = [0; 3];
assert_eq!(Ok(0), reader.read(&mut []));
@ -233,7 +233,7 @@ mod test {
let mut writer = ChanWriter::new(tx);
writer.write_be_u32(42).unwrap();
let wanted = vec![0u8, 0u8, 0u8, 42u8];
let wanted = vec![0, 0, 0, 42];
let got = thread::scoped(move|| { rx.recv().unwrap() }).join();
assert_eq!(wanted, got);

View File

@ -101,7 +101,7 @@ pub fn u64_to_le_bytes<T, F>(n: u64, size: uint, f: F) -> T where
let mut i = size;
let mut n = n;
while i > 0 {
bytes.push((n & 255_u64) as u8);
bytes.push((n & 255) as u8);
n >>= 8;
i -= 1;
}
@ -170,7 +170,7 @@ pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
panic!("index out of bounds");
}
let mut buf = [0u8; 8];
let mut buf = [0; 8];
unsafe {
let ptr = data.as_ptr().offset(start as int);
let out = buf.as_mut_ptr();
@ -522,8 +522,8 @@ mod bench {
({
use super::u64_from_be_bytes;
let data = (0u8..$stride*100+$start_index).collect::<Vec<_>>();
let mut sum = 0u64;
let data = (0..$stride*100+$start_index).collect::<Vec<_>>();
let mut sum = 0;
$b.iter(|| {
let mut i = $start_index;
while i < data.len() {

View File

@ -1166,7 +1166,7 @@ mod test {
check!(w.write(msg));
}
let files = check!(readdir(dir));
let mut mem = [0u8; 4];
let mut mem = [0; 4];
for f in &files {
{
let n = f.filestem_str();
@ -1198,7 +1198,7 @@ mod test {
check!(File::create(&dir2.join("14")));
let mut files = check!(walk_dir(dir));
let mut cur = [0u8; 2];
let mut cur = [0; 2];
for f in files {
let stem = f.filestem_str().unwrap();
let root = stem.as_bytes()[0] - b'0';

View File

@ -670,7 +670,7 @@ pub trait Reader {
fn read_le_uint_n(&mut self, nbytes: uint) -> IoResult<u64> {
assert!(nbytes > 0 && nbytes <= 8);
let mut val = 0u64;
let mut val = 0;
let mut pos = 0;
let mut i = nbytes;
while i > 0 {
@ -694,7 +694,7 @@ pub trait Reader {
fn read_be_uint_n(&mut self, nbytes: uint) -> IoResult<u64> {
assert!(nbytes > 0 && nbytes <= 8);
let mut val = 0u64;
let mut val = 0;
let mut i = nbytes;
while i > 0 {
i -= 1;
@ -1078,7 +1078,7 @@ pub trait Writer {
/// Write a single char, encoded as UTF-8.
#[inline]
fn write_char(&mut self, c: char) -> IoResult<()> {
let mut buf = [0u8; 4];
let mut buf = [0; 4];
let n = c.encode_utf8(&mut buf).unwrap_or(0);
self.write_all(&buf[..n])
}
@ -1896,7 +1896,7 @@ mod tests {
fn test_read_at_least() {
let mut r = BadReader::new(MemReader::new(b"hello, world!".to_vec()),
vec![GoodBehavior(usize::MAX)]);
let buf = &mut [0u8; 5];
let buf = &mut [0; 5];
assert!(r.read_at_least(1, buf).unwrap() >= 1);
assert!(r.read_exact(5).unwrap().len() == 5); // read_exact uses read_at_least
assert!(r.read_at_least(0, buf).is_ok());

View File

@ -198,7 +198,7 @@ impl<'a> Parser<'a> {
}
fn read_number_impl(&mut self, radix: u8, max_digits: u32, upto: u32) -> Option<u32> {
let mut r = 0u32;
let mut r = 0;
let mut digit_count = 0;
loop {
match self.read_digit(radix) {
@ -226,7 +226,7 @@ impl<'a> Parser<'a> {
}
fn read_ipv4_addr_impl(&mut self) -> Option<IpAddr> {
let mut bs = [0u8; 4];
let mut bs = [0; 4];
let mut i = 0;
while i < 4 {
if i != 0 && self.read_given_char('.').is_none() {
@ -251,7 +251,7 @@ impl<'a> Parser<'a> {
fn read_ipv6_addr_impl(&mut self) -> Option<IpAddr> {
fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
assert!(head.len() + tail.len() <= 8);
let mut gs = [0u16; 8];
let mut gs = [0; 8];
gs.clone_from_slice(head);
gs[(8 - tail.len()) .. 8].clone_from_slice(tail);
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
@ -294,7 +294,7 @@ impl<'a> Parser<'a> {
(i, false)
}
let mut head = [0u16; 8];
let mut head = [0; 8];
let (head_size, head_ipv4) = read_groups(self, &mut head, 8);
if head_size == 8 {
@ -313,7 +313,7 @@ impl<'a> Parser<'a> {
return None;
}
let mut tail = [0u16; 8];
let mut tail = [0; 8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
Some(ipv6_addr_from_head_tail(&head[..head_size], &tail[..tail_size]))
}
@ -425,17 +425,17 @@ pub struct ParseError;
/// // The following lines are equivalent modulo possible "localhost" name resolution
/// // differences
/// let tcp_s = TcpStream::connect(SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 12345 });
/// let tcp_s = TcpStream::connect((Ipv4Addr(127, 0, 0, 1), 12345u16));
/// let tcp_s = TcpStream::connect(("127.0.0.1", 12345u16));
/// let tcp_s = TcpStream::connect(("localhost", 12345u16));
/// let tcp_s = TcpStream::connect((Ipv4Addr(127, 0, 0, 1), 12345));
/// let tcp_s = TcpStream::connect(("127.0.0.1", 12345));
/// let tcp_s = TcpStream::connect(("localhost", 12345));
/// let tcp_s = TcpStream::connect("127.0.0.1:12345");
/// let tcp_s = TcpStream::connect("localhost:12345");
///
/// // TcpListener::bind(), UdpSocket::bind() and UdpSocket::send_to() behave similarly
/// let tcp_l = TcpListener::bind("localhost:12345");
///
/// let mut udp_s = UdpSocket::bind(("127.0.0.1", 23451u16)).unwrap();
/// udp_s.send_to([7u8, 7u8, 7u8].as_slice(), (Ipv4Addr(127, 0, 0, 1), 23451u16));
/// let mut udp_s = UdpSocket::bind(("127.0.0.1", 23451)).unwrap();
/// udp_s.send_to([7, 7, 7].as_slice(), (Ipv4Addr(127, 0, 0, 1), 23451));
/// }
/// ```
pub trait ToSocketAddr {
@ -674,7 +674,7 @@ mod test {
#[test]
fn to_socket_addr_ipaddr_u16() {
let a = Ipv4Addr(77, 88, 21, 11);
let p = 12345u16;
let p = 12345;
let e = SocketAddr { ip: a, port: p };
assert_eq!(Ok(e), (a, p).to_socket_addr());
assert_eq!(Ok(vec![e]), (a, p).to_socket_addr_all());
@ -683,15 +683,15 @@ mod test {
#[test]
fn to_socket_addr_str_u16() {
let a = SocketAddr { ip: Ipv4Addr(77, 88, 21, 11), port: 24352 };
assert_eq!(Ok(a), ("77.88.21.11", 24352u16).to_socket_addr());
assert_eq!(Ok(vec![a]), ("77.88.21.11", 24352u16).to_socket_addr_all());
assert_eq!(Ok(a), ("77.88.21.11", 24352).to_socket_addr());
assert_eq!(Ok(vec![a]), ("77.88.21.11", 24352).to_socket_addr_all());
let a = SocketAddr { ip: Ipv6Addr(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), port: 53 };
assert_eq!(Ok(a), ("2a02:6b8:0:1::1", 53).to_socket_addr());
assert_eq!(Ok(vec![a]), ("2a02:6b8:0:1::1", 53).to_socket_addr_all());
let a = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 23924 };
assert!(("localhost", 23924u16).to_socket_addr_all().unwrap().contains(&a));
assert!(("localhost", 23924).to_socket_addr_all().unwrap().contains(&a));
}
#[test]

View File

@ -1162,7 +1162,7 @@ mod test {
tx.send(TcpStream::connect(addr).unwrap()).unwrap();
});
let _l = rx.recv().unwrap();
for i in 0i32..1001 {
for i in 0..1001 {
match a.accept() {
Ok(..) => break,
Err(ref e) if e.kind == TimedOut => {}
@ -1262,7 +1262,7 @@ mod test {
assert_eq!(s.read(&mut [0]).err().unwrap().kind, TimedOut);
s.set_timeout(Some(20));
for i in 0i32..1001 {
for i in 0..1001 {
match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,
@ -1320,7 +1320,7 @@ mod test {
let mut s = a.accept().unwrap();
s.set_write_timeout(Some(20));
for i in 0i32..1001 {
for i in 0..1001 {
match s.write(&[0; 128 * 1024]) {
Ok(()) | Err(IoError { kind: ShortWrite(..), .. }) => {},
Err(IoError { kind: TimedOut, .. }) => break,

View File

@ -73,8 +73,8 @@ it is running in and assigns a port range based on it.
*/
fn base_port() -> u16 {
let base = 9600u16;
let range = 1000u16;
let base = 9600;
let range = 1000;
let bases = [
("32-opt", base + range * 1),

View File

@ -418,7 +418,7 @@ mod test {
#[test]
fn test_iter_reader() {
let mut r = IterReader::new(0u8..8);
let mut r = IterReader::new(0..8);
let mut buf = [0, 0, 0];
let len = r.read(&mut buf).unwrap();
assert_eq!(len, 3);
@ -437,7 +437,7 @@ mod test {
#[test]
fn iter_reader_zero_length() {
let mut r = IterReader::new(0u8..8);
let mut r = IterReader::new(0..8);
let mut buf = [];
assert_eq!(Ok(0), r.read(&mut buf));
}

View File

@ -468,7 +468,7 @@ mod test {
let lengths = [0, 1, 2, 3, 4, 5, 6, 7,
80, 81, 82, 83, 84, 85, 86, 87];
for &n in &lengths {
let mut v = repeat(0u8).take(n).collect::<Vec<_>>();
let mut v = repeat(0).take(n).collect::<Vec<_>>();
r.fill_bytes(&mut v);
// use this to get nicer error messages.

View File

@ -80,13 +80,13 @@ mod imp {
}
fn getrandom_next_u32() -> u32 {
let mut buf: [u8; 4] = [0u8; 4];
let mut buf: [u8; 4] = [0; 4];
getrandom_fill_bytes(&mut buf);
unsafe { mem::transmute::<[u8; 4], u32>(buf) }
}
fn getrandom_next_u64() -> u64 {
let mut buf: [u8; 8] = [0u8; 8];
let mut buf: [u8; 8] = [0; 8];
getrandom_fill_bytes(&mut buf);
unsafe { mem::transmute::<[u8; 8], u64>(buf) }
}
@ -231,12 +231,12 @@ mod imp {
impl Rng for OsRng {
fn next_u32(&mut self) -> u32 {
let mut v = [0u8; 4];
let mut v = [0; 4];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
fn next_u64(&mut self) -> u64 {
let mut v = [0u8; 8];
let mut v = [0; 8];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
@ -318,12 +318,12 @@ mod imp {
impl Rng for OsRng {
fn next_u32(&mut self) -> u32 {
let mut v = [0u8; 4];
let mut v = [0; 4];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
fn next_u64(&mut self) -> u64 {
let mut v = [0u8; 8];
let mut v = [0; 8];
self.fill_bytes(&mut v);
unsafe { mem::transmute(v) }
}
@ -366,7 +366,7 @@ mod test {
r.next_u32();
r.next_u64();
let mut v = [0u8; 1000];
let mut v = [0; 1000];
r.fill_bytes(&mut v);
}
@ -386,7 +386,7 @@ mod test {
// as possible (XXX: is this a good test?)
let mut r = OsRng::new().unwrap();
thread::yield_now();
let mut v = [0u8; 1000];
let mut v = [0; 1000];
for _ in 0..100 {
r.next_u32();

View File

@ -84,28 +84,28 @@ mod test {
#[test]
fn test_reader_rng_u64() {
// transmute from the target to avoid endianness concerns.
let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1,
let v = vec![0, 0, 0, 0, 0, 0, 0, 1,
0 , 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 3];
let mut rng = ReaderRng::new(MemReader::new(v));
assert_eq!(rng.next_u64(), 1_u64.to_be());
assert_eq!(rng.next_u64(), 2_u64.to_be());
assert_eq!(rng.next_u64(), 3_u64.to_be());
assert_eq!(rng.next_u64(), 1.to_be());
assert_eq!(rng.next_u64(), 2.to_be());
assert_eq!(rng.next_u64(), 3.to_be());
}
#[test]
fn test_reader_rng_u32() {
let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
let v = vec![0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3];
let mut rng = ReaderRng::new(MemReader::new(v));
assert_eq!(rng.next_u32(), 1_u32.to_be());
assert_eq!(rng.next_u32(), 2_u32.to_be());
assert_eq!(rng.next_u32(), 3_u32.to_be());
assert_eq!(rng.next_u32(), 1.to_be());
assert_eq!(rng.next_u32(), 2.to_be());
assert_eq!(rng.next_u32(), 3.to_be());
}
#[test]
fn test_reader_rng_fill_bytes() {
let v = [1u8, 2, 3, 4, 5, 6, 7, 8];
let mut w = [0u8; 8];
let v = [1, 2, 3, 4, 5, 6, 7, 8];
let mut w = [0; 8];
let mut rng = ReaderRng::new(MemReader::new(v.to_vec()));
rng.fill_bytes(&mut w);
@ -117,7 +117,7 @@ mod test {
#[should_fail]
fn test_reader_rng_insufficient_bytes() {
let mut rng = ReaderRng::new(MemReader::new(vec!()));
let mut v = [0u8; 3];
let mut v = [0; 3];
rng.fill_bytes(&mut v);
}
}

View File

@ -139,7 +139,7 @@ pub fn abort(args: fmt::Arguments) -> ! {
}
// Convert the arguments into a stack-allocated string
let mut msg = [0u8; 512];
let mut msg = [0; 512];
let mut w = BufWriter { buf: &mut msg, pos: 0 };
let _ = write!(&mut w, "{}", args);
let msg = str::from_utf8(&w.buf[..w.pos]).unwrap_or("aborted");

View File

@ -714,7 +714,7 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: uint) -> bool {
if index == slice.len() { return true; }
match slice.bytes.get(index) {
None => false,
Some(&b) => b < 128u8 || b >= 192u8,
Some(&b) => b < 128 || b >= 192,
}
}
@ -776,7 +776,7 @@ impl<'a> Iterator for EncodeWide<'a> {
return Some(tmp);
}
let mut buf = [0u16; 2];
let mut buf = [0; 2];
self.code_points.next().map(|code_point| {
let n = encode_utf16_raw(code_point.value, &mut buf)
.unwrap_or(0);

View File

@ -389,7 +389,7 @@ mod tests {
let mut writer = FileDesc::new(writer, true);
writer.write(b"test").ok().unwrap();
let mut buf = [0u8; 4];
let mut buf = [0; 4];
match reader.read(&mut buf) {
Ok(4) => {
assert_eq!(buf[0], 't' as u8);

View File

@ -901,7 +901,7 @@ mod test {
assert!(e.is::<T>());
let any = e.downcast::<T>().ok().unwrap();
assert!(any.is::<u16>());
assert_eq!(*any.downcast::<u16>().ok().unwrap(), 413u16);
assert_eq!(*any.downcast::<u16>().ok().unwrap(), 413);
}
Ok(()) => panic!()
}

View File

@ -68,7 +68,7 @@ pub const MAX: Duration = Duration {
impl Duration {
/// Makes a new `Duration` with given number of weeks.
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks.
/// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60)` with overflow checks.
/// Panics when the duration is out of bounds.
#[inline]
#[unstable(feature = "std_misc")]

View File

@ -53,7 +53,7 @@
//! assert!(b == c);
//!
//! let d : (u32, f32) = Default::default();
//! assert_eq!(d, (0u32, 0.0f32));
//! assert_eq!(d, (0, 0.0f32));
//! ```
#![doc(primitive = "tuple")]

View File

@ -159,10 +159,10 @@ pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
pub fn int_ty_max(t: IntTy) -> u64 {
match t {
TyI8 => 0x80u64,
TyI16 => 0x8000u64,
TyIs(_) | TyI32 => 0x80000000u64, // actually ni about TyIs
TyI64 => 0x8000000000000000u64
TyI8 => 0x80,
TyI16 => 0x8000,
TyIs(_) | TyI32 => 0x80000000, // actually ni about TyIs
TyI64 => 0x8000000000000000
}
}
@ -185,10 +185,10 @@ pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
pub fn uint_ty_max(t: UintTy) -> u64 {
match t {
TyU8 => 0xffu64,
TyU16 => 0xffffu64,
TyUs(_) | TyU32 => 0xffffffffu64, // actually ni about TyUs
TyU64 => 0xffffffffffffffffu64
TyU8 => 0xff,
TyU16 => 0xffff,
TyUs(_) | TyU32 => 0xffffffff, // actually ni about TyUs
TyU64 => 0xffffffffffffffff
}
}

View File

@ -52,6 +52,13 @@ macro_rules! span_help {
})
}
#[macro_export]
macro_rules! fileline_help {
($session:expr, $span:expr, $($message:tt)*) => ({
($session).fileline_help($span, &format!($($message)*))
})
}
#[macro_export]
macro_rules! register_diagnostics {
($($code:tt),*) => (

View File

@ -753,6 +753,10 @@ impl<'a> ExtCtxt<'a> {
self.print_backtrace();
self.parse_sess.span_diagnostic.span_help(sp, msg);
}
pub fn fileline_help(&self, sp: Span, msg: &str) {
self.print_backtrace();
self.parse_sess.span_diagnostic.fileline_help(sp, msg);
}
pub fn bug(&self, msg: &str) -> ! {
self.print_backtrace();
self.parse_sess.span_diagnostic.handler().bug(msg);

View File

@ -571,7 +571,7 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use");
is_use = true;
if let ast::AttrInner = attr.node.style {
fld.cx.span_help(attr.span, "consider an outer attribute, \
fld.cx.fileline_help(attr.span, "consider an outer attribute, \
#[macro_use] mod ...");
}
};

View File

@ -676,9 +676,10 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
token::FatArrow => "FatArrow",
token::Pound => "Pound",
token::Dollar => "Dollar",
token::Question => "Question",
token::Underscore => "Underscore",
token::Eof => "Eof",
_ => panic!(),
_ => panic!("unhandled token in quote!"),
};
mk_token_path(cx, sp, name)
}

View File

@ -362,7 +362,7 @@ impl<'a> Context<'a> {
pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain: &str) {
diag.span_err(span, explain);
diag.span_help(span, &format!("add #![feature({})] to the \
diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to enable",
feature));
}
@ -370,7 +370,7 @@ pub fn emit_feature_err(diag: &SpanHandler, feature: &str, span: Span, explain:
pub fn emit_feature_warn(diag: &SpanHandler, feature: &str, span: Span, explain: &str) {
diag.span_warn(span, explain);
if diag.handler.can_emit_warnings {
diag.span_help(span, &format!("add #![feature({})] to the \
diag.fileline_help(span, &format!("add #![feature({})] to the \
crate attributes to silence this warning",
feature));
}

View File

@ -77,7 +77,7 @@ impl<'a> ParserAttr for Parser<'a> {
self.span_err(span,
"an inner attribute is not permitted in \
this context");
self.span_help(span,
self.fileline_help(span,
"place inner attribute at the top of the module or block");
}
ast::AttrInner

Some files were not shown because too many files have changed in this diff Show More