Skip to content

Rolling up PRs in the queue #12221

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

Closed
wants to merge 8 commits into from
2 changes: 1 addition & 1 deletion mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
PKG_EXE = $(PKG_DIR)-install.exe
endif

PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt

PKG_FILES := \
$(S)COPYRIGHT \
Expand Down
2 changes: 1 addition & 1 deletion src/doc/guide-ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<T: Send> Unique<T> {
pub fn new(value: T) -> Unique<T> {
unsafe {
let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
assert!(!ptr::is_null(ptr));
assert!(!ptr.is_null());
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
// move_val_init moves a value into this memory without
// attempting to drop the original value.
Expand Down
6 changes: 3 additions & 3 deletions src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ braced block gives the whole block the value of that last expression.

Put another way, the semicolon in Rust *ignores the value of an expression*.
Thus, if the branches of the `if` had looked like `{ 4; }`, the above example
would simply assign `()` (nil or void) to `price`. But without the semicolon, each
would simply assign `()` (unit or void) to `price`. But without the semicolon, each
branch has a different value, and `price` gets the value of the branch that
was taken.

Expand Down Expand Up @@ -352,7 +352,7 @@ before the opening and after the closing quote, and can contain any sequence of
characters except their closing delimiter. More on strings
[later](#vectors-and-strings).

The nil type, written `()`, has a single value, also written `()`.
The unit type, written `()`, has a single value, also written `()`.

## Operators

Expand Down Expand Up @@ -852,7 +852,7 @@ fn line(a: int, b: int, x: int) -> int {
It's better Rust style to write a return value this way instead of
writing an explicit `return`. The utility of `return` comes in when
returning early from a function. Functions that do not return a value
are said to return nil, `()`, and both the return type and the return
are said to return unit, `()`, and both the return type and the return
value may be omitted from the definition. The following two functions
are equivalent.

Expand Down
7 changes: 3 additions & 4 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use std::cast;
use std::cell::{Cell, RefCell};
use std::mem;
use std::num;
use std::ptr;
use std::kinds::marker;
use std::rc::Rc;
use std::rt::global_heap;
Expand Down Expand Up @@ -144,7 +143,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
let fill = chunk.fill.get();

while idx < fill {
let tydesc_data: *uint = transmute(ptr::offset(buf, idx as int));
let tydesc_data: *uint = transmute(buf.offset(idx as int));
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
let (size, align) = ((*tydesc).size, (*tydesc).align);

Expand All @@ -155,7 +154,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
//debug!("freeing object: idx = {}, size = {}, align = {}, done = {}",
// start, size, align, is_done);
if is_done {
((*tydesc).drop_glue)(ptr::offset(buf, start as int) as *i8);
((*tydesc).drop_glue)(buf.offset(start as int) as *i8);
}

// Find where the next tydesc lives
Expand Down Expand Up @@ -261,7 +260,7 @@ impl Arena {
// start, n_bytes, align, head.fill);

let buf = self.head.as_ptr();
return (ptr::offset(buf, tydesc_start as int), ptr::offset(buf, start as int));
return (buf.offset(tydesc_start as int), buf.offset(start as int));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libextra/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl <T> CVec<T> {
pub fn get<'a>(&'a self, ofs: uint) -> &'a T {
assert!(ofs < self.len);
unsafe {
&*ptr::mut_offset(self.base, ofs as int)
&*self.base.offset(ofs as int)
}
}

Expand All @@ -131,7 +131,7 @@ impl <T> CVec<T> {
pub fn get_mut<'a>(&'a mut self, ofs: uint) -> &'a mut T {
assert!(ofs < self.len);
unsafe {
&mut *ptr::mut_offset(self.base, ofs as int)
&mut *self.base.offset(ofs as int)
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/libextra/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ pub mod url;
pub mod json;
pub mod tempfile;
pub mod time;
pub mod base64;
pub mod workcache;
pub mod enum_set;
pub mod stats;
pub mod hex;

#[cfg(unicode)]
mod unicode;
Expand Down
16 changes: 14 additions & 2 deletions src/libnum/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,12 @@ impl BigUint {
if n_bits == 0 || self.data.is_empty() { return (*self).clone(); }

let mut borrow = 0;
let mut shifted = ~[];
let mut shifted_rev = vec::with_capacity(self.data.len());
for elem in self.data.rev_iter() {
shifted = ~[(*elem >> n_bits) | borrow] + shifted;
shifted_rev.push((*elem >> n_bits) | borrow);
borrow = *elem << (BigDigit::bits - n_bits);
}
let shifted = { shifted_rev.reverse(); shifted_rev };
return BigUint::new(shifted);
}

Expand Down Expand Up @@ -2637,4 +2638,15 @@ mod bench {
fib.to_str();
});
}

#[bench]
fn shr(bh: &mut BenchHarness) {
let n = { let one : BigUint = One::one(); one << 1000 };
bh.iter(|| {
let mut m = n.clone();
for _ in range(0, 10) {
m = m >> 1;
}
})
}
}
2 changes: 1 addition & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use std::run;
use std::str;
use std::io;
use std::io::fs;
use extra::hex::ToHex;
use serialize::hex::ToHex;
use extra::tempfile::TempDir;
use syntax::abi;
use syntax::ast;
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use std::io;
use std::num;
use std::option;
use std::os::consts::{macos, freebsd, linux, android, win32};
use std::ptr;
use std::str;
use std::vec;
use flate;
Expand Down Expand Up @@ -340,7 +339,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
});
if !version_ok { return None; }

let cvbuf1 = ptr::offset(cvbuf, vlen as int);
let cvbuf1 = cvbuf.offset(vlen as int);
debug!("inflating {} bytes of compressed metadata",
csz - vlen);
vec::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| {
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/trans/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use std::cast;
use std::hashmap::HashMap;
use std::libc::{c_uint, c_ulonglong, c_char};
use syntax::codemap::Span;
use std::ptr::is_not_null;

pub struct Builder<'a> {
llbuilder: BuilderRef,
Expand Down Expand Up @@ -492,7 +491,7 @@ impl<'a> Builder<'a> {
debug!("Store {} -> {}",
self.ccx.tn.val_to_str(val),
self.ccx.tn.val_to_str(ptr));
assert!(is_not_null(self.llbuilder));
assert!(self.llbuilder.is_not_null());
self.count_insn("store");
unsafe {
llvm::LLVMBuildStore(self.llbuilder, val, ptr);
Expand All @@ -503,7 +502,7 @@ impl<'a> Builder<'a> {
debug!("Store {} -> {}",
self.ccx.tn.val_to_str(val),
self.ccx.tn.val_to_str(ptr));
assert!(is_not_null(self.llbuilder));
assert!(self.llbuilder.is_not_null());
self.count_insn("store.volatile");
unsafe {
let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
if type_is_c_like_enum(fcx, expr.span, t_e) && t_1_is_trivial {
// casts from C-like enums are allowed
} else if t_1_is_char {
let te = fcx.infcx().resolve_type_vars_if_possible(te);
if ty::get(te).sty != ty::ty_uint(ast::TyU8) {
fcx.type_error_message(expr.span, |actual| {
format!("only `u8` can be cast as `char`, not `{}`", actual)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/util/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::iter::range_step;
use std::num::Zero;
use std::vec;
use std::vec::bytes::{MutableByteVector, copy_memory};
use extra::hex::ToHex;
use serialize::hex::ToHex;

/// Write a u32 into a vector, which must be 4 bytes long. The value is written in big-endian
/// format.
Expand Down Expand Up @@ -529,7 +529,7 @@ mod tests {
use std::vec;
use std::rand::isaac::IsaacRng;
use std::rand::Rng;
use extra::hex::FromHex;
use serialize::hex::FromHex;

// A normal addition - no overflow occurs
#[test]
Expand Down
19 changes: 15 additions & 4 deletions src/librustdoc/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ impl Clean<Item> for ast::Method {
_ => self.decl.inputs.slice_from(1)
};
let decl = FnDecl {
inputs: inputs.iter().map(|x| x.clean()).collect(),
inputs: Arguments {
values: inputs.iter().map(|x| x.clean()).collect(),
},
output: (self.decl.output.clean()),
cf: self.decl.cf.clean(),
attrs: ~[]
Expand Down Expand Up @@ -378,7 +380,9 @@ impl Clean<Item> for ast::TypeMethod {
_ => self.decl.inputs.slice_from(1)
};
let decl = FnDecl {
inputs: inputs.iter().map(|x| x.clean()).collect(),
inputs: Arguments {
values: inputs.iter().map(|x| x.clean()).collect(),
},
output: (self.decl.output.clean()),
cf: self.decl.cf.clean(),
attrs: ~[]
Expand Down Expand Up @@ -472,16 +476,23 @@ impl Clean<ClosureDecl> for ast::ClosureTy {

#[deriving(Clone, Encodable, Decodable)]
pub struct FnDecl {
inputs: ~[Argument],
inputs: Arguments,
output: Type,
cf: RetStyle,
attrs: ~[Attribute]
}

#[deriving(Clone, Encodable, Decodable)]
pub struct Arguments {
values: ~[Argument],
}

impl Clean<FnDecl> for ast::FnDecl {
fn clean(&self) -> FnDecl {
FnDecl {
inputs: self.inputs.iter().map(|x| x.clean()).collect(),
inputs: Arguments {
values: self.inputs.iter().map(|x| x.clean()).collect(),
},
output: (self.output.clean()),
cf: self.cf.clean(),
attrs: ~[]
Expand Down
29 changes: 14 additions & 15 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,19 @@ impl fmt::Show for clean::Type {
}
}

impl fmt::Show for clean::Arguments {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for (i, input) in self.values.iter().enumerate() {
if i > 0 { if_ok!(write!(f.buf, ", ")); }
if input.name.len() > 0 {
if_ok!(write!(f.buf, "{}: ", input.name));
}
if_ok!(write!(f.buf, "{}", input.type_));
}
Ok(())
}
}

impl fmt::Show for clean::FnDecl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f.buf, "({args}){arrow, select, yes{ -&gt; {ret}} other{}}",
Expand All @@ -413,20 +426,6 @@ impl fmt::Show for clean::FnDecl {
}
}

impl fmt::Show for ~[clean::Argument] {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut args = ~"";
for (i, input) in self.iter().enumerate() {
if i > 0 { args.push_str(", "); }
if input.name.len() > 0 {
args.push_str(format!("{}: ", input.name));
}
args.push_str(format!("{}", input.type_));
}
f.buf.write(args.as_bytes())
}
}

impl<'a> fmt::Show for Method<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Method(selfty, d) = *self;
Expand All @@ -448,7 +447,7 @@ impl<'a> fmt::Show for Method<'a> {
args.push_str("&amp;self");
}
}
for (i, input) in d.inputs.iter().enumerate() {
for (i, input) in d.inputs.values.iter().enumerate() {
if i > 0 || args.len() > 0 { args.push_str(", "); }
if input.name.len() > 0 {
args.push_str(format!("{}: ", input.name));
Expand Down
2 changes: 1 addition & 1 deletion src/librustuv/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ mod test {
unsafe {
let base = transmute::<*u8, *mut u8>(buf.base);
(*base) = 1;
(*ptr::mut_offset(base, 1)) = 2;
(*base.offset(1)) = 2;
}

assert!(slice[0] == 1);
Expand Down
12 changes: 6 additions & 6 deletions src/libextra/base64.rs → src/libserialize/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ impl<'a> ToBase64 for &'a [u8] {
* # Example
*
* ```rust
* extern mod extra;
* use extra::base64::{ToBase64, STANDARD};
* extern mod serialize;
* use serialize::base64::{ToBase64, STANDARD};
*
* fn main () {
* let str = [52,32].to_base64(STANDARD);
Expand Down Expand Up @@ -189,8 +189,8 @@ impl<'a> FromBase64 for &'a str {
* This converts a string literal to base64 and back.
*
* ```rust
* extern mod extra;
* use extra::base64::{ToBase64, FromBase64, STANDARD};
* extern mod serialize;
* use serialize::base64::{ToBase64, FromBase64, STANDARD};
* use std::str;
*
* fn main () {
Expand Down Expand Up @@ -261,8 +261,8 @@ impl<'a> FromBase64 for &'a str {

#[cfg(test)]
mod test {
use test::BenchHarness;
use base64::*;
use extra::test::BenchHarness;
use base64::{Config, FromBase64, ToBase64, STANDARD, URL_SAFE};

#[test]
fn test_to_base64_basic() {
Expand Down
3 changes: 1 addition & 2 deletions src/libserialize/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ pub mod reader {
}

pub fn vuint_at(data: &[u8], start: uint) -> Res {
use std::ptr::offset;
use std::mem::from_be32;

if data.len() - start < 4 {
Expand Down Expand Up @@ -163,7 +162,7 @@ pub mod reader {

unsafe {
let (ptr, _): (*u8, uint) = transmute(data);
let ptr = offset(ptr, start as int);
let ptr = ptr.offset(start as int);
let ptr: *i32 = transmute(ptr);
let val = from_be32(*ptr) as u32;

Expand Down
Loading