Skip to content

Rolling up PRs in the queue #18459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Oct 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7e2e4ce
return &mut T from the arenas, not &T
thestinger Oct 27, 2014
7163d65
Small grammar fix in rustdoc.md
pelmers Oct 28, 2014
c6ab5b0
Respect mut in &mut str in astconv
bkoropoff Oct 28, 2014
374da5b
Add regression test for issue #17361
bkoropoff Oct 28, 2014
348a46f
Remove double negation from sqrt's doc comment
cakebaker Oct 28, 2014
a33b744
Add ptr::RawMutPtr to prelude
aochagavia Oct 28, 2014
54babf8
Guide: Fix use of sqrt() in example
cakebaker Oct 28, 2014
012cc6d
Remove unnecessary clone in ascii.rs
aochagavia Oct 28, 2014
e0ad0fc
Update code with new lint names
aturon Oct 27, 2014
1ad1e2e
Turn on warning for use of deprecated lint names
aturon Oct 27, 2014
d9eb13b
Add regression test for lint deprecation
aturon Oct 28, 2014
321de97
reference: note the existence of UnsafeCell
thestinger Oct 28, 2014
768a7e1
reference: slices are now regular types
thestinger Oct 28, 2014
8a71925
reference: document unwinding unsafety issues
thestinger Oct 28, 2014
cb5f979
Diagnostic: resolve bare fn in expected closure
gamazeps Oct 28, 2014
c8b142a
Fix ICE assigning methods to local variables
bkoropoff Oct 29, 2014
12619be
Add regression test for issue #18412
bkoropoff Oct 29, 2014
793a733
Fix `core::num::CheckedDiv::checked_div` documentation
tbu- Oct 29, 2014
89e8caa
rustc: fail if LLVM is passed an invalid triple
richo Oct 29, 2014
710fd0c
Remove an empty file from librustc
Oct 29, 2014
936d999
Use common variants for open and close delimiters
brendanzab Oct 29, 2014
1ab50f3
Remove Token::get_close_delimiter
brendanzab Oct 29, 2014
98a4770
Formatting fixes
brendanzab Oct 29, 2014
13d19bb
Rename rust_fail to rust_panic
Manishearth Oct 29, 2014
8e9f8f9
collections: impl Deref for Vec/String
alexcrichton Oct 29, 2014
a0ee7c9
Remove `unused_extern_crate` and `unused_result` from the `unused` li…
ftxqxd Oct 11, 2014
2a7be1b
Fix a minor issue with how lint groups are printed by rustc
ftxqxd Oct 11, 2014
fb00015
Improve the error message for parenthesised box expressions
ftxqxd Oct 25, 2014
8384dd9
Fix ICE translating array repeat expr of non-Copy type
bkoropoff Oct 30, 2014
88c8a54
Add regression test for #18425
bkoropoff Oct 30, 2014
14398f2
Add a message for when a `.` follows a macro invocation
ftxqxd Oct 27, 2014
737e396
Special-case some error messages about `Sized`
ftxqxd Oct 28, 2014
1d35662
collections: Enable IndexMut for some collections
alexcrichton Oct 23, 2014
88946f7
rollup merge of #18381 : pelmers/patch-1
alexcrichton Oct 30, 2014
7577b6b
rollup merge of #18383 : bkoropoff/issue-17361
alexcrichton Oct 30, 2014
cda554a
rollup merge of #18392 : cakebaker/remove_double_negation
alexcrichton Oct 30, 2014
735ad68
rollup merge of #18393 : aochagavia/prelude
alexcrichton Oct 30, 2014
b85780e
rollup merge of #18395 : cakebaker/fix_use_of_sqrt
alexcrichton Oct 30, 2014
f2fe55b
rollup merge of #18397 : aochagavia/ascii
alexcrichton Oct 30, 2014
5ee8569
rollup merge of #18407 : thestinger/arena
alexcrichton Oct 30, 2014
1e919c9
rollup merge of #18408 : thestinger/unsafe
alexcrichton Oct 30, 2014
ce63fbc
rollup merge of #18409 : gamazeps/issue15273
alexcrichton Oct 30, 2014
f3ba518
rollup merge of #18411 : richo/tm-null-check
alexcrichton Oct 30, 2014
fc3ed0c
rollup merge of #18413 : bkoropoff/issue-18412
alexcrichton Oct 30, 2014
0966977
rollup merge of #18417 : P1start/lint-fixes
alexcrichton Oct 30, 2014
dfefe9a
rollup merge of #18421 : tbu-/pr_checkeddiv1
alexcrichton Oct 30, 2014
8c03068
rollup merge of #18438 : jakub-/empty-file
alexcrichton Oct 30, 2014
d7ee04c
rollup merge of #18442 : Manishearth/rust_panic
alexcrichton Oct 30, 2014
f3d72dc
rollup merge of #18443 : alexcrichton/deref-vec-and-string
alexcrichton Oct 30, 2014
f68dafa
rollup merge of #18452 : bkoropoff/issue-18425
alexcrichton Oct 30, 2014
00975e0
rollup merge of #18398 : aturon/lint-conventions-2
alexcrichton Oct 30, 2014
5d6241d
rollup merge of #18430 : bjz/token
alexcrichton Oct 30, 2014
c10c163
rollup merge of #18445 : alexcrichton/index-mut
alexcrichton Oct 30, 2014
6fcba88
Test fixes and rebase conflicts
alexcrichton Oct 30, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/complement-bugreport.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
2 changes: 1 addition & 1 deletion src/doc/guide-lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
~~~

Expand Down
7 changes: 5 additions & 2 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ testing this code, the `fib` function will be included (so it can compile).

Running tests often requires some special configuration to filter tests, find
libraries, or try running ignored examples. The testing framework that rustdoc
uses is build on crate `test`, which is also used when you compile crates with
uses is built on crate `test`, which is also used when you compile crates with
rustc's `--test` flag. Extra arguments can be passed to rustdoc's test harness
with the `--test-args` flag.

Expand Down
12 changes: 6 additions & 6 deletions src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ 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,
"MOD_SEP" => token::ModSep,
"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 }),
Expand All @@ -83,15 +83,15 @@ 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,
"EQEQ" => token::EqEq,
"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,
Expand Down
16 changes: 8 additions & 8 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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) =
Expand All @@ -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)
Expand Down Expand Up @@ -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));
Expand Down
21 changes: 11 additions & 10 deletions src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
28 changes: 14 additions & 14 deletions src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
//! }
//! }
//! }
Expand Down Expand Up @@ -151,7 +151,7 @@
//! }
//! ```

#![allow(missing_doc)]
#![allow(missing_docs)]

use core::prelude::*;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -462,40 +462,40 @@ 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 {
let right = child + 1;
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);
}
}
Expand Down
Loading