auto merge of #18459 : alexcrichton/rust/rollup, r=alexcrichton

This commit is contained in:
bors 2014-10-31 02:27:15 +00:00
commit 221fc1e3cd
257 changed files with 1168 additions and 1437 deletions

View File

@ -1013,7 +1013,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
if prefix_matches(line, prefixes[i].as_slice()) &&
line.contains(ee.kind.as_slice()) &&
line.contains(ee.msg.as_slice()) {
*found_flags.get_mut(i) = true;
found_flags[i] = true;
was_expected = true;
break;
}

View File

@ -47,7 +47,7 @@ release: 0.12.0
```
Finally, if you can run the offending command under gdb, pasting a stack trace can be
useful; to do so, you will need to set a breakpoint on `rust_fail`.
useful; to do so, you will need to set a breakpoint on `rust_panic`.
# I submitted a bug, but nobody has commented on it!

View File

@ -56,7 +56,7 @@ a reference.
fn compute_distance(p1: &Point, p2: &Point) -> f64 {
let x_d = p1.x - p2.x;
let y_d = p1.y - p2.y;
sqrt(x_d * x_d + y_d * y_d)
(x_d * x_d + y_d * y_d).sqrt()
}
~~~

View File

@ -1153,7 +1153,7 @@ exposing an API making it possible for it to occur in safe code.
* Data races
* Dereferencing a null/dangling raw pointer
* Mutating an immutable value/reference
* Mutating an immutable value/reference without `UnsafeCell`
* Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values)
(uninitialized) memory
* Breaking the [pointer aliasing
@ -1166,11 +1166,14 @@ exposing an API making it possible for it to occur in safe code.
* Using `std::ptr::copy_nonoverlapping_memory` (`memcpy32`/`memcpy64`
instrinsics) on overlapping buffers
* Invalid values in primitive types, even in private fields/locals:
* Dangling/null pointers in non-raw pointers, or slices
* Dangling/null references or boxes
* A value other than `false` (0) or `true` (1) in a `bool`
* A discriminant in an `enum` not included in the type definition
* A value in a `char` which is a surrogate or above `char::MAX`
* non-UTF-8 byte sequences in a `str`
* Unwinding into Rust from foreign code or unwinding from Rust into foreign
code. Rust's failure system is not compatible with exception handling in
other languages. Unwinding must be caught and handled at FFI boundaries.
##### Behaviour not considered unsafe

View File

@ -59,7 +59,7 @@ fn parse_token_list(file: &str) -> HashMap<String, Token> {
"FLOAT_SUFFIX" => id(),
"INT_SUFFIX" => id(),
"SHL" => token::BinOp(token::Shl),
"LBRACE" => token::LBrace,
"LBRACE" => token::OpenDelim(token::Brace),
"RARROW" => token::Rarrow,
"LIT_STR" => token::LitStr(Name(0)),
"DOTDOT" => token::DotDot,
@ -67,12 +67,12 @@ fn parse_token_list(file: &str) -> HashMap<String, Token> {
"DOTDOTDOT" => token::DotDotDot,
"NOT" => token::Not,
"AND" => token::BinOp(token::And),
"LPAREN" => token::LParen,
"LPAREN" => token::OpenDelim(token::Paren),
"ANDAND" => token::AndAnd,
"AT" => token::At,
"LBRACKET" => token::LBracket,
"LBRACKET" => token::OpenDelim(token::Bracket),
"LIT_STR_RAW" => token::LitStrRaw(Name(0), 0),
"RPAREN" => token::RParen,
"RPAREN" => token::CloseDelim(token::Paren),
"SLASH" => token::BinOp(token::Slash),
"COMMA" => token::Comma,
"LIFETIME" => token::Lifetime(ast::Ident { name: Name(0), ctxt: 0 }),
@ -83,7 +83,7 @@ fn parse_token_list(file: &str) -> HashMap<String, Token> {
"LIT_CHAR" => token::LitChar(Name(0)),
"LIT_BYTE" => token::LitByte(Name(0)),
"EQ" => token::Eq,
"RBRACKET" => token::RBracket,
"RBRACKET" => token::CloseDelim(token::Bracket),
"COMMENT" => token::Comment,
"DOC_COMMENT" => token::DocComment(Name(0)),
"DOT" => token::Dot,
@ -91,7 +91,7 @@ fn parse_token_list(file: &str) -> HashMap<String, Token> {
"NE" => token::Ne,
"GE" => token::Ge,
"PERCENT" => token::BinOp(token::Percent),
"RBRACE" => token::RBrace,
"RBRACE" => token::CloseDelim(token::Brace),
"BINOP" => token::BinOp(token::Plus),
"POUND" => token::Pound,
"OROR" => token::OrOr,

View File

@ -29,7 +29,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(unsafe_destructor)]
#![allow(missing_doc)]
#![allow(missing_docs)]
use std::cell::{Cell, RefCell};
use std::cmp;
@ -208,13 +208,13 @@ impl Arena {
}
#[inline]
fn alloc_copy<T>(&self, op: || -> T) -> &T {
fn alloc_copy<T>(&self, op: || -> T) -> &mut T {
unsafe {
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
mem::min_align_of::<T>());
let ptr = ptr as *mut T;
ptr::write(&mut (*ptr), op());
return &*ptr;
return &mut *ptr;
}
}
@ -262,7 +262,7 @@ impl Arena {
}
#[inline]
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
fn alloc_noncopy<T>(&self, op: || -> T) -> &mut T {
unsafe {
let tydesc = get_tydesc::<T>();
let (ty_ptr, ptr) =
@ -279,14 +279,14 @@ impl Arena {
// the object is there.
*ty_ptr = bitpack_tydesc_ptr(tydesc, true);
return &*ptr;
return &mut *ptr;
}
}
/// Allocates a new item in the arena, using `op` to initialize the value,
/// and returns a reference to it.
#[inline]
pub fn alloc<T>(&self, op: || -> T) -> &T {
pub fn alloc<T>(&self, op: || -> T) -> &mut T {
unsafe {
if intrinsics::needs_drop::<T>() {
self.alloc_noncopy(op)
@ -458,12 +458,12 @@ impl<T> TypedArena<T> {
/// Allocates an object in the `TypedArena`, returning a reference to it.
#[inline]
pub fn alloc(&self, object: T) -> &T {
pub fn alloc(&self, object: T) -> &mut T {
if self.ptr == self.end {
self.grow()
}
let ptr: &T = unsafe {
let ptr: &mut T = unsafe {
let ptr: &mut T = mem::transmute(self.ptr);
ptr::write(ptr, object);
self.ptr.set(self.ptr.get().offset(1));

View File

@ -243,7 +243,7 @@ impl Bitv {
let used_bits = bitv.nbits % u32::BITS;
if init && used_bits != 0 {
let largest_used_word = (bitv.nbits + u32::BITS - 1) / u32::BITS - 1;
*bitv.storage.get_mut(largest_used_word) &= (1 << used_bits) - 1;
bitv.storage[largest_used_word] &= (1 << used_bits) - 1;
}
bitv
@ -297,8 +297,9 @@ impl Bitv {
let w = i / u32::BITS;
let b = i % u32::BITS;
let flag = 1 << b;
*self.storage.get_mut(w) = if x { self.storage[w] | flag }
else { self.storage[w] & !flag };
let val = if x { self.storage[w] | flag }
else { self.storage[w] & !flag };
self.storage[w] = val;
}
/// Sets all bits to 1.
@ -617,7 +618,7 @@ impl Bitv {
self.storage.truncate(word_len);
if len % u32::BITS > 0 {
let mask = (1 << len % u32::BITS) - 1;
*self.storage.get_mut(word_len - 1) &= mask;
self.storage[word_len - 1] &= mask;
}
}
}
@ -681,15 +682,15 @@ impl Bitv {
let overhang = self.nbits % u32::BITS; // # of already-used bits
let mask = !((1 << overhang) - 1); // e.g. 5 unused bits => 111110....0
if value {
*self.storage.get_mut(old_last_word) |= mask;
self.storage[old_last_word] |= mask;
} else {
*self.storage.get_mut(old_last_word) &= !mask;
self.storage[old_last_word] &= !mask;
}
}
// Fill in words after the old tail word
let stop_idx = cmp::min(self.storage.len(), new_nwords);
for idx in range(old_last_word + 1, stop_idx) {
*self.storage.get_mut(idx) = full_value;
self.storage[idx] = full_value;
}
// Allocate new words, if needed
if new_nwords > self.storage.len() {
@ -700,7 +701,7 @@ impl Bitv {
if value {
let tail_word = new_nwords - 1;
let used_bits = new_nbits % u32::BITS;
*self.storage.get_mut(tail_word) &= (1 << used_bits) - 1;
self.storage[tail_word] &= (1 << used_bits) - 1;
}
}
// Adjust internal bit count
@ -728,7 +729,7 @@ impl Bitv {
let ret = self.get(self.nbits - 1);
// If we are unusing a whole word, make sure it is zeroed out
if self.nbits % u32::BITS == 1 {
*self.storage.get_mut(self.nbits / u32::BITS) = 0;
self.storage[self.nbits / u32::BITS] = 0;
}
self.nbits -= 1;
ret
@ -1184,7 +1185,7 @@ impl BitvSet {
for (i, w) in other_words {
let old = self_bitv.storage[i];
let new = f(old, w);
*self_bitv.storage.get_mut(i) = new;
self_bitv.storage[i] = new;
}
}

View File

@ -690,6 +690,12 @@ impl<K: Ord, V> Index<K, V> for BTreeMap<K, V> {
}
}
impl<K: Ord, V> IndexMut<K, V> for BTreeMap<K, V> {
fn index_mut(&mut self, key: &K) -> &mut V {
self.find_mut(key).expect("no entry found for key")
}
}
/// Genericises over how to get the correct type of iterator from the correct type
/// of Node ownership.
trait Traverse<N> {

View File

@ -71,7 +71,7 @@
//! let mut pq = PriorityQueue::new();
//!
//! // We're at `start`, with a zero cost
//! *dist.get_mut(start) = 0u;
//! dist[start] = 0u;
//! pq.push(State { cost: 0u, position: start });
//!
//! // Examine the frontier with lower cost nodes first (min-heap)
@ -96,7 +96,7 @@
//! if next.cost < dist[next.position] {
//! pq.push(next);
//! // Relaxation, we have now found a better way
//! *dist.get_mut(next.position) = next.cost;
//! dist[next.position] = next.cost;
//! }
//! }
//! }
@ -151,7 +151,7 @@
//! }
//! ```
#![allow(missing_doc)]
#![allow(missing_docs)]
use core::prelude::*;
@ -330,7 +330,7 @@ impl<T: Ord> PriorityQueue<T> {
None => { None }
Some(mut item) => {
if !self.is_empty() {
swap(&mut item, self.data.get_mut(0));
swap(&mut item, &mut self.data[0]);
self.siftdown(0);
}
Some(item)
@ -378,7 +378,7 @@ impl<T: Ord> PriorityQueue<T> {
/// ```
pub fn push_pop(&mut self, mut item: T) -> T {
if !self.is_empty() && *self.top().unwrap() > item {
swap(&mut item, self.data.get_mut(0));
swap(&mut item, &mut self.data[0]);
self.siftdown(0);
}
item
@ -402,7 +402,7 @@ impl<T: Ord> PriorityQueue<T> {
/// ```
pub fn replace(&mut self, mut item: T) -> Option<T> {
if !self.is_empty() {
swap(&mut item, self.data.get_mut(0));
swap(&mut item, &mut self.data[0]);
self.siftdown(0);
Some(item)
} else {
@ -462,26 +462,26 @@ impl<T: Ord> PriorityQueue<T> {
// compared to using swaps, which involves twice as many moves.
fn siftup(&mut self, start: uint, mut pos: uint) {
unsafe {
let new = replace(self.data.get_mut(pos), zeroed());
let new = replace(&mut self.data[pos], zeroed());
while pos > start {
let parent = (pos - 1) >> 1;
if new > self.data[parent] {
let x = replace(self.data.get_mut(parent), zeroed());
ptr::write(self.data.get_mut(pos), x);
let x = replace(&mut self.data[parent], zeroed());
ptr::write(&mut self.data[pos], x);
pos = parent;
continue
}
break
}
ptr::write(self.data.get_mut(pos), new);
ptr::write(&mut self.data[pos], new);
}
}
fn siftdown_range(&mut self, mut pos: uint, end: uint) {
unsafe {
let start = pos;
let new = replace(self.data.get_mut(pos), zeroed());
let new = replace(&mut self.data[pos], zeroed());
let mut child = 2 * pos + 1;
while child < end {
@ -489,13 +489,13 @@ impl<T: Ord> PriorityQueue<T> {
if right < end && !(self.data[child] > self.data[right]) {
child = right;
}
let x = replace(self.data.get_mut(child), zeroed());
ptr::write(self.data.get_mut(pos), x);
let x = replace(&mut self.data[child], zeroed());
ptr::write(&mut self.data[pos], x);
pos = child;
child = 2 * pos + 1;
}
ptr::write(self.data.get_mut(pos), new);
ptr::write(&mut self.data[pos], new);
self.siftup(start, pos);
}
}

View File

@ -58,7 +58,7 @@ impl<T> Deque<T> for RingBuf<T> {
/// Returns a mutable reference to the first element in the `RingBuf`.
fn front_mut<'a>(&'a mut self) -> Option<&'a mut T> {
if self.nelts > 0 { Some(self.get_mut(0)) } else { None }
if self.nelts > 0 { Some(&mut self[0]) } else { None }
}
/// Returns a reference to the last element in the `RingBuf`.
@ -69,13 +69,13 @@ impl<T> Deque<T> for RingBuf<T> {
/// Returns a mutable reference to the last element in the `RingBuf`.
fn back_mut<'a>(&'a mut self) -> Option<&'a mut T> {
let nelts = self.nelts;
if nelts > 0 { Some(self.get_mut(nelts - 1)) } else { None }
if nelts > 0 { Some(&mut self[nelts - 1]) } else { None }
}
/// Removes and returns the first element in the `RingBuf`, or `None` if it
/// is empty.
fn pop_front(&mut self) -> Option<T> {
let result = self.elts.get_mut(self.lo).take();
let result = self.elts[self.lo].take();
if result.is_some() {
self.lo = (self.lo + 1u) % self.elts.len();
self.nelts -= 1u;
@ -91,7 +91,7 @@ impl<T> Deque<T> for RingBuf<T> {
if self.lo == 0u {
self.lo = self.elts.len() - 1u;
} else { self.lo -= 1u; }
*self.elts.get_mut(self.lo) = Some(t);
self.elts[self.lo] = Some(t);
self.nelts += 1u;
}
}
@ -102,14 +102,14 @@ impl<T> MutableSeq<T> for RingBuf<T> {
grow(self.nelts, &mut self.lo, &mut self.elts);
}
let hi = self.raw_index(self.nelts);
*self.elts.get_mut(hi) = Some(t);
self.elts[hi] = Some(t);
self.nelts += 1u;
}
fn pop(&mut self) -> Option<T> {
if self.nelts > 0 {
self.nelts -= 1;
let hi = self.raw_index(self.nelts);
self.elts.get_mut(hi).take()
self.elts[hi].take()
} else {
None
}
@ -140,6 +140,7 @@ impl<T> RingBuf<T> {
/// # Example
///
/// ```rust
/// # #![allow(deprecated)]
/// use std::collections::RingBuf;
///
/// let mut buf = RingBuf::new();
@ -149,12 +150,9 @@ impl<T> RingBuf<T> {
/// *buf.get_mut(1) = 7;
/// assert_eq!(buf[1], 7);
/// ```
#[deprecated = "use indexing instead: `buf[index] = value`"]
pub fn get_mut<'a>(&'a mut self, i: uint) -> &'a mut T {
let idx = self.raw_index(i);
match *self.elts.get_mut(idx) {
None => panic!(),
Some(ref mut v) => v
}
&mut self[i]
}
/// Swaps elements at indices `i` and `j`.
@ -466,13 +464,16 @@ impl<A> Index<uint, A> for RingBuf<A> {
}
}
// FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
/*impl<A> IndexMut<uint, A> for RingBuf<A> {
impl<A> IndexMut<uint, A> for RingBuf<A> {
#[inline]
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut A {
self.get_mut(*index)
fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut A {
let idx = self.raw_index(*i);
match *(&mut self.elts[idx]) {
None => panic!(),
Some(ref mut v) => v
}
}
}*/
}
impl<A> FromIterator<A> for RingBuf<A> {
fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {

View File

@ -109,7 +109,7 @@ pub use core::slice::{Found, NotFound};
// Functional utilities
#[allow(missing_doc)]
#[allow(missing_docs)]
pub trait VectorVector<T> for Sized? {
// FIXME #5898: calling these .concat and .connect conflicts with
// StrVector::con{cat,nect}, since they have generic contents.

View File

@ -11,7 +11,7 @@
//! A simple map based on a vector for small integer keys. Space requirements
//! are O(highest integer key).
#![allow(missing_doc)]
#![allow(missing_docs)]
use core::prelude::*;
@ -100,7 +100,7 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
/// Returns a mutable reference to the value corresponding to the key.
fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V> {
if *key < self.v.len() {
match *self.v.get_mut(*key) {
match *self.v.index_mut(key) {
Some(ref mut value) => Some(value),
None => None
}
@ -118,7 +118,7 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
if len <= key {
self.v.grow_fn(key - len + 1, |_| None);
}
*self.v.get_mut(key) = Some(value);
self.v[key] = Some(value);
!exists
}
@ -145,7 +145,7 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
if *key >= self.v.len() {
return None;
}
self.v.get_mut(*key).take()
self.v[*key].take()
}
}
@ -405,13 +405,12 @@ impl<V> Index<uint, V> for SmallIntMap<V> {
}
}
// FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
/*impl<V> IndexMut<uint, V> for SmallIntMap<V> {
impl<V> IndexMut<uint, V> for SmallIntMap<V> {
#[inline]
fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut V {
self.find_mut(i).expect("key not present")
}
}*/
}
macro_rules! iterator {
(impl $name:ident -> $elem:ty, $($getter:ident),+) => {

View File

@ -692,17 +692,17 @@ pub trait StrAllocating: Str {
for (i, sc) in me.chars().enumerate() {
let mut current = i;
*dcol.get_mut(0) = current + 1;
dcol[0] = current + 1;
for (j, tc) in t.chars().enumerate() {
let next = dcol[j + 1];
if sc == tc {
*dcol.get_mut(j + 1) = current;
dcol[j + 1] = current;
} else {
*dcol.get_mut(j + 1) = cmp::min(current, next);
*dcol.get_mut(j + 1) = cmp::min(dcol[j + 1], dcol[j]) + 1;
dcol[j + 1] = cmp::min(current, next);
dcol[j + 1] = cmp::min(dcol[j + 1], dcol[j]) + 1;
}
current = next;
@ -1677,40 +1677,6 @@ mod tests {
assert_eq!(pos, p.len());
}
#[test]
fn test_split_char_iterator() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
let split: Vec<&str> = data.split(' ').collect();
assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let mut rsplit: Vec<&str> = data.split(' ').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let split: Vec<&str> = data.split(|c: char| c == ' ').collect();
assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let mut rsplit: Vec<&str> = data.split(|c: char| c == ' ').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
// Unicode
let split: Vec<&str> = data.split('ä').collect();
assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let mut rsplit: Vec<&str> = data.split('ä').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let split: Vec<&str> = data.split(|c: char| c == 'ä').collect();
assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let mut rsplit: Vec<&str> = data.split(|c: char| c == 'ä').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
}
#[test]
fn test_splitn_char_iterator() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
@ -1729,28 +1695,6 @@ mod tests {
assert_eq!(split, vec!["\nM", "ry h", "d ", " little lämb\nLittle lämb\n"]);
}
#[test]
fn test_rsplitn_char_iterator() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
let mut split: Vec<&str> = data.rsplitn(3, ' ').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == ' ').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
// Unicode
let mut split: Vec<&str> = data.rsplitn(3, 'ä').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == 'ä').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
}
#[test]
fn test_split_char_iterator_no_trailing() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
@ -1762,19 +1706,6 @@ mod tests {
assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb"]);
}
#[test]
fn test_rev_split_char_iterator_no_trailing() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
let mut split: Vec<&str> = data.split('\n').rev().collect();
split.reverse();
assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb", ""]);
let mut split: Vec<&str> = data.split_terminator('\n').rev().collect();
split.reverse();
assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb"]);
}
#[test]
fn test_words() {
let data = "\n \tMäry häd\tä little lämb\nLittle lämb\n";

View File

@ -744,6 +744,11 @@ impl ops::Slice<uint, str> for String {
}
}
#[experimental = "waiting on Deref stabilization"]
impl ops::Deref<str> for String {
fn deref<'a>(&'a self) -> &'a str { self.as_slice() }
}
/// Wrapper type providing a `&String` reference via `Deref`.
#[experimental]
pub struct DerefString<'a> {

View File

@ -257,12 +257,12 @@ impl<K: Ord, V> Index<K, V> for TreeMap<K, V> {
}
}
/*impl<K: Ord, V> IndexMut<K, V> for TreeMap<K, V> {
impl<K: Ord, V> IndexMut<K, V> for TreeMap<K, V> {
#[inline]
fn index_mut<'a>(&'a mut self, i: &K) -> &'a mut V {
self.find_mut(i).expect("no entry found for key")
}
}*/
}
impl<K: Ord, V> TreeMap<K, V> {
/// Creates an empty `TreeMap`.

View File

@ -515,13 +515,12 @@ impl<T> Index<uint, T> for TrieMap<T> {
}
}
// FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
/*impl<T> IndexMut<uint, T> for TrieMap<T> {
impl<T> IndexMut<uint, T> for TrieMap<T> {
#[inline]
fn index_mut<'a>(&'a mut self, i: &uint) -> &'a mut T {
self.find_mut(i).expect("key not present")
}
}*/
}
/// A set implemented as a radix trie.
///

View File

@ -28,8 +28,7 @@ use core::raw::Slice as RawSlice;
use core::uint;
use {Mutable, MutableSeq};
use slice::{MutableOrdSlice, MutableSliceAllocating, CloneableVector};
use slice::{Items, MutItems};
use slice::{CloneableVector};
/// An owned, growable vector.
///
@ -46,7 +45,7 @@ use slice::{Items, MutItems};
/// assert_eq!(vec.pop(), Some(2));
/// assert_eq!(vec.len(), 1);
///
/// *vec.get_mut(0) = 7i;
/// vec[0] = 7i;
/// assert_eq!(vec[0], 7);
///
/// vec.push_all([1, 2, 3]);
@ -414,11 +413,10 @@ impl<T> Index<uint,T> for Vec<T> {
}
}
#[cfg(not(stage0))]
impl<T> IndexMut<uint,T> for Vec<T> {
#[inline]
fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
self.get_mut(*index)
&mut self.as_mut_slice()[*index]
}
}
@ -464,6 +462,16 @@ impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
}
}
#[experimental = "waiting on Deref stability"]
impl<T> ops::Deref<[T]> for Vec<T> {
fn deref<'a>(&'a self) -> &'a [T] { self.as_slice() }
}
#[experimental = "waiting on DerefMut stability"]
impl<T> ops::DerefMut<[T]> for Vec<T> {
fn deref_mut<'a>(&'a mut self) -> &'a mut [T] { self.as_mut_slice() }
}
#[experimental = "waiting on FromIterator stability"]
impl<T> FromIterator<T> for Vec<T> {
#[inline]
@ -712,14 +720,6 @@ impl<T> Vec<T> {
}
}
/// Deprecated, use `.extend(other.into_iter())`
#[inline]
#[deprecated = "use .extend(other.into_iter())"]
#[cfg(stage0)]
pub fn push_all_move(&mut self, other: Vec<T>) {
self.extend(other.into_iter());
}
/// Returns a mutable slice of the elements of `self`.
///
/// # Example
@ -735,7 +735,7 @@ impl<T> Vec<T> {
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
unsafe {
mem::transmute(RawSlice {
data: self.as_mut_ptr() as *const T,
data: self.ptr as *const T,
len: self.len,
})
}
@ -799,134 +799,17 @@ impl<T> Vec<T> {
/// # Example
///
/// ```
/// # #![allow(deprecated)]
/// let mut vec = vec![1i, 2, 3];
/// *vec.get_mut(1) = 4;
/// assert_eq!(vec, vec![1i, 4, 3]);
/// ```
#[inline]
#[unstable = "this is likely to be moved to actual indexing"]
#[deprecated = "use `foo[index] = bar` instead"]
pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut T {
&mut self.as_mut_slice()[index]
}
/// Returns an iterator over references to the elements of the vector in
/// order.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3];
/// for num in vec.iter() {
/// println!("{}", *num);
/// }
/// ```
#[inline]
pub fn iter<'a>(&'a self) -> Items<'a,T> {
self.as_slice().iter()
}
/// Returns an iterator over mutable references to the elements of the
/// vector in order.
///
/// # Example
///
/// ```
/// let mut vec = vec![1i, 2, 3];
/// for num in vec.iter_mut() {
/// *num = 0;
/// }
/// assert_eq!(vec, vec![0i, 0, 0]);
/// ```
#[inline]
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a,T> {
self.as_mut_slice().iter_mut()
}
/// Sorts the vector, in place, using `compare` to compare elements.
///
/// This sort is `O(n log n)` worst-case and stable, but allocates
/// approximately `2 * n`, where `n` is the length of `self`.
///
/// # Example
///
/// ```
/// let mut v = vec![5i, 4, 1, 3, 2];
/// v.sort_by(|a, b| a.cmp(b));
/// assert_eq!(v, vec![1i, 2, 3, 4, 5]);
///
/// // reverse sorting
/// v.sort_by(|a, b| b.cmp(a));
/// assert_eq!(v, vec![5i, 4, 3, 2, 1]);
/// ```
#[inline]
pub fn sort_by(&mut self, compare: |&T, &T| -> Ordering) {
self.as_mut_slice().sort_by(compare)
}
/// Returns a slice of self spanning the interval [`start`, `end`).
///
/// # Failure
///
/// Fails when the slice (or part of it) is outside the bounds of self, or when
/// `start` > `end`.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3, 4];
/// assert!(vec[0..2] == [1, 2]);
/// ```
#[inline]
pub fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [T] {
self[start..end]
}
/// Returns a slice containing all but the first element of the vector.
///
/// # Failure
///
/// Fails when the vector is empty.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3];
/// assert!(vec.tail() == [2, 3]);
/// ```
#[inline]
pub fn tail<'a>(&'a self) -> &'a [T] {
self[].tail()
}
/// Returns a reference to the last element of a vector, or `None` if it is
/// empty.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3];
/// assert!(vec.last() == Some(&3));
/// ```
#[inline]
pub fn last<'a>(&'a self) -> Option<&'a T> {
self[].last()
}
/// Returns a mutable reference to the last element of a vector, or `None`
/// if it is empty.
///
/// # Example
///
/// ```
/// let mut vec = vec![1i, 2, 3];
/// *vec.last_mut().unwrap() = 4;
/// assert_eq!(vec, vec![1i, 2, 4]);
/// ```
#[inline]
pub fn last_mut<'a>(&'a mut self) -> Option<&'a mut T> {
self.as_mut_slice().last_mut()
}
/// Removes an element from anywhere in the vector and return it, replacing
/// it with the last element. This does not preserve ordering, but is O(1).
///
@ -1035,215 +918,6 @@ impl<T> Vec<T> {
}
}
/// Returns a mutable slice of `self` between `start` and `end`.
///
/// # Failure
///
/// Fails when `start` or `end` point outside the bounds of `self`, or when
/// `start` > `end`.
///
/// # Example
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
/// assert!(vec[mut 0..2] == [1, 2]);
/// ```
#[inline]
pub fn slice_mut<'a>(&'a mut self, start: uint, end: uint)
-> &'a mut [T] {
self[mut start..end]
}
/// Returns a mutable slice of `self` from `start` to the end of the `Vec`.
///
/// # Failure
///
/// Fails when `start` points outside the bounds of self.
///
/// # Example
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
/// assert!(vec[mut 2..] == [3, 4]);
/// ```
#[inline]
pub fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] {
self[mut start..]
}
/// Returns a mutable slice of `self` from the start of the `Vec` to `end`.
///
/// # Failure
///
/// Fails when `end` points outside the bounds of self.
///
/// # Example
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
/// assert!(vec[mut ..2] == [1, 2]);
/// ```
#[inline]
pub fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T] {
self[mut ..end]
}
/// Returns a pair of mutable slices that divides the `Vec` at an index.
///
/// The first will contain all indices from `[0, mid)` (excluding
/// the index `mid` itself) and the second will contain all
/// indices from `[mid, len)` (excluding the index `len` itself).
///
/// # Failure
///
/// Fails if `mid > len`.
///
/// # Example
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4, 5, 6];
///
/// // scoped to restrict the lifetime of the borrows
/// {
/// let (left, right) = vec.split_at_mut(0);
/// assert!(left == &mut []);
/// assert!(right == &mut [1, 2, 3, 4, 5, 6]);
/// }
///
/// {
/// let (left, right) = vec.split_at_mut(2);
/// assert!(left == &mut [1, 2]);
/// assert!(right == &mut [3, 4, 5, 6]);
/// }
///
/// {
/// let (left, right) = vec.split_at_mut(6);
/// assert!(left == &mut [1, 2, 3, 4, 5, 6]);
/// assert!(right == &mut []);
/// }
/// ```
#[inline]
pub fn split_at_mut<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) {
self[mut].split_at_mut(mid)
}
/// Reverses the order of elements in a vector, in place.
///
/// # Example
///
/// ```
/// let mut v = vec![1i, 2, 3];
/// v.reverse();
/// assert_eq!(v, vec![3i, 2, 1]);
/// ```
#[inline]
pub fn reverse(&mut self) {
self[mut].reverse()
}
/// Returns a slice of `self` from `start` to the end of the vec.
///
/// # Failure
///
/// Fails when `start` points outside the bounds of self.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3];
/// assert!(vec[1..] == [2, 3]);
/// ```
#[inline]
pub fn slice_from<'a>(&'a self, start: uint) -> &'a [T] {
self[start..]
}
/// Returns a slice of self from the start of the vec to `end`.
///
/// # Failure
///
/// Fails when `end` points outside the bounds of self.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3, 4];
/// assert!(vec[..2] == [1, 2]);
/// ```
#[inline]
pub fn slice_to<'a>(&'a self, end: uint) -> &'a [T] {
self[..end]
}
/// Returns a slice containing all but the last element of the vector.
///
/// # Failure
///
/// Fails if the vector is empty
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3];
/// assert!(vec.init() == [1, 2]);
/// ```
#[inline]
pub fn init<'a>(&'a self) -> &'a [T] {
self[0..self.len() - 1]
}
/// Returns an unsafe pointer to the vector's buffer.
///
/// The caller must ensure that the vector outlives the pointer this
/// function returns, or else it will end up pointing to garbage.
///
/// Modifying the vector may cause its buffer to be reallocated, which
/// would also make any pointers to it invalid.
///
/// # Example
///
/// ```
/// let v = vec![1i, 2, 3];
/// let p = v.as_ptr();
/// unsafe {
/// // Examine each element manually
/// assert_eq!(*p, 1i);
/// assert_eq!(*p.offset(1), 2i);
/// assert_eq!(*p.offset(2), 3i);
/// }
/// ```
#[inline]
pub fn as_ptr(&self) -> *const T {
self.ptr as *const T
}
/// Returns a mutable unsafe pointer to the vector's buffer.
///
/// The caller must ensure that the vector outlives the pointer this
/// function returns, or else it will end up pointing to garbage.
///
/// Modifying the vector may cause its buffer to be reallocated, which
/// would also make any pointers to it invalid.
///
/// # Example
///
/// ```
/// use std::ptr;
///
/// let mut v = vec![1i, 2, 3];
/// let p = v.as_mut_ptr();
/// unsafe {
/// ptr::write(p, 9i);
/// ptr::write(p.offset(2), 5i);
/// }
/// assert_eq!(v, vec![9i, 2, 5]);
/// ```
#[inline]
pub fn as_mut_ptr(&mut self) -> *mut T {
self.ptr
}
/// Retains only the elements specified by the predicate.
///
/// In other words, remove all elements `e` such that `f(&e)` returns false.
@ -1297,24 +971,6 @@ impl<T> Vec<T> {
}
}
impl<T:Ord> Vec<T> {
/// Sorts the vector in place.
///
/// This sort is `O(n log n)` worst-case and stable, but allocates
/// approximately `2 * n`, where `n` is the length of `self`.
///
/// # Example
///
/// ```
/// let mut vec = vec![3i, 1, 2];
/// vec.sort();
/// assert_eq!(vec, vec![1, 2, 3]);
/// ```
pub fn sort(&mut self) {
self.as_mut_slice().sort()
}
}
#[experimental = "waiting on Mutable stability"]
impl<T> Mutable for Vec<T> {
#[inline]
@ -1325,19 +981,6 @@ impl<T> Mutable for Vec<T> {
}
impl<T: PartialEq> Vec<T> {
/// Returns true if a vector contains an element equal to the given value.
///
/// # Example
///
/// ```
/// let vec = vec![1i, 2, 3];
/// assert!(vec.contains(&1));
/// ```
#[inline]
pub fn contains(&self, x: &T) -> bool {
self.as_slice().contains(x)
}
/// Removes consecutive repeated elements in the vector.
///
/// If the vector is sorted, this removes all duplicates.
@ -1449,7 +1092,12 @@ impl<T> AsSlice<T> for Vec<T> {
#[inline]
#[stable]
fn as_slice<'a>(&'a self) -> &'a [T] {
unsafe { mem::transmute(RawSlice { data: self.as_ptr(), len: self.len }) }
unsafe {
mem::transmute(RawSlice {
data: self.ptr as *const T,
len: self.len
})
}
}
}
@ -1697,6 +1345,7 @@ pub fn as_vec<'a, T>(x: &'a [T]) -> DerefVec<'a, T> {
pub mod raw {
use super::Vec;
use core::ptr;
use core::slice::MutableSlice;
/// Constructs a vector from an unsafe pointer to a buffer.
///

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(missing_doc)]
#![allow(missing_docs)]
use char;
use collections::Collection;

View File

@ -10,7 +10,7 @@
//! Utilities for formatting and printing strings
#![allow(unused_variable)]
#![allow(unused_variables)]
use any;
use cell::{Cell, Ref, RefMut};
@ -733,7 +733,7 @@ macro_rules! tuple (
() => ();
( $($name:ident,)+ ) => (
impl<$($name:Show),*> Show for ($($name,)*) {
#[allow(non_snake_case, dead_assignment)]
#[allow(non_snake_case, unused_assignments)]
fn fmt(&self, f: &mut Formatter) -> Result {
try!(write!(f, "("));
let ($(ref $name,)*) = *self;

View File

@ -12,7 +12,7 @@
// FIXME: #6220 Implement floating point formatting
#![allow(unsigned_negate)]
#![allow(unsigned_negation)]
use collections::Collection;
use fmt;

View File

@ -42,7 +42,7 @@ A quick refresher on memory ordering:
*/
#![experimental]
#![allow(missing_doc)]
#![allow(missing_docs)]
pub type GlueFn = extern "Rust" fn(*const i8);
@ -57,107 +57,10 @@ pub struct TyDesc {
// Called when a value of type `T` is no longer needed
pub drop_glue: GlueFn,
// Called by reflection visitor to visit a value of type `T`
#[cfg(stage0)]
pub visit_glue: GlueFn,
// Name corresponding to the type
pub name: &'static str,
}
#[cfg(stage0)]
#[lang="opaque"]
pub enum Opaque { }
#[cfg(stage0)]
pub type Disr = u64;
#[cfg(stage0)]
#[lang="ty_visitor"]
pub trait TyVisitor {
fn visit_bot(&mut self) -> bool;
fn visit_nil(&mut self) -> bool;
fn visit_bool(&mut self) -> bool;
fn visit_int(&mut self) -> bool;
fn visit_i8(&mut self) -> bool;
fn visit_i16(&mut self) -> bool;
fn visit_i32(&mut self) -> bool;
fn visit_i64(&mut self) -> bool;
fn visit_uint(&mut self) -> bool;
fn visit_u8(&mut self) -> bool;
fn visit_u16(&mut self) -> bool;
fn visit_u32(&mut self) -> bool;
fn visit_u64(&mut self) -> bool;
fn visit_f32(&mut self) -> bool;
fn visit_f64(&mut self) -> bool;
fn visit_char(&mut self) -> bool;
fn visit_estr_slice(&mut self) -> bool;
fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_uniq(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_ptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_rptr(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_evec_slice(&mut self, mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
inner: *const TyDesc) -> bool;
fn visit_enter_rec(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool;
fn visit_rec_field(&mut self, i: uint, name: &str,
mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_leave_rec(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool;
fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
sz: uint, align: uint) -> bool;
fn visit_class_field(&mut self, i: uint, name: &str, named: bool,
mtbl: uint, inner: *const TyDesc) -> bool;
fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
sz: uint, align: uint) -> bool;
fn visit_enter_tup(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool;
fn visit_tup_field(&mut self, i: uint, inner: *const TyDesc) -> bool;
fn visit_leave_tup(&mut self, n_fields: uint,
sz: uint, align: uint) -> bool;
fn visit_enter_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
sz: uint, align: uint) -> bool;
fn visit_enter_enum_variant(&mut self, variant: uint,
disr_val: Disr,
n_fields: uint,
name: &str) -> bool;
fn visit_enum_variant_field(&mut self, i: uint, offset: uint,
inner: *const TyDesc) -> bool;
fn visit_leave_enum_variant(&mut self, variant: uint,
disr_val: Disr,
n_fields: uint,
name: &str) -> bool;
fn visit_leave_enum(&mut self, n_variants: uint,
get_disr: unsafe extern fn(ptr: *const Opaque) -> Disr,
sz: uint, align: uint) -> bool;
fn visit_enter_fn(&mut self, purity: uint, proto: uint,
n_inputs: uint, retstyle: uint) -> bool;
fn visit_fn_input(&mut self, i: uint, mode: uint,
inner: *const TyDesc) -> bool;
fn visit_fn_output(&mut self, retstyle: uint, variadic: bool,
converging: bool, inner: *const TyDesc) -> bool;
fn visit_leave_fn(&mut self, purity: uint, proto: uint,
n_inputs: uint, retstyle: uint) -> bool;
fn visit_trait(&mut self, name: &str) -> bool;
fn visit_param(&mut self, i: uint) -> bool;
fn visit_self(&mut self) -> bool;
}
extern "rust-intrinsic" {
// NB: These intrinsics take unsafe pointers because they mutate aliased

View File

@ -60,7 +60,7 @@
#![allow(unknown_features)]
#![feature(globs, intrinsics, lang_items, macro_rules, phase)]
#![feature(simd, unsafe_destructor, slicing_syntax)]
#![deny(missing_doc)]
#![deny(missing_docs)]
mod macros;

View File

@ -12,7 +12,7 @@
#![doc(primitive = "f32")]
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
#![allow(type_overflow)]
#![allow(overflowing_literals)]
use intrinsics;
use mem;

View File

@ -12,7 +12,7 @@
#![doc(primitive = "f64")]
// FIXME: MIN_VALUE and MAX_VALUE literals are parsed as -inf and inf #14353
#![allow(type_overflow)]
#![allow(overflowing_literals)]
use intrinsics;
use mem;

View File

@ -12,7 +12,7 @@
//! Numeric traits and functions for generic mathematics
#![allow(missing_doc)]
#![allow(missing_docs)]
use intrinsics;
use {int, i8, i16, i32, i64};
@ -1353,7 +1353,7 @@ checked_impl!(CheckedMul, checked_mul, i64, intrinsics::i64_mul_with_overflow)
/// wrapping around on underflow and overflow.
pub trait CheckedDiv: Div<Self, Self> {
/// Divides two numbers, checking for underflow, overflow and division by zero. If any of that
/// happens, / `None` is returned.
/// happens, `None` is returned.
///
/// # Example
///
@ -1502,7 +1502,7 @@ pub trait Float: Signed + Primitive {
/// Take the square root of a number.
///
/// Returns NaN if `self` is not a non-negative number.
/// Returns NaN if `self` is a negative number.
fn sqrt(self) -> Self;
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
fn rsqrt(self) -> Self;

View File

@ -28,7 +28,7 @@
//! one function. Currently, the actual symbol is declared in the standard
//! library, but the location of this may change over time.
#![allow(dead_code, missing_doc)]
#![allow(dead_code, missing_docs)]
use fmt;
use intrinsics;
@ -63,7 +63,7 @@ fn panic_bounds_check(file_line: &(&'static str, uint),
#[cfg(stage0)]
#[cold] #[inline(never)]
pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
#[allow(ctypes)]
#[allow(improper_ctypes)]
extern {
#[lang = "fail_fmt"]
fn panic_impl(fmt: &fmt::Arguments, file: &'static str,
@ -104,7 +104,7 @@ fn panic_bounds_check(file_line: &(&'static str, uint),
#[cfg(not(stage0))]
#[cold] #[inline(never)]
pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
#[allow(ctypes)]
#[allow(improper_ctypes)]
extern {
#[lang = "panic_fmt"]
fn panic_impl(fmt: &fmt::Arguments, file: &'static str,

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(missing_doc)]
#![allow(missing_docs)]
#![experimental]
//! Contains struct definitions for the layout of compiler built-in types.

View File

@ -35,7 +35,7 @@
//! warning.
#![allow(non_camel_case_types)]
#![allow(missing_doc)]
#![allow(missing_docs)]
#[experimental]
#[simd]

View File

@ -768,7 +768,7 @@ Section: Comparing strings
/// to compare &[u8] byte slices that are not necessarily valid UTF-8.
#[inline]
fn eq_slice_(a: &str, b: &str) -> bool {
#[allow(ctypes)]
#[allow(improper_ctypes)]
extern { fn memcmp(s1: *const i8, s2: *const i8, n: uint) -> i32; }
a.len() == b.len() && unsafe {
memcmp(a.as_ptr() as *const i8,
@ -1118,7 +1118,7 @@ pub mod raw {
Section: Trait implementations
*/
#[allow(missing_doc)]
#[allow(missing_docs)]
pub mod traits {
use cmp::{Ord, Ordering, Less, Equal, Greater, PartialEq, PartialOrd, Equiv, Eq};
use collections::Collection;

View File

@ -81,7 +81,7 @@ macro_rules! tuple_impls {
}
)+) => {
$(
#[allow(missing_doc)]
#[allow(missing_docs)]
#[stable]
pub trait $Tuple<$($T),+> {
$(
@ -97,21 +97,21 @@ macro_rules! tuple_impls {
impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
$(
#[inline]
#[allow(unused_variable)]
#[allow(unused_variables)]
#[unstable = "may rename pending accessor naming conventions"]
fn $valN(self) -> $T {
let ($($x,)+) = self; $ret
}
#[inline]
#[allow(unused_variable)]
#[allow(unused_variables)]
#[unstable = "may rename pending accessor naming conventions"]
fn $refN<'a>(&'a self) -> &'a $T {
let ($(ref $x,)+) = *self; $ret
}
#[inline]
#[allow(unused_variable)]
#[allow(unused_variables)]
#[unstable = "may rename pending accessor naming conventions"]
fn $mutN<'a>(&'a mut self) -> &'a mut $T {
let ($(ref mut $x,)+) = *self; $ret

View File

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(unsigned_negate)]
#![allow(unsigned_negation)]
use core::fmt::radix;

View File

@ -38,3 +38,72 @@ fn test_strslice_contains() {
let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
check_contains_all_substrings(x);
}
#[test]
fn test_rsplitn_char_iterator() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
let mut split: Vec<&str> = data.rsplitn(3, ' ').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == ' ').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ä", "little", "lämb\nLittle", "lämb\n"]);
// Unicode
let mut split: Vec<&str> = data.rsplitn(3, 'ä').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
let mut split: Vec<&str> = data.rsplitn(3, |c: char| c == 'ä').collect();
split.reverse();
assert_eq!(split, vec!["\nMäry häd ", " little l", "mb\nLittle l", "mb\n"]);
}
#[test]
fn test_split_char_iterator() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
let split: Vec<&str> = data.split(' ').collect();
assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let mut rsplit: Vec<&str> = data.split(' ').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let split: Vec<&str> = data.split(|c: char| c == ' ').collect();
assert_eq!( split, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
let mut rsplit: Vec<&str> = data.split(|c: char| c == ' ').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nMäry", "häd", "ä", "little", "lämb\nLittle", "lämb\n"]);
// Unicode
let split: Vec<&str> = data.split('ä').collect();
assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let mut rsplit: Vec<&str> = data.split('ä').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let split: Vec<&str> = data.split(|c: char| c == 'ä').collect();
assert_eq!( split, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
let mut rsplit: Vec<&str> = data.split(|c: char| c == 'ä').rev().collect();
rsplit.reverse();
assert_eq!(rsplit, vec!["\nM", "ry h", "d ", " little l", "mb\nLittle l", "mb\n"]);
}
#[test]
fn test_rev_split_char_iterator_no_trailing() {
let data = "\nMäry häd ä little lämb\nLittle lämb\n";
let mut split: Vec<&str> = data.split('\n').rev().collect();
split.reverse();
assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb", ""]);
let mut split: Vec<&str> = data.split_terminator('\n').rev().collect();
split.reverse();
assert_eq!(split, vec!["", "Märy häd ä little lämb", "Little lämb"]);
}

View File

@ -89,7 +89,7 @@
html_playground_url = "http://play.rust-lang.org/")]
#![feature(globs, phase)]
#![feature(import_shadowing)]
#![deny(missing_doc)]
#![deny(missing_docs)]
#[cfg(test)] #[phase(plugin, link)] extern crate log;
@ -201,7 +201,7 @@ pub enum Fail_ {
/// The type of failure that occurred.
#[deriving(PartialEq, Eq)]
#[allow(missing_doc)]
#[allow(missing_docs)]
pub enum FailType {
ArgumentMissing_,
UnrecognizedOption_,
@ -614,29 +614,29 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
if name_pos == names.len() && !i_arg.is_none() {
return Err(UnexpectedArgument(nm.to_string()));
}
vals.get_mut(optid).push(Given);
vals[optid].push(Given);
}
Maybe => {
if !i_arg.is_none() {
vals.get_mut(optid)
vals[optid]
.push(Val((i_arg.clone())
.unwrap()));
} else if name_pos < names.len() || i + 1 == l ||
is_arg(args[i + 1].as_slice()) {
vals.get_mut(optid).push(Given);
vals[optid].push(Given);
} else {
i += 1;
vals.get_mut(optid).push(Val(args[i].clone()));
vals[optid].push(Val(args[i].clone()));
}
}
Yes => {
if !i_arg.is_none() {
vals.get_mut(optid).push(Val(i_arg.clone().unwrap()));
vals[optid].push(Val(i_arg.clone().unwrap()));
} else if i + 1 == l {
return Err(ArgumentMissing(nm.to_string()));
} else {
i += 1;
vals.get_mut(optid).push(Val(args[i].clone()));
vals[optid].push(Val(args[i].clone()));
}
}
}

View File

@ -58,7 +58,7 @@ impl<'a,T> IntoMaybeOwnedVector<'a,T> for &'a [T] {
impl<'a,T> MaybeOwnedVector<'a,T> {
pub fn iter(&'a self) -> slice::Items<'a,T> {
match self {
&Growable(ref v) => v.iter(),
&Growable(ref v) => v.as_slice().iter(),
&Borrowed(ref v) => v.iter(),
}
}

View File

@ -75,8 +75,8 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_uppercase_statics)]
#![allow(missing_doc)]
#![allow(non_upper_case_globals)]
#![allow(missing_docs)]
#![allow(non_snake_case)]
extern crate core;

View File

@ -167,7 +167,7 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(macro_rules)]
#![deny(missing_doc)]
#![deny(missing_docs)]
extern crate regex;

View File

@ -10,7 +10,7 @@
//! C definitions used by libnative that don't belong in liblibc
#![allow(type_overflow)]
#![allow(overflowing_literals)]
use libc;

View File

@ -79,7 +79,7 @@ fn helper(input: libc::HANDLE, messages: Receiver<Req>, _: ()) {
}
} else {
let remove = {
match chans.get_mut(idx as uint - 1) {
match &mut chans[idx as uint - 1] {
&(ref mut c, oneshot) => { c.call(); oneshot }
}
};

View File

@ -55,7 +55,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![deny(unused_result, unused_must_use)]
#![deny(unused_results, unused_must_use)]
#![allow(non_camel_case_types)]
#![allow(unknown_features)]
#![feature(default_type_params, lang_items, slicing_syntax)]

View File

@ -118,7 +118,7 @@ impl IsaacRng {
/// Refills the output buffer (`self.rsl`)
#[inline]
#[allow(unsigned_negate)]
#[allow(unsigned_negation)]
fn isaac(&mut self) {
self.c += 1;
// abbreviations

View File

@ -26,7 +26,7 @@
html_playground_url = "http://play.rust-lang.org/")]
#![allow(unknown_features)]
#![feature(macro_rules, phase, slicing_syntax)]
#![allow(missing_doc)]
#![allow(missing_docs)]
extern crate serialize;

View File

@ -157,7 +157,7 @@ impl<'r> Compiler<'r> {
if cap >= len {
self.names.grow(10 + cap - len, None)
}
*self.names.get_mut(cap) = name;
self.names[cap] = name;
self.push(Save(2 * cap));
self.compile(*x);
@ -243,7 +243,7 @@ impl<'r> Compiler<'r> {
/// `panic!` is called.
#[inline]
fn set_split(&mut self, i: InstIdx, pc1: InstIdx, pc2: InstIdx) {
let split = self.insts.get_mut(i);
let split = &mut self.insts[i];
match *split {
Split(_, _) => *split = Split(pc1, pc2),
_ => panic!("BUG: Invalid split index."),
@ -263,7 +263,7 @@ impl<'r> Compiler<'r> {
/// `panic!` is called.
#[inline]
fn set_jump(&mut self, i: InstIdx, pc: InstIdx) {
let jmp = self.insts.get_mut(i);
let jmp = &mut self.insts[i];
match *jmp {
Jump(_) => *jmp = Jump(pc),
_ => panic!("BUG: Invalid jump index."),

View File

@ -370,7 +370,7 @@
#![allow(unknown_features)]
#![feature(macro_rules, phase, slicing_syntax)]
#![deny(missing_doc)]
#![deny(missing_docs)]
#[cfg(test)]
extern crate "test" as stdtest;

View File

@ -978,7 +978,7 @@ fn combine_ranges(unordered: Vec<(char, char)>) -> Vec<(char, char)> {
}
match which {
None => ordered.push((us, ue)),
Some(i) => *ordered.get_mut(i) = (us, ue),
Some(i) => ordered[i] = (us, ue),
}
}
ordered.sort();

View File

@ -461,13 +461,13 @@ impl Threads {
}
fn add(&mut self, pc: uint, groups: &[Option<uint>], empty: bool) {
let t = self.queue.get_mut(self.size);
let t = &mut self.queue[self.size];
t.pc = pc;
match (empty, self.which) {
(_, Exists) | (true, _) => {},
(false, Location) => {
*t.groups.get_mut(0) = groups[0];
*t.groups.get_mut(1) = groups[1];
t.groups[0] = groups[0];
t.groups[1] = groups[1];
}
(false, Submatches) => {
for (slot, val) in t.groups.iter_mut().zip(groups.iter()) {
@ -475,7 +475,7 @@ impl Threads {
}
}
}
*self.sparse.get_mut(pc) = self.size;
self.sparse[pc] = self.size;
self.size += 1;
}
@ -497,7 +497,7 @@ impl Threads {
#[inline]
fn groups<'r>(&'r mut self, i: uint) -> &'r mut [Option<uint>] {
self.queue.get_mut(i).groups.as_mut_slice()
self.queue[i].groups.as_mut_slice()
}
}

View File

@ -179,7 +179,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
}
impl<'t> Nfa<'t> {
#[allow(unused_variable)]
#[allow(unused_variables)]
fn run(&mut self, start: uint, end: uint) -> Vec<Option<uint>> {
let mut matched = false;
let prefix_bytes: &[u8] = $prefix_bytes;
@ -226,7 +226,7 @@ fn exec<'t>(which: ::regex::native::MatchKind, input: &'t str,
}
// Sometimes `nlist` is never used (for empty regexes).
#[allow(unused_variable)]
#[allow(unused_variables)]
#[inline]
fn step(&self, groups: &mut Captures, nlist: &mut Threads,
caps: &mut Captures, pc: uint) -> StepState {

View File

@ -226,12 +226,10 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
}
};
unsafe {
sess.targ_cfg
.target_strs
.target_triple
.as_slice()
.with_c_str(|t| {
let triple = sess.targ_cfg.target_strs.target_triple.as_slice();
let tm = unsafe {
triple.with_c_str(|t| {
sess.opts.cg.target_cpu.as_slice().with_c_str(|cpu| {
target_feature(sess).with_c_str(|features| {
llvm::LLVMRustCreateTargetMachine(
@ -249,7 +247,15 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
})
})
})
}
};
if tm.is_null() {
llvm_err(sess.diagnostic().handler(),
format!("Could not create LLVM TargetMachine for triple: {}",
triple).to_string());
} else {
return tm;
};
}

View File

@ -498,7 +498,7 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
}
None
}
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static os_names : &'static [(&'static str, abi::Os)] = &[
("mingw32", abi::OsWindows),
("win32", abi::OsWindows),
@ -516,7 +516,7 @@ pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
}
None
}
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static architecture_abis : &'static [(&'static str, abi::Architecture)] = &[
("i386", abi::X86),
("i486", abi::X86),

View File

@ -255,7 +255,8 @@ Available lint options:
for (name, to) in lints.into_iter() {
let name = name.chars().map(|x| x.to_lowercase())
.collect::<String>().replace("_", "-");
let desc = to.into_iter().map(|x| x.as_str()).collect::<Vec<String>>().connect(", ");
let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))
.collect::<Vec<String>>().connect(", ");
println!(" {} {}",
padded(name.as_slice()), desc);
}

View File

@ -1021,7 +1021,7 @@ declare_lint!(UNUSED_PARENS, Warn,
pub struct UnusedParens;
impl UnusedParens {
fn check_unnecessary_parens_core(&self, cx: &Context, value: &ast::Expr, msg: &str,
fn check_unused_parens_core(&self, cx: &Context, value: &ast::Expr, msg: &str,
struct_lit_needs_parens: bool) {
match value.node {
ast::ExprParen(ref inner) => {
@ -1090,7 +1090,7 @@ impl LintPass for UnusedParens {
ast::ExprAssignOp(_, _, ref value) => (value, "assigned value", false),
_ => return
};
self.check_unnecessary_parens_core(cx, &**value, msg, struct_lit_needs_parens);
self.check_unused_parens_core(cx, &**value, msg, struct_lit_needs_parens);
}
fn check_stmt(&mut self, cx: &Context, s: &ast::Stmt) {
@ -1104,7 +1104,7 @@ impl LintPass for UnusedParens {
},
_ => return
};
self.check_unnecessary_parens_core(cx, &**value, msg, false);
self.check_unused_parens_core(cx, &**value, msg, false);
}
}
@ -1364,7 +1364,7 @@ impl MissingDoc {
*self.doc_hidden_stack.last().expect("empty doc_hidden_stack")
}
fn check_missing_doc_attrs(&self,
fn check_missing_docs_attrs(&self,
cx: &Context,
id: Option<ast::NodeId>,
attrs: &[ast::Attribute],
@ -1374,7 +1374,7 @@ impl MissingDoc {
// documentation is probably not really relevant right now.
if cx.sess().opts.test { return }
// `#[doc(hidden)]` disables missing_doc check.
// `#[doc(hidden)]` disables missing_docs check.
if self.doc_hidden() { return }
// Only check publicly-visible items, using the result from the privacy pass.
@ -1429,7 +1429,7 @@ impl LintPass for MissingDoc {
}
fn check_crate(&mut self, cx: &Context, krate: &ast::Crate) {
self.check_missing_doc_attrs(cx, None, krate.attrs.as_slice(),
self.check_missing_docs_attrs(cx, None, krate.attrs.as_slice(),
krate.span, "crate");
}
@ -1442,7 +1442,7 @@ impl LintPass for MissingDoc {
ast::ItemTrait(..) => "a trait",
_ => return
};
self.check_missing_doc_attrs(cx, Some(it.id), it.attrs.as_slice(),
self.check_missing_docs_attrs(cx, Some(it.id), it.attrs.as_slice(),
it.span, desc);
}
@ -1456,7 +1456,7 @@ impl LintPass for MissingDoc {
// Otherwise, doc according to privacy. This will also check
// doc for default methods defined on traits.
self.check_missing_doc_attrs(cx, Some(m.id), m.attrs.as_slice(),
self.check_missing_docs_attrs(cx, Some(m.id), m.attrs.as_slice(),
m.span, "a method");
}
_ => {}
@ -1464,7 +1464,7 @@ impl LintPass for MissingDoc {
}
fn check_ty_method(&mut self, cx: &Context, tm: &ast::TypeMethod) {
self.check_missing_doc_attrs(cx, Some(tm.id), tm.attrs.as_slice(),
self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs.as_slice(),
tm.span, "a type method");
}
@ -1473,7 +1473,7 @@ impl LintPass for MissingDoc {
ast::NamedField(_, vis) if vis == ast::Public => {
let cur_struct_def = *self.struct_def_stack.last()
.expect("empty struct_def_stack");
self.check_missing_doc_attrs(cx, Some(cur_struct_def),
self.check_missing_docs_attrs(cx, Some(cur_struct_def),
sf.node.attrs.as_slice(), sf.span,
"a struct field")
}
@ -1482,7 +1482,7 @@ impl LintPass for MissingDoc {
}
fn check_variant(&mut self, cx: &Context, v: &ast::Variant, _: &ast::Generics) {
self.check_missing_doc_attrs(cx, Some(v.node.id), v.node.attrs.as_slice(),
self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs.as_slice(),
v.span, "a variant");
}
}

View File

@ -221,8 +221,8 @@ impl LintStore {
add_lint_group!(sess, "unused",
UNUSED_IMPORTS, UNUSED_VARIABLES, UNUSED_ASSIGNMENTS, DEAD_CODE,
UNUSED_MUT, UNREACHABLE_CODE, UNUSED_EXTERN_CRATES, UNUSED_MUST_USE,
UNUSED_UNSAFE, UNUSED_RESULTS, PATH_STATEMENTS)
UNUSED_MUT, UNREACHABLE_CODE, UNUSED_MUST_USE,
UNUSED_UNSAFE, PATH_STATEMENTS)
// We have one lint pass defined in this module.
self.register_pass(sess, false, box GatherNodeLevels as LintPassObject);
@ -254,21 +254,19 @@ impl LintStore {
}
#[allow(unused_variable)]
#[allow(unused_variables)]
fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
-> Option<LintId>
{
match self.by_name.find_equiv(&lint_name) {
Some(&Id(lint_id)) => Some(lint_id),
Some(&Renamed(ref new_name, lint_id)) => {
// NOTE(stage0): add the following code after the next snapshot
// let warning = format!("lint {} has been renamed to {}",
// lint_name, new_name);
// match span {
// Some(span) => sess.span_warn(span, warning.as_slice()),
// None => sess.warn(warning.as_slice()),
// };
let warning = format!("lint {} has been renamed to {}",
lint_name, new_name);
match span {
Some(span) => sess.span_warn(span, warning.as_slice()),
None => sess.warn(warning.as_slice()),
};
Some(lint_id)
}
None => None

View File

@ -98,7 +98,7 @@ macro_rules! declare_lint (
#[macro_export]
macro_rules! lint_array ( ($( $lint:expr ),*) => (
{
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static array: LintArray = &[ $( &$lint ),* ];
array
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_camel_case_types, non_uppercase_statics)]
#![allow(non_camel_case_types, non_upper_case_globals)]
use std::mem;
use back::svh::Svh;

View File

@ -1330,9 +1330,9 @@ pub fn get_missing_lang_items(cdata: Cmd)
{
let items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_lang_items);
let mut result = Vec::new();
reader::tagged_docs(items, tag_lang_items_missing, |missing_doc| {
reader::tagged_docs(items, tag_lang_items_missing, |missing_docs| {
let item: lang_items::LangItem =
FromPrimitive::from_u32(reader::doc_as_u32(missing_doc)).unwrap();
FromPrimitive::from_u32(reader::doc_as_u32(missing_docs)).unwrap();
result.push(item);
true
});

View File

@ -1619,7 +1619,7 @@ fn encode_index<T: Hash>(rbml_w: &mut Encoder, index: Vec<entry<T>>,
let mut buckets: Vec<Vec<entry<T>>> = Vec::from_fn(256, |_| Vec::new());
for elt in index.into_iter() {
let h = hash::hash(&elt.val) as uint;
buckets.get_mut(h % 256).push(elt);
buckets[h % 256].push(elt);
}
rbml_w.start_tag(tag_index);
@ -2028,7 +2028,7 @@ fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) {
}
// NB: Increment this as you change the metadata encoding version.
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const metadata_encoding_version : &'static [u8] = &[b'r', b'u', b's', b't', 0, 0, 0, 1 ];
pub fn encode_metadata(parms: EncodeParams, krate: &Crate) -> Vec<u8> {

View File

@ -83,7 +83,7 @@ impl Clone for MovePathIndex {
}
}
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static InvalidMovePathIndex: MovePathIndex =
MovePathIndex(uint::MAX);
@ -97,7 +97,7 @@ impl MoveIndex {
}
}
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static InvalidMoveIndex: MoveIndex =
MoveIndex(uint::MAX);
@ -214,13 +214,13 @@ impl MoveData {
fn set_path_first_move(&self,
index: MovePathIndex,
first_move: MoveIndex) {
self.paths.borrow_mut().get_mut(index.get()).first_move = first_move
(*self.paths.borrow_mut())[index.get()].first_move = first_move
}
fn set_path_first_child(&self,
index: MovePathIndex,
first_child: MovePathIndex) {
self.paths.borrow_mut().get_mut(index.get()).first_child = first_child
(*self.paths.borrow_mut())[index.get()].first_child = first_child
}
fn move_next_move(&self, index: MoveIndex) -> MoveIndex {

View File

@ -9,7 +9,7 @@
// except according to those terms.
#![allow(non_camel_case_types)]
#![allow(unsigned_negate)]
#![allow(unsigned_negation)]
use metadata::csearch;
use middle::astencode;

View File

@ -161,7 +161,7 @@ fn calculate_type(sess: &session::Session,
if src.dylib.is_none() && !formats.contains_key(&cnum) {
assert!(src.rlib.is_some());
add_library(sess, cnum, cstore::RequireStatic, &mut formats);
*ret.get_mut(cnum as uint - 1) = Some(cstore::RequireStatic);
ret[cnum as uint - 1] = Some(cstore::RequireStatic);
debug!("adding staticlib: {}", data.name);
}
});

View File

@ -66,20 +66,20 @@ impl<E: Show> Show for Edge<E> {
#[deriving(Clone, PartialEq, Show)]
pub struct NodeIndex(pub uint);
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX);
#[deriving(PartialEq, Show)]
pub struct EdgeIndex(pub uint);
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX);
// Use a private field here to guarantee no more instances are created:
#[deriving(Show)]
pub struct Direction { repr: uint }
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const Outgoing: Direction = Direction { repr: 0 };
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const Incoming: Direction = Direction { repr: 1 };
impl NodeIndex {
@ -142,7 +142,7 @@ impl<N,E> Graph<N,E> {
}
pub fn mut_node_data<'a>(&'a mut self, idx: NodeIndex) -> &'a mut N {
&mut self.nodes.get_mut(idx.get()).data
&mut self.nodes[idx.get()].data
}
pub fn node_data<'a>(&'a self, idx: NodeIndex) -> &'a N {
@ -182,14 +182,14 @@ impl<N,E> Graph<N,E> {
});
// adjust the firsts for each node target be the next object.
self.nodes.get_mut(source.get()).first_edge[Outgoing.repr] = idx;
self.nodes.get_mut(target.get()).first_edge[Incoming.repr] = idx;
self.nodes[source.get()].first_edge[Outgoing.repr] = idx;
self.nodes[target.get()].first_edge[Incoming.repr] = idx;
return idx;
}
pub fn mut_edge_data<'a>(&'a mut self, idx: EdgeIndex) -> &'a mut E {
&mut self.edges.get_mut(idx.get()).data
&mut self.edges[idx.get()].data
}
pub fn edge_data<'a>(&'a self, idx: EdgeIndex) -> &'a E {

View File

@ -756,7 +756,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
fn init_empty(&mut self, ln: LiveNode, succ_ln: LiveNode) {
*self.successors.get_mut(ln.get()) = succ_ln;
self.successors[ln.get()] = succ_ln;
// It is not necessary to initialize the
// values to empty because this is the value
@ -770,10 +770,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn init_from_succ(&mut self, ln: LiveNode, succ_ln: LiveNode) {
// more efficient version of init_empty() / merge_from_succ()
*self.successors.get_mut(ln.get()) = succ_ln;
self.successors[ln.get()] = succ_ln;
self.indices2(ln, succ_ln, |this, idx, succ_idx| {
*this.users.get_mut(idx) = this.users[succ_idx]
this.users[idx] = this.users[succ_idx]
});
debug!("init_from_succ(ln={}, succ={})",
self.ln_str(ln), self.ln_str(succ_ln));
@ -789,11 +789,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let mut changed = false;
self.indices2(ln, succ_ln, |this, idx, succ_idx| {
changed |= copy_if_invalid(this.users[succ_idx].reader,
&mut this.users.get_mut(idx).reader);
&mut this.users[idx].reader);
changed |= copy_if_invalid(this.users[succ_idx].writer,
&mut this.users.get_mut(idx).writer);
&mut this.users[idx].writer);
if this.users[succ_idx].used && !this.users[idx].used {
this.users.get_mut(idx).used = true;
this.users[idx].used = true;
changed = true;
}
});
@ -817,8 +817,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// this) so we just clear out all the data.
fn define(&mut self, writer: LiveNode, var: Variable) {
let idx = self.idx(writer, var);
self.users.get_mut(idx).reader = invalid_node();
self.users.get_mut(idx).writer = invalid_node();
self.users[idx].reader = invalid_node();
self.users[idx].writer = invalid_node();
debug!("{} defines {} (idx={}): {}", writer.to_string(), var.to_string(),
idx, self.ln_str(writer));
@ -830,7 +830,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
ln.to_string(), acc, var.to_string(), self.ln_str(ln));
let idx = self.idx(ln, var);
let user = self.users.get_mut(idx);
let user = &mut self.users[idx];
if (acc & ACC_WRITE) != 0 {
user.reader = invalid_node();

View File

@ -2596,7 +2596,7 @@ impl<'a> Resolver<'a> {
// We've successfully resolved the import. Write the results in.
let mut import_resolutions = module_.import_resolutions.borrow_mut();
let import_resolution = import_resolutions.get_mut(&target);
let import_resolution = &mut (*import_resolutions)[target];
match value_result {
BoundResult(ref target_module, ref name_bindings) => {
@ -3158,7 +3158,7 @@ impl<'a> Resolver<'a> {
(_, _) => {
search_module = module_def.clone();
// track extern crates for unused_extern_crate lint
// track extern crates for unused_extern_crates lint
match module_def.def_id.get() {
Some(did) => {
self.used_crates.insert(did.krate);
@ -5697,7 +5697,7 @@ impl<'a> Resolver<'a> {
let mut smallest = 0;
for (i, other) in maybes.iter().enumerate() {
*values.get_mut(i) = name.lev_distance(other.get());
values[i] = name.lev_distance(other.get());
if values[i] <= values[smallest] {
smallest = i;

View File

@ -145,7 +145,7 @@ impl<'a> SpanUtils<'a> {
last_span = None;
let mut next = toks.next_token();
if (next.tok == token::LParen ||
if (next.tok == token::OpenDelim(token::Paren) ||
next.tok == token::Lt) &&
bracket_count == 0 &&
prev.tok.is_ident() {
@ -164,8 +164,8 @@ impl<'a> SpanUtils<'a> {
}
bracket_count += match prev.tok {
token::LParen | token::Lt => 1,
token::RParen | token::Gt => -1,
token::OpenDelim(token::Paren) | token::Lt => 1,
token::CloseDelim(token::Paren) | token::Gt => -1,
token::BinOp(token::Shr) => -2,
_ => 0
};

View File

@ -403,7 +403,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
let mut pats = br.pats.clone();
*pats.get_mut(col) = pat;
pats[col] = pat;
Match {
pats: pats,
data: &*br.data,

View File

@ -43,7 +43,7 @@
* taken to it, implementing them for Rust seems difficult.
*/
#![allow(unsigned_negate)]
#![allow(unsigned_negation)]
use std::collections::Map;
use std::num::Int;
@ -393,12 +393,12 @@ fn mk_cenum(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> Repr {
fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntType {
debug!("range_to_inttype: {} {}", hint, bounds);
// Lists of sizes to try. u64 is always allowed as a fallback.
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static choose_shortest: &'static[IntType] = &[
attr::UnsignedInt(ast::TyU8), attr::SignedInt(ast::TyI8),
attr::UnsignedInt(ast::TyU16), attr::SignedInt(ast::TyI16),
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static at_least_32: &'static[IntType] = &[
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
use llvm;
use llvm::{Integer, Pointer, Float, Double, Struct, Array};

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
use libc::c_uint;
use std::cmp;

View File

@ -11,7 +11,7 @@
// The classification code for the x86_64 ABI is taken from the clay language
// https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
use llvm;
use llvm::{Integer, Pointer, Float, Double};

View File

@ -469,7 +469,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
assert!(self.is_valid_custom_scope(custom_scope));
let mut scopes = self.scopes.borrow_mut();
let scope = scopes.get_mut(custom_scope.index);
let scope = &mut (*scopes)[custom_scope.index];
scope.cleanups.push(cleanup);
scope.clear_cached_exits();
}

View File

@ -218,20 +218,20 @@ use syntax::parse::token::special_idents;
static DW_LANG_RUST: c_uint = 0x9000;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_TAG_auto_variable: c_uint = 0x100;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_TAG_arg_variable: c_uint = 0x101;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_ATE_boolean: c_uint = 0x02;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_ATE_float: c_uint = 0x04;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_ATE_signed: c_uint = 0x05;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_ATE_unsigned: c_uint = 0x07;
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
static DW_ATE_unsigned_char: c_uint = 0x08;
static UNKNOWN_LINE_NUMBER: c_uint = 0;

View File

@ -833,7 +833,7 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let _icx = push_ctxt("trans_def_lvalue");
match def {
def::DefFn(..) | def::DefStaticMethod(..) |
def::DefFn(..) | def::DefStaticMethod(..) | def::DefMethod(..) |
def::DefStruct(_) | def::DefVariant(..) => {
trans_def_fn_unadjusted(bcx, ref_expr, def)
}
@ -1191,10 +1191,12 @@ fn trans_def_fn_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let llfn = match def {
def::DefFn(did, _, _) |
def::DefStruct(did) | def::DefVariant(_, did, _) |
def::DefStaticMethod(did, def::FromImpl(_), _) => {
def::DefStaticMethod(did, def::FromImpl(_), _) |
def::DefMethod(did, _, def::FromImpl(_)) => {
callee::trans_fn_ref(bcx, did, ExprId(ref_expr.id))
}
def::DefStaticMethod(impl_did, def::FromTrait(trait_did), _) => {
def::DefStaticMethod(impl_did, def::FromTrait(trait_did), _) |
def::DefMethod(impl_did, _, def::FromTrait(trait_did)) => {
meth::trans_static_method_callee(bcx, impl_did,
trait_did, ref_expr.id)
}
@ -1331,7 +1333,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
field_ty.name == field.ident.node.name);
match opt_pos {
Some(i) => {
*need_base.get_mut(i) = false;
need_base[i] = false;
(i, &*field.expr)
}
None => {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
use llvm;
use llvm::{SequentiallyConsistent, Acquire, Release, AtomicXchg, ValueRef};

View File

@ -310,26 +310,23 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
return expr::trans_into(bcx, &**element, Ignore);
}
SaveIn(lldest) => {
let count = ty::eval_repeat_count(bcx.tcx(), &**count_expr);
if count == 0 {
return bcx;
match ty::eval_repeat_count(bcx.tcx(), &**count_expr) {
0 => bcx,
1 => expr::trans_into(bcx, &**element, SaveIn(lldest)),
count => {
let elem = unpack_datum!(bcx, expr::trans(bcx, &**element));
assert!(!ty::type_moves_by_default(bcx.tcx(), elem.ty));
let bcx = iter_vec_loop(bcx, lldest, vt,
C_uint(bcx.ccx(), count),
|set_bcx, lleltptr, _| {
elem.shallow_copy(set_bcx, lleltptr)
});
elem.add_clean_if_rvalue(bcx, element.id);
bcx
}
}
// Some cleanup would be required in the case in which panic happens
// during a copy. But given that copy constructors are not overridable,
// this can only happen as a result of OOM. So we just skip out on the
// cleanup since things would *probably* be broken at that point anyways.
let elem = unpack_datum!(bcx, expr::trans(bcx, &**element));
assert!(!ty::type_moves_by_default(bcx.tcx(), elem.ty));
let bcx = iter_vec_loop(bcx, lldest, vt,
C_uint(bcx.ccx(), count), |set_bcx, lleltptr, _| {
elem.shallow_copy(set_bcx, lleltptr)
});
elem.add_clean_if_rvalue(bcx, element.id);
bcx
}
}
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
use llvm;
use llvm::{TypeRef, Bool, False, True, TypeKind, ValueRef};
@ -284,7 +284,7 @@ impl Type {
return Vec::new();
}
let mut elts = Vec::from_elem(n_elts, 0 as TypeRef);
llvm::LLVMGetStructElementTypes(self.to_ref(), elts.get_mut(0));
llvm::LLVMGetStructElementTypes(self.to_ref(), &mut elts[0]);
mem::transmute(elts)
}
}

View File

@ -2215,7 +2215,7 @@ macro_rules! def_type_content_sets(
mod $mname {
use middle::ty::TypeContents;
$(
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const $name: TypeContents = TypeContents { bits: $bits };
)+
}
@ -3631,7 +3631,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
def::DefFn(_, _, true) => RvalueDpsExpr,
// Fn pointers are just scalar values.
def::DefFn(..) | def::DefStaticMethod(..) => RvalueDatumExpr,
def::DefFn(..) | def::DefStaticMethod(..) | def::DefMethod(..) => RvalueDatumExpr,
// Note: there is actually a good case to be made that
// DefArg's, particularly those of immediate type, ought to
@ -4670,7 +4670,7 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
}
pub fn is_binopable(cx: &ctxt, ty: t, op: ast::BinOp) -> bool {
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
static tycat_other: int = 0;
static tycat_bool: int = 1;
static tycat_char: int = 2;

View File

@ -674,7 +674,7 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
return constr(ty::mk_str(tcx));
}
RPtr(r) => {
return ty::mk_str_slice(tcx, r, ast::MutImmutable);
return ty::mk_str_slice(tcx, r, a_seq_mutbl);
}
}
}

View File

@ -648,7 +648,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
ByValueExplicitSelfCategory => {
let mut n = (*m).clone();
let self_ty = n.fty.sig.inputs[0];
*n.fty.sig.inputs.get_mut(0) = ty::mk_uniq(tcx, self_ty);
n.fty.sig.inputs[0] = ty::mk_uniq(tcx, self_ty);
m = Rc::new(n);
}
_ => { }

View File

@ -5456,7 +5456,7 @@ pub fn check_bounds_are_used(ccx: &CrateCtxt,
match ty::get(t).sty {
ty::ty_param(ParamTy {idx, ..}) => {
debug!("Found use of ty param num {}", idx);
*tps_used.get_mut(idx) = true;
tps_used[idx] = true;
}
_ => ()
}

View File

@ -1757,7 +1757,7 @@ fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx,
// is inferred to mutable if necessary
let mut upvar_borrow_map =
rcx.fcx.inh.upvar_borrow_map.borrow_mut();
let ub = upvar_borrow_map.get_mut(upvar_id);
let ub = &mut (*upvar_borrow_map)[*upvar_id];
return adjust_upvar_borrow_kind(rcx, *upvar_id, ub, ty::MutBorrow);
}
@ -1807,7 +1807,7 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &Rcx, cmt: mc::cmt) {
// borrow_kind of the upvar to make sure it
// is inferred to unique if necessary
let mut ub = rcx.fcx.inh.upvar_borrow_map.borrow_mut();
let ub = ub.get_mut(upvar_id);
let ub = &mut (*ub)[*upvar_id];
return adjust_upvar_borrow_kind(rcx, *upvar_id, ub, ty::UniqueImmBorrow);
}

View File

@ -402,15 +402,25 @@ pub fn maybe_report_ambiguity(fcx: &FnCtxt, obligation: &Obligation) {
// has_errors() to be sure that compilation isn't happening
// anyway. In that case, why inundate the user.
if !fcx.tcx().sess.has_errors() {
fcx.tcx().sess.span_err(
obligation.cause.span,
format!(
"unable to infer enough type information to \
locate the impl of the trait `{}` for \
the type `{}`; type annotations required",
trait_ref.user_string(fcx.tcx()),
self_ty.user_string(fcx.tcx())).as_slice());
note_obligation_cause(fcx, obligation);
if fcx.ccx.tcx.lang_items.sized_trait()
.map_or(false, |sized_id| sized_id == trait_ref.def_id) {
fcx.tcx().sess.span_err(
obligation.cause.span,
format!(
"unable to infer enough type information about `{}`; type annotations \
required",
self_ty.user_string(fcx.tcx())).as_slice());
} else {
fcx.tcx().sess.span_err(
obligation.cause.span,
format!(
"unable to infer enough type information to \
locate the impl of the trait `{}` for \
the type `{}`; type annotations required",
trait_ref.user_string(fcx.tcx()),
self_ty.user_string(fcx.tcx())).as_slice());
note_obligation_cause(fcx, obligation);
}
}
} else if !fcx.tcx().sess.has_errors() {
// Ambiguity. Coherence should have reported an error.

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -282,7 +282,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
}
_ => {
span_err!(self.tcx().sess, reason.span(self.tcx()), E0100,
"cannot coerce non-statically resolved bare fn");
"cannot coerce non-statically resolved bare fn to closure");
span_help!(self.tcx().sess, reason.span(self.tcx()),
"consider embedding the function in a closure");
}
}

View File

@ -261,7 +261,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
if snapshot.length == 0 {
undo_log.truncate(0);
} else {
*undo_log.get_mut(snapshot.length) = CommitedSnapshot;
(*undo_log)[snapshot.length] = CommitedSnapshot;
}
}

View File

@ -46,7 +46,7 @@
// future). If you want to resolve everything but one type, you are
// probably better off writing `resolve_all - resolve_ivar`.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
use middle::ty::{FloatVar, FloatVid, IntVar, IntVid, RegionVid, TyVar, TyVid};
use middle::ty::{IntType, UintType};

View File

@ -159,12 +159,12 @@ impl sv::SnapshotVecDelegate<TypeVariableData,UndoEntry> for Delegate {
action: UndoEntry) {
match action {
SpecifyVar(vid, relations) => {
values.get_mut(vid.index).value = Bounded(relations);
values[vid.index].value = Bounded(relations);
}
Relate(a, b) => {
relations(values.get_mut(a.index)).pop();
relations(values.get_mut(b.index)).pop();
relations(&mut (*values)[a.index]).pop();
relations(&mut (*values)[b.index]).pop();
}
}
}

View File

@ -715,7 +715,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
}
_ => {
self.terms_cx.arena.alloc(|| TransformTerm(v1, v2))
&*self.terms_cx.arena.alloc(|| TransformTerm(v1, v2))
}
}
}
@ -994,7 +994,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> {
new_value,
term.to_string());
*self.solutions.get_mut(inferred) = new_value;
self.solutions[inferred] = new_value;
changed = true;
}
}

View File

@ -105,7 +105,7 @@ impl<T,U,D:SnapshotVecDelegate<T,U>> SnapshotVec<T,U,D> {
* action.
*/
self.values.get_mut(index)
&mut self.values[index]
}
pub fn set(&mut self, index: uint, new_elem: T) {
@ -114,7 +114,7 @@ impl<T,U,D:SnapshotVecDelegate<T,U>> SnapshotVec<T,U,D> {
* saved (and perhaps restored) if a snapshot is active.
*/
let old_elem = mem::replace(self.values.get_mut(index), new_elem);
let old_elem = mem::replace(&mut self.values[index], new_elem);
if self.in_snapshot() {
self.undo_log.push(SetElem(index, old_elem));
}
@ -162,7 +162,7 @@ impl<T,U,D:SnapshotVecDelegate<T,U>> SnapshotVec<T,U,D> {
}
SetElem(i, v) => {
*self.values.get_mut(i) = v;
self.values[i] = v;
}
Other(u) => {
@ -189,7 +189,7 @@ impl<T,U,D:SnapshotVecDelegate<T,U>> SnapshotVec<T,U,D> {
// The root snapshot.
self.undo_log.truncate(0);
} else {
*self.undo_log.get_mut(snapshot.length) = CommittedSnapshot;
self.undo_log[snapshot.length] = CommittedSnapshot;
}
}
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
pub const box_field_refcnt: uint = 0u;
pub const box_field_drop_glue: uint = 1u;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]

View File

@ -97,8 +97,8 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
// miscellaneous, no highlighting
token::Dot | token::DotDot | token::DotDotDot | token::Comma | token::Semi |
token::Colon | token::ModSep | token::LArrow | token::LParen |
token::RParen | token::LBracket | token::LBrace | token::RBrace |
token::Colon | token::ModSep | token::LArrow | token::OpenDelim(_) |
token::CloseDelim(token::Brace) | token::CloseDelim(token::Paren) |
token::Question => "",
token::Dollar => {
if lexer.peek().tok.is_ident() {
@ -118,7 +118,7 @@ fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader,
try!(write!(out, r"<span class='attribute'>#"));
continue
}
token::RBracket => {
token::CloseDelim(token::Bracket) => {
if is_attribute {
is_attribute = false;
try!(write!(out, "]</span>"));

View File

@ -212,7 +212,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
if lints {
prog.push_str(r"
#![deny(warnings)]
#![allow(unused_variable, dead_assignment, unused_mut, unused_attribute, dead_code)]
#![allow(unused_variables, unused_assignments, unused_mut, unused_attributes, dead_code)]
");
}

View File

@ -10,7 +10,7 @@
//! Unwind library interface
#![allow(non_uppercase_statics)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)] // these are just bindings

View File

@ -66,7 +66,7 @@ use task::{Task, LocalStorage};
*/
pub type Key<T> = &'static KeyValue<T>;
#[allow(missing_doc)]
#[allow(missing_docs)]
pub enum KeyValue<T> { KeyValueKey }
// The task-local-map stores all TLD information for the currently running

View File

@ -177,7 +177,7 @@ pub unsafe fn try(f: ||) -> ::core::result::Result<(), Box<Any + Send>> {
// An uninlined, unmangled function upon which to slap yer breakpoints
#[inline(never)]
#[no_mangle]
fn rust_fail(cause: Box<Any + Send>) -> ! {
fn rust_panic(cause: Box<Any + Send>) -> ! {
rtdebug!("begin_unwind()");
unsafe {
@ -588,7 +588,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
// (hopefully someone printed something about this).
let mut task: Box<Task> = match Local::try_take() {
Some(task) => task,
None => rust_fail(msg),
None => rust_panic(msg),
};
if task.unwinder.unwinding {
@ -605,7 +605,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
// requires the task. We need a handle to its unwinder, however, so after
// this we unsafely extract it and continue along.
Local::put(task);
rust_fail(msg);
rust_panic(msg);
}
/// Register a callback to be invoked when a task unwinds.

View File

@ -28,9 +28,9 @@ pub const ENFORCE_SANITY: bool = true || !cfg!(rtopt) || cfg!(rtdebug) ||
pub struct Stdio(libc::c_int);
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
pub const Stderr: Stdio = Stdio(libc::STDERR_FILENO);
impl fmt::FormatWriter for Stdio {

View File

@ -12,7 +12,7 @@
// Copyright (c) 2011 Google Inc.
#![forbid(non_camel_case_types)]
#![allow(missing_doc)]
#![allow(missing_docs)]
/*!
JSON parsing and serialization
@ -1231,7 +1231,7 @@ impl Stack {
InternalIndex(i) => { i + 1 }
_ => { panic!(); }
};
*self.stack.get_mut(len - 1) = InternalIndex(idx);
self.stack[len - 1] = InternalIndex(idx);
}
}

View File

@ -331,8 +331,7 @@ impl IntoStr for Vec<Ascii> {
#[inline]
fn into_string(self) -> String {
unsafe {
let s: &str = mem::transmute(self.as_slice());
String::from_str(s)
string::raw::from_utf8(self.into_bytes())
}
}
}

View File

@ -258,7 +258,7 @@ macro_rules! bitflags {
}
#[cfg(test)]
#[allow(non_uppercase_statics)]
#[allow(non_upper_case_globals)]
mod tests {
use hash;
use option::{Some, None};

View File

@ -14,19 +14,14 @@ use clone::Clone;
use cmp::{max, Eq, Equiv, PartialEq};
use collections::{Collection, Mutable, MutableSet, Map, MutableMap};
use default::Default;
use fmt::Show;
use fmt;
use fmt::{mod, Show};
use hash::{Hash, Hasher, RandomSipHasher};
use iter::{Iterator, FromIterator, Extendable};
use iter;
use mem::replace;
use mem;
use iter::{mod, Iterator, FromIterator, Extendable};
use mem::{mod, replace};
use num;
use ops::Deref;
use ops::{Deref, Index, IndexMut};
use option::{Some, None, Option};
use result::{Ok, Err};
use ops::Index;
use core::result::Result;
use result::{Result, Ok, Err};
use super::table;
use super::table::{
@ -837,6 +832,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
/// # Example
///
/// ```
/// # #![allow(deprecated)]
/// use std::collections::HashMap;
///
/// let mut map = HashMap::new();
@ -852,11 +848,9 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
/// *map.get_mut(&"a") = -2;
/// assert_eq!(map["a"], -2);
/// ```
#[deprecated = "use indexing instead: `&mut map[key]`"]
pub fn get_mut<'a>(&'a mut self, k: &K) -> &'a mut V {
match self.find_mut(k) {
Some(v) => v,
None => panic!("no entry found for key")
}
&mut self[*k]
}
/// Return true if the map contains a value for the specified key,
@ -1194,13 +1188,15 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Index<K, V> for HashMap<K, V, H> {
}
}
// FIXME(#12825) Indexing will always try IndexMut first and that causes issues.
/*impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> ops::IndexMut<K, V> for HashMap<K, V, H> {
impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> IndexMut<K, V> for HashMap<K, V, H> {
#[inline]
fn index_mut<'a>(&'a mut self, index: &K) -> &'a mut V {
self.get_mut(index)
match self.find_mut(index) {
Some(v) => v,
None => panic!("no entry found for key")
}
}
}*/
}
/// HashMap iterator
pub struct Entries<'a, K: 'a, V: 'a> {

View File

@ -17,7 +17,7 @@ A simple wrapper over the platform's dynamic library facilities
*/
#![experimental]
#![allow(missing_doc)]
#![allow(missing_docs)]
use clone::Clone;
use collections::MutableSeq;
@ -286,6 +286,7 @@ pub mod dl {
use os;
use ptr;
use result::{Ok, Err, Result};
use slice::ImmutableSlice;
use str::StrSlice;
use str;
use string::String;

View File

@ -15,7 +15,7 @@ use comm::{Sender, Receiver};
use io;
use option::{None, Some};
use result::{Ok, Err};
use slice::{bytes, CloneableVector};
use slice::{bytes, CloneableVector, ImmutableSlice};
use super::{Buffer, Reader, Writer, IoResult};
use vec::Vec;

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