Skip to content

Commit 94d453e

Browse files
committed
auto merge of #12248 : alexcrichton/rust/rollup, r=alexcrichton
This passed `make check` locally, so hopefully it passes on bors!
2 parents cfb87f1 + 640b228 commit 94d453e

Some content is hidden

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

50 files changed

+651
-398
lines changed

Makefile.in

+2-6
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ ifdef TRACE
125125
CFG_RUSTC_FLAGS += -Z trace
126126
endif
127127
ifdef CFG_DISABLE_RPATH
128-
# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
129-
RUSTFLAGS_STAGE1 += -C no-rpath
130-
RUSTFLAGS_STAGE2 += -C no-rpath
131-
RUSTFLAGS_STAGE3 += -C no-rpath
128+
CFG_RUSTC_FLAGS += -C no-rpath
132129
endif
133130

134131
# The executables crated during this compilation process have no need to include
@@ -140,8 +137,7 @@ endif
140137
# snapshot will be generated with a statically linked rustc so we only have to
141138
# worry about the distribution of one file (with its native dynamic
142139
# dependencies)
143-
#
144-
# NOTE: after a snapshot (stage0), put this on stage0 as well
140+
RUSTFLAGS_STAGE0 += -C prefer-dynamic
145141
RUSTFLAGS_STAGE1 += -C prefer-dynamic
146142

147143
# platform-specific auto-configuration

mk/dist.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
1212
PKG_EXE = $(PKG_DIR)-install.exe
1313
endif
1414

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

1717
PKG_FILES := \
1818
$(S)COPYRIGHT \

mk/tests.mk

+22-12
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,22 @@ $(foreach host,$(CFG_HOST), \
333333

334334
define TEST_RUNNER
335335

336-
# If NO_REBUILD is set then break the dependencies on extra so we can
337-
# test crates without rebuilding std and extra first
336+
# If NO_REBUILD is set then break the dependencies on everything but
337+
# the source files so we can test crates without rebuilding any of the
338+
# parent crates.
338339
ifeq ($(NO_REBUILD),)
339-
STDTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
340+
TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
340341
$$(foreach crate,$$(TARGET_CRATES),\
341-
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate))
342+
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
343+
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))
342344
else
343-
STDTESTDEP_$(1)_$(2)_$(3)_$(4) =
345+
TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
344346
endif
345347

346348
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): CFG_COMPILER = $(2)
347349
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
348-
$$(CRATEFILE_$(4)) \
349-
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
350-
$$(STDTESTDEP_$(1)_$(2)_$(3)_$(4))
350+
$$(CRATEFILE_$(4)) \
351+
$$(TESTDEP_$(1)_$(2)_$(3)_$(4))
351352
@$$(call E, oxidize: $$@)
352353
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
353354
-L "$$(RT_OUTPUT_DIR_$(2))" \
@@ -684,13 +685,22 @@ $(foreach host,$(CFG_HOST), \
684685

685686
define DEF_CRATE_DOC_TEST
686687

688+
# If NO_REBUILD is set then break the dependencies on everything but
689+
# the source files so we can test crate documentation without
690+
# rebuilding any of the parent crates.
691+
ifeq ($(NO_REBUILD),)
692+
DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
693+
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
694+
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
695+
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
696+
else
697+
DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
698+
endif
699+
687700
check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
688701

689702
ifeq ($(2),$$(CFG_BUILD))
690-
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
691-
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
692-
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
693-
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
703+
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
694704
@$$(call E, run doc-$(4) [$(2)])
695705
$$(Q)$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) --test \
696706
$$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@

src/doc/guide-ffi.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<T: Send> Unique<T> {
195195
pub fn new(value: T) -> Unique<T> {
196196
unsafe {
197197
let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
198-
assert!(!ptr::is_null(ptr));
198+
assert!(!ptr.is_null());
199199
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
200200
// move_val_init moves a value into this memory without
201201
// attempting to drop the original value.

src/doc/rust.md

+74-10
Original file line numberDiff line numberDiff line change
@@ -1725,31 +1725,95 @@ mod bar {
17251725
pub type int8_t = i8;
17261726
~~~~
17271727

1728-
> **Note:** In future versions of Rust, user-provided extensions to the compiler will be able to interpret attributes.
1729-
> When this facility is provided, the compiler will distinguish between language-reserved and user-available attributes.
1728+
> **Note:** In future versions of Rust, user-provided extensions to the compiler
1729+
> will be able to interpret attributes. When this facility is provided, the
1730+
> compiler will distinguish between language-reserved and user-available
1731+
> attributes.
17301732
1731-
At present, only the Rust compiler interprets attributes, so all attribute
1732-
names are effectively reserved. Some significant attributes include:
1733+
At present, only the Rust compiler interprets attributes, so all attribute names
1734+
are effectively reserved. Some significant attributes include:
17331735

17341736
* The `doc` attribute, for documenting code in-place.
1735-
* The `cfg` attribute, for conditional-compilation by build-configuration.
1737+
* The `cfg` attribute, for conditional-compilation by build-configuration (see
1738+
[Conditional compilation](#conditional-compilation)).
17361739
* The `crate_id` attribute, for describing the package ID of a crate.
17371740
* The `lang` attribute, for custom definitions of traits and functions that are
17381741
known to the Rust compiler (see [Language items](#language-items)).
17391742
* The `link` attribute, for describing linkage metadata for a extern blocks.
17401743
* The `test` attribute, for marking functions as unit tests.
17411744
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
17421745
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
1743-
* The `deriving` attribute, for automatically generating
1744-
implementations of certain traits.
1746+
* The `deriving` attribute, for automatically generating implementations of
1747+
certain traits.
17451748
* The `inline` attribute, for expanding functions at caller location (see
17461749
[Inline attributes](#inline-attributes)).
1747-
* The `static_assert` attribute, for asserting that a static bool is true at compiletime
1748-
* The `thread_local` attribute, for defining a `static mut` as a thread-local. Note that this is
1749-
only a low-level building block, and is not local to a *task*, nor does it provide safety.
1750+
* The `static_assert` attribute, for asserting that a static bool is true at
1751+
compiletime.
1752+
* The `thread_local` attribute, for defining a `static mut` as a thread-local.
1753+
Note that this is only a low-level building block, and is not local to a
1754+
*task*, nor does it provide safety.
17501755

17511756
Other attributes may be added or removed during development of the language.
17521757

1758+
### Conditional compilation
1759+
1760+
Sometimes one wants to have different compiler outputs from the same code,
1761+
depending on build target, such as targeted operating system, or to enable
1762+
release builds.
1763+
1764+
There are two kinds of configuration options, one that is either defined or not
1765+
(`#[cfg(foo)]`), and the other that contains a string that can be checked
1766+
against (`#[cfg(bar = "baz")]` (currently only compiler-defined configuration
1767+
options can have the latter form).
1768+
1769+
~~~~
1770+
// The function is only included in the build when compiling for OSX
1771+
#[cfg(target_os = "macos")]
1772+
fn macos_only() {
1773+
// ...
1774+
}
1775+
1776+
// This function is only included when either foo or bar is defined
1777+
#[cfg(foo)]
1778+
#[cfg(bar)]
1779+
fn needs_foo_or_bar() {
1780+
// ...
1781+
}
1782+
1783+
// This function is only included when compiling for a unixish OS with a 32-bit
1784+
// architecture
1785+
#[cfg(unix, target_word_size = "32")]
1786+
fn on_32bit_unix() {
1787+
// ...
1788+
}
1789+
~~~~
1790+
1791+
This illustrates some conditional compilation can be achieved using the
1792+
`#[cfg(...)]` attribute. Note that `#[cfg(foo, bar)]` is a condition that needs
1793+
both `foo` and `bar` to be defined while `#[cfg(foo)] #[cfg(bar)]` only needs
1794+
one of `foo` and `bar` to be defined (this resembles in the disjunctive normal
1795+
form). Additionally, one can reverse a condition by enclosing it in a
1796+
`not(...)`, like e. g. `#[cfg(not(target_os = "win32"))]`.
1797+
1798+
To pass a configuration option which triggers a `#[cfg(identifier)]` one can use
1799+
`rustc --cfg identifier`. In addition to that, the following configurations are
1800+
pre-defined by the compiler:
1801+
1802+
* `target_arch = "..."`. Target CPU architecture, such as `"x86"`, `"x86_64"`
1803+
`"mips"`, or `"arm"`.
1804+
* `target_endian = "..."`. Endianness of the target CPU, either `"little"` or
1805+
`"big"`.
1806+
* `target_family = "..."`. Operating system family of the target, e. g.
1807+
`"unix"` or `"windows"`. The value of this configuration option is defined as
1808+
a configuration itself, like `unix` or `windows`.
1809+
* `target_os = "..."`. Operating system of the target, examples include
1810+
`"win32"`, `"macos"`, `"linux"`, `"android"` or `"freebsd"`.
1811+
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
1812+
for 32-bit CPU targets, and likewise set to `"64"` for 64-bit CPU targets.
1813+
* `test`. Only set in test builds (`rustc --test`).
1814+
* `unix`. See `target_family`.
1815+
* `windows`. See `target_family`.
1816+
17531817
### Lint check attributes
17541818

17551819
A lint check names a potentially undesirable coding pattern, such as

src/libarena/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use std::cast;
3434
use std::cell::{Cell, RefCell};
3535
use std::mem;
3636
use std::num;
37-
use std::ptr;
3837
use std::kinds::marker;
3938
use std::rc::Rc;
4039
use std::rt::global_heap;
@@ -144,7 +143,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
144143
let fill = chunk.fill.get();
145144

146145
while idx < fill {
147-
let tydesc_data: *uint = transmute(ptr::offset(buf, idx as int));
146+
let tydesc_data: *uint = transmute(buf.offset(idx as int));
148147
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
149148
let (size, align) = ((*tydesc).size, (*tydesc).align);
150149

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

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

263262
let buf = self.head.as_ptr();
264-
return (ptr::offset(buf, tydesc_start as int), ptr::offset(buf, start as int));
263+
return (buf.offset(tydesc_start as int), buf.offset(start as int));
265264
}
266265
}
267266

src/libextra/c_vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl <T> CVec<T> {
119119
pub fn get<'a>(&'a self, ofs: uint) -> &'a T {
120120
assert!(ofs < self.len);
121121
unsafe {
122-
&*ptr::mut_offset(self.base, ofs as int)
122+
&*self.base.offset(ofs as int)
123123
}
124124
}
125125

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

src/libextra/lib.rs

-12
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,10 @@ Rust extras are part of the standard Rust distribution.
3535
#[deny(missing_doc)];
3636

3737
extern mod sync;
38-
#[cfg(not(stage0))]
3938
extern mod serialize;
4039

4140
extern mod collections;
4241

43-
#[cfg(stage0)]
44-
pub mod serialize {
45-
#[allow(missing_doc)];
46-
// Temp re-export until after a snapshot
47-
extern mod serialize = "serialize";
48-
pub use self::serialize::{Encoder, Decoder, Encodable, Decodable,
49-
EncoderHelpers, DecoderHelpers};
50-
}
51-
5242
// Utility modules
5343

5444
pub mod c_vec;
@@ -59,11 +49,9 @@ pub mod url;
5949
pub mod json;
6050
pub mod tempfile;
6151
pub mod time;
62-
pub mod base64;
6352
pub mod workcache;
6453
pub mod enum_set;
6554
pub mod stats;
66-
pub mod hex;
6755

6856
#[cfg(unicode)]
6957
mod unicode;

src/libnum/bigint.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,12 @@ impl BigUint {
784784
if n_bits == 0 || self.data.is_empty() { return (*self).clone(); }
785785

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

@@ -2637,4 +2638,15 @@ mod bench {
26372638
fib.to_str();
26382639
});
26392640
}
2641+
2642+
#[bench]
2643+
fn shr(bh: &mut BenchHarness) {
2644+
let n = { let one : BigUint = One::one(); one << 1000 };
2645+
bh.iter(|| {
2646+
let mut m = n.clone();
2647+
for _ in range(0, 10) {
2648+
m = m >> 1;
2649+
}
2650+
})
2651+
}
26402652
}

src/librustc/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use std::run;
3434
use std::str;
3535
use std::io;
3636
use std::io::fs;
37-
use extra::hex::ToHex;
37+
use serialize::hex::ToHex;
3838
use extra::tempfile::TempDir;
3939
use syntax::abi;
4040
use syntax::ast;

src/librustc/metadata/loader.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use std::io;
3030
use std::num;
3131
use std::option;
3232
use std::os::consts::{macos, freebsd, linux, android, win32};
33-
use std::ptr;
3433
use std::str;
3534
use std::vec;
3635
use flate;
@@ -340,7 +339,7 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
340339
});
341340
if !version_ok { return None; }
342341

343-
let cvbuf1 = ptr::offset(cvbuf, vlen as int);
342+
let cvbuf1 = cvbuf.offset(vlen as int);
344343
debug!("inflating {} bytes of compressed metadata",
345344
csz - vlen);
346345
vec::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| {

src/librustc/middle/trans/builder.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use std::cast;
2121
use std::hashmap::HashMap;
2222
use std::libc::{c_uint, c_ulonglong, c_char};
2323
use syntax::codemap::Span;
24-
use std::ptr::is_not_null;
2524

2625
pub struct Builder<'a> {
2726
llbuilder: BuilderRef,
@@ -492,7 +491,7 @@ impl<'a> Builder<'a> {
492491
debug!("Store {} -> {}",
493492
self.ccx.tn.val_to_str(val),
494493
self.ccx.tn.val_to_str(ptr));
495-
assert!(is_not_null(self.llbuilder));
494+
assert!(self.llbuilder.is_not_null());
496495
self.count_insn("store");
497496
unsafe {
498497
llvm::LLVMBuildStore(self.llbuilder, val, ptr);
@@ -503,7 +502,7 @@ impl<'a> Builder<'a> {
503502
debug!("Store {} -> {}",
504503
self.ccx.tn.val_to_str(val),
505504
self.ccx.tn.val_to_str(ptr));
506-
assert!(is_not_null(self.llbuilder));
505+
assert!(self.llbuilder.is_not_null());
507506
self.count_insn("store.volatile");
508507
unsafe {
509508
let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr);

src/librustc/middle/typeck/check/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3035,6 +3035,7 @@ pub fn check_expr_with_unifier(fcx: @FnCtxt,
30353035
if type_is_c_like_enum(fcx, expr.span, t_e) && t_1_is_trivial {
30363036
// casts from C-like enums are allowed
30373037
} else if t_1_is_char {
3038+
let te = fcx.infcx().resolve_type_vars_if_possible(te);
30383039
if ty::get(te).sty != ty::ty_uint(ast::TyU8) {
30393040
fcx.type_error_message(expr.span, |actual| {
30403041
format!("only `u8` can be cast as `char`, not `{}`", actual)

src/librustc/util/sha2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::iter::range_step;
1616
use std::num::Zero;
1717
use std::vec;
1818
use std::vec::bytes::{MutableByteVector, copy_memory};
19-
use extra::hex::ToHex;
19+
use serialize::hex::ToHex;
2020

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

534534
// A normal addition - no overflow occurs
535535
#[test]

0 commit comments

Comments
 (0)