Skip to content

Commit aa034cd

Browse files
committed
auto merge of #17725 : alexcrichton/rust/rollup, r=alexcrichton
2 parents d0af3fe + d911936 commit aa034cd

File tree

320 files changed

+1053
-5369
lines changed

Some content is hidden

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

320 files changed

+1053
-5369
lines changed

Diff for: .travis.yml

+15-49
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,26 @@
11
# Use something that's not 'ruby' so we don't set up things like
2-
# RVM/bundler/ruby and whatnot. Right now 'rust' isn't a language on travis and
3-
# it treats unknown languages as ruby-like I believe.
2+
# RVM/bundler/ruby and whatnot. Right now 'rust' as a language actually
3+
# downloads a rust/cargo snapshot, which we don't really want for building rust.
44
language: c
55

6-
# Before we start doing anything, install a stock LLVM
6+
# Make sure we've got an up-to-date g++ compiler to get past the LLVM configure
7+
# script.
78
install:
8-
- sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.4 main' >> /etc/apt/sources.list"
9-
- sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list"
10-
- sudo sh -c "echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main' >> /etc/apt/sources.list"
11-
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
9+
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
1210
- sudo apt-get update -qq
13-
- sudo apt-get install -qq --force-yes -y llvm-$LLVM_VERSION
14-
llvm-${LLVM_VERSION}-dev clang-$LLVM_VERSION lldb-$LLVM_VERSION
11+
- sudo apt-get install g++-4.7
1512

16-
17-
# All of the llvm tools are suffixed with "-$VERS" which we don't want, so
18-
# symlink them all into a local directory and just use that
13+
# The test suite is in general way too stressful for travis, especially in
14+
# terms of time limit and reliability. In the past we've tried to scale things
15+
# back to only build the stage1 compiler and run a subset of tests, but this
16+
# didn't end up panning out very well.
1917
#
20-
# FIXME: this shouldn't update the src/llvm sub-repo, that takes about a minute
21-
# it's gotta download so much stuff.
18+
# As a result, we're just using travis to run `make tidy` now. It'll help
19+
# everyone find out about their trailing spaces early on!
2220
before_script:
23-
- mkdir -p local-llvm/bin
24-
- ln -nsf /usr/bin/llvm-config-$LLVM_VERSION local-llvm/bin/llvm-config
25-
- ln -nsf /usr/bin/llvm-mc-$LLVM_VERSION local-llvm/bin/llvm-mc
26-
- ln -nsf /usr/bin/llvm-as-$LLVM_VERSION local-llvm/bin/llvm-as
27-
- ln -nsf /usr/bin/llvm-dis-$LLVM_VERSION local-llvm/bin/llvm-dis
28-
- ln -nsf /usr/bin/llc-$LLVM_VERSION local-llvm/bin/llc
29-
- ln -nsf /usr/include/llvm-$LLVM_VERSION local-llvm/include
30-
- ./configure --disable-optimize-tests --llvm-root=`pwd`/local-llvm
31-
--enable-fast-make --enable-clang
32-
33-
# Tidy everything up first, then build a few things, and then run a few tests.
34-
# Note that this is meant to run in a "fairly small" amount of time, so this
35-
# isn't exhaustive at all.
36-
#
37-
# As a result of https://github.com/travis-ci/travis-ci/issues/1066, we run
38-
# everything in one large command instead of multiple commands.
39-
script: |
40-
if [[ $TRAVIS_PULL_REQUEST != 'false' ]]; then
41-
if [[ $LLVM_VERSION != '3.4' ]]; then exit 0; fi
42-
fi &&
43-
make tidy &&
44-
make -j4 rustc-stage1 RUSTFLAGS='-Z time-passes' &&
45-
make check-stage1-std check-stage1-rpass check-stage1-cfail check-stage1-rfail check-stage1-doc
46-
47-
env:
48-
global:
49-
- NO_BENCH=1
50-
matrix:
51-
- LLVM_VERSION=3.3
52-
- LLVM_VERSION=3.4
53-
54-
# We track this ourselves, and in theory we don't have to update the LLVM repo
55-
# (but sadly we do right now anyway).
56-
git:
57-
submodules: false
21+
- ./configure
22+
script:
23+
- make tidy
5824

5925
notifications:
6026
email: false

Diff for: mk/ctags.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CTAGS_LOCATIONS=$(patsubst ${CFG_SRC_DIR}src/llvm,, \
2828
$(patsubst ${CFG_SRC_DIR}src/rt/sundown,, \
2929
$(patsubst ${CFG_SRC_DIR}src/rt/vg,, \
3030
$(wildcard ${CFG_SRC_DIR}src/*) $(wildcard ${CFG_SRC_DIR}src/rt/*) \
31-
)))))))))))
31+
)))))))))
3232
CTAGS_OPTS=--options="${CFG_SRC_DIR}src/etc/ctags.rust" --languages=-javascript --recurse ${CTAGS_LOCATIONS}
3333
# We could use `--languages=Rust`, but there is value in producing tags for the
3434
# C++ parts of the code base too (at the time of writing, those are .h and .cpp

Diff for: mk/rt.mk

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# that's per-target so you're allowed to conditionally add files based on the
3636
# target.
3737
################################################################################
38-
NATIVE_LIBS := rust_builtin hoedown uv_support morestack miniz context_switch \
38+
NATIVE_LIBS := rust_builtin hoedown morestack miniz context_switch \
3939
rustrt_native rust_test_helpers
4040

4141
# $(1) is the target triple
@@ -50,7 +50,6 @@ NATIVE_DEPS_hoedown_$(1) := hoedown/src/autolink.c \
5050
hoedown/src/html_smartypants.c \
5151
hoedown/src/stack.c \
5252
hoedown/src/version.c
53-
NATIVE_DEPS_uv_support_$(1) := rust_uv.c
5453
NATIVE_DEPS_miniz_$(1) = miniz.c
5554
NATIVE_DEPS_rust_builtin_$(1) := rust_builtin.c \
5655
rust_android_dummy.c

Diff for: src/doc/guide-lifetimes.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,17 @@ copying.
305305
# Circle(Point, f64), // origin, radius
306306
# Rectangle(Point, Size) // upper-left, dimensions
307307
# }
308-
# static tau: f64 = 6.28;
309308
fn compute_area(shape: &Shape) -> f64 {
310309
match *shape {
311-
Circle(_, radius) => 0.5 * tau * radius * radius,
310+
Circle(_, radius) => std::f64::consts::PI * radius * radius,
312311
Rectangle(_, ref size) => size.w * size.h
313312
}
314313
}
315314
~~~
316315

317316
The first case matches against circles. Here, the pattern extracts the
318317
radius from the shape variant and the action uses it to compute the
319-
area of the circle. (Like any up-to-date engineer, we use the [tau
320-
circle constant][tau] and not that dreadfully outdated notion of pi).
321-
322-
[tau]: http://www.math.utah.edu/~palais/pi.html
318+
area of the circle.
323319

324320
The second match is more interesting. Here we match against a
325321
rectangle and extract its size: but rather than copy the `size`

Diff for: src/doc/guide-pointers.md

-13
Original file line numberDiff line numberDiff line change
@@ -632,19 +632,6 @@ This part is coming soon.
632632

633633
This part is coming soon.
634634

635-
# Gc
636-
637-
The `Gc<T>` type exists for historical reasons, and is [still used
638-
internally](https://github.com/rust-lang/rust/issues/7929) by the compiler.
639-
It is not even a 'real' garbage collected type at the moment.
640-
641-
In the future, Rust may have a real garbage collected type, and so it
642-
has not yet been removed for that reason.
643-
644-
## Best practices
645-
646-
There is currently no legitimate use case for the `Gc<T>` type.
647-
648635
# Raw Pointers
649636

650637
This part is coming soon.

Diff for: src/doc/guide-runtime.md

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ list):
3131
* Task synchronization
3232
* Task-local storage
3333
* Logging
34-
* Local heaps (GC heaps)
3534
* Task unwinding
3635

3736
## What is the runtime accomplishing?

Diff for: src/doc/guide-unsafe.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ pub struct Unique<T> {
208208
// Implement methods for creating and using the values in the box.
209209
210210
// NB: For simplicity and correctness, we require that T has kind Send
211-
// (owned boxes relax this restriction, and can contain managed (GC) boxes).
212-
// This is because, as implemented, the garbage collector would not know
213-
// about any shared boxes stored in the malloc'd region of memory.
211+
// (owned boxes relax this restriction).
214212
impl<T: Send> Unique<T> {
215213
pub fn new(value: T) -> Unique<T> {
216214
unsafe {

Diff for: src/doc/guide.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ The second point is the `println!()` part. This is calling a Rust **macro**,
195195
which is how metaprogramming is done in Rust. If it were a function instead, it
196196
would look like this: `println()`. For our purposes, we don't need to worry
197197
about this difference. Just know that sometimes, you'll see a `!`, and that
198-
means that you're calling a macro instead of a normal function. One last thing
199-
to mention: Rust's macros are significantly different than C macros, if you've
200-
used those. Don't be scared of using macros. We'll get to the details
198+
means that you're calling a macro instead of a normal function. Rust implements
199+
`println!` as a macro rather than a function for good reasons, but that's a
200+
very advanced topic. You'll learn more when we talk about macros later. One
201+
last thing to mention: Rust's macros are significantly different than C macros,
202+
if you've used those. Don't be scared of using macros. We'll get to the details
201203
eventually, you'll just have to trust us for now.
202204

203205
Next, `"Hello, world!"` is a **string**. Strings are a surprisingly complicated
@@ -659,14 +661,12 @@ error: mismatched types: expected `int` but found `()` (expected int but found (
659661
```
660662

661663
We expected an integer, but we got `()`. `()` is pronounced 'unit', and is a
662-
special type in Rust's type system. `()` is different than `null` in other
663-
languages, because `()` is distinct from other types. For example, in C, `null`
664-
is a valid value for a variable of type `int`. In Rust, `()` is _not_ a valid
665-
value for a variable of type `int`. It's only a valid value for variables of
666-
the type `()`, which aren't very useful. Remember how we said statements don't
667-
return a value? Well, that's the purpose of unit in this case. The semicolon
668-
turns any expression into a statement by throwing away its value and returning
669-
unit instead.
664+
special type in Rust's type system. In Rust, `()` is _not_ a valid value for a
665+
variable of type `int`. It's only a valid value for variables of the type `()`,
666+
which aren't very useful. Remember how we said statements don't return a value?
667+
Well, that's the purpose of unit in this case. The semicolon turns any
668+
expression into a statement by throwing away its value and returning unit
669+
instead.
670670

671671
There's one more time in which you won't see a semicolon at the end of a line
672672
of Rust code. For that, we'll need our next concept: functions.
@@ -1680,11 +1680,11 @@ just `int`s.
16801680

16811681
Rust provides a method on these `IoResult<T>`s called `ok()`, which does the
16821682
same thing as our `match` statement, but assuming that we have a valid value.
1683-
If we don't, it will terminate our program. In this case, if we can't get
1684-
input, our program doesn't work, so we're okay with that. In most cases, we
1685-
would want to handle the error case explicitly. The result of `ok()` has a
1686-
method, `expect()`, which allows us to give an error message if this crash
1687-
happens.
1683+
We then call `expect()` on the result, which will terminate our program if we
1684+
don't have a valid value. In this case, if we can't get input, our program
1685+
doesn't work, so we're okay with that. In most cases, we would want to handle
1686+
the error case explicitly. `expect()` allows us to give an error message if
1687+
this crash happens.
16881688

16891689
We will cover the exact details of how all of this works later in the Guide.
16901690
For now, this gives you enough of a basic understanding to work with.
@@ -2030,7 +2030,7 @@ fn main() {
20302030
match cmp(input, secret_number) {
20312031
Less => println!("Too small!"),
20322032
Greater => println!("Too big!"),
2033-
Equal => { println!("You win!"); },
2033+
Equal => println!("You win!"),
20342034
}
20352035
}
20362036
@@ -2727,7 +2727,8 @@ mod hello {
27272727
}
27282728
```
27292729

2730-
This will work:
2730+
Usage of the `pub` keyword is sometimes called 'exporting', because
2731+
we're making the function available for other modules. This will work:
27312732

27322733
```{notrust,ignore}
27332734
$ cargo run
@@ -3291,8 +3292,7 @@ use super::times_four;
32913292

32923293
Because we've made a nested module, we can import functions from the parent
32933294
module by using `super`. Sub-modules are allowed to 'see' private functions in
3294-
the parent. We sometimes call this usage of `use` a 're-export,' because we're
3295-
exporting the name again, somewhere else.
3295+
the parent.
32963296

32973297
We've now covered the basics of testing. Rust's tools are primitive, but they
32983298
work well in the simple cases. There are some Rustaceans working on building

Diff for: src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3381,7 +3381,7 @@ fn main() {
33813381
33823382
```
33833383

3384-
Patterns can also dereference pointers by using the `&`, `box` or `@` symbols,
3384+
Patterns can also dereference pointers by using the `&`, `box` symbols,
33853385
as appropriate. For example, these two matches on `x: &int` are equivalent:
33863386

33873387
```

Diff for: src/etc/x86.supp

-20
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,6 @@
373373
fun:_ZN4llvm4UsernwEjj
374374
}
375375

376-
{
377-
libuv-0-byte-realloc
378-
Memcheck:Leak
379-
fun:malloc
380-
...
381-
fun:*uv_loop_delete*
382-
}
383-
384376
{
385377
race-or-something-ask-pcwalton-0
386378
Memcheck:Value4
@@ -502,15 +494,3 @@
502494
fun:*
503495
...
504496
}
505-
506-
{
507-
libuv-mac-no-thread-join
508-
Memcheck:Leak
509-
fun:malloc_zone_malloc
510-
fun:_CFRuntimeCreateInstance
511-
fun:CFRunLoopSourceCreate
512-
fun:uv__platform_loop_init
513-
fun:uv__loop_init
514-
fun:uv_loop_new
515-
...
516-
}

Diff for: src/liballoc/heap.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,15 @@ mod imp {
182182

183183
#[inline]
184184
pub unsafe fn reallocate_inplace(ptr: *mut u8, size: uint, align: uint,
185-
_old_size: uint) -> bool {
185+
old_size: uint) -> bool {
186186
let flags = align_to_flags(align);
187-
je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) == size as size_t
187+
let new_size = je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as uint;
188+
// checking for failure to shrink is tricky
189+
if size < old_size {
190+
usable_size(size, align) == new_size as uint
191+
} else {
192+
new_size >= size
193+
}
188194
}
189195

190196
#[inline]
@@ -250,9 +256,9 @@ mod imp {
250256
}
251257

252258
#[inline]
253-
pub unsafe fn reallocate_inplace(_ptr: *mut u8, _size: uint, _align: uint,
254-
_old_size: uint) -> bool {
255-
false
259+
pub unsafe fn reallocate_inplace(_ptr: *mut u8, size: uint, _align: uint,
260+
old_size: uint) -> bool {
261+
size == old_size
256262
}
257263

258264
#[inline]
@@ -312,9 +318,9 @@ mod imp {
312318
}
313319

314320
#[inline]
315-
pub unsafe fn reallocate_inplace(_ptr: *mut u8, _size: uint, _align: uint,
316-
_old_size: uint) -> bool {
317-
false
321+
pub unsafe fn reallocate_inplace(_ptr: *mut u8, size: uint, _align: uint,
322+
old_size: uint) -> bool {
323+
size == old_size
318324
}
319325

320326
#[inline]
@@ -335,9 +341,21 @@ mod imp {
335341
}
336342

337343
#[cfg(test)]
338-
mod bench {
344+
mod test {
339345
extern crate test;
340346
use self::test::Bencher;
347+
use heap;
348+
349+
#[test]
350+
fn basic_reallocate_inplace_noop() {
351+
unsafe {
352+
let size = 4000;
353+
let ptr = heap::allocate(size, 8);
354+
let ret = heap::reallocate_inplace(ptr, size, 8, size);
355+
heap::deallocate(ptr, size, 8);
356+
assert!(ret);
357+
}
358+
}
341359

342360
#[bench]
343361
fn alloc_owned_small(b: &mut Bencher) {

Diff for: src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ pub use boxed as owned;
9292

9393
pub mod heap;
9494
pub mod libc_heap;
95-
pub mod util;
9695

9796
// Primitive types using the heaps above
9897

Diff for: src/liballoc/rc.rs

-8
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,6 @@ mod tests {
541541
assert!(y.upgrade().is_none());
542542
}
543543

544-
#[test]
545-
fn gc_inside() {
546-
// see issue #11532
547-
use std::gc::GC;
548-
let a = Rc::new(RefCell::new(box(GC) 1i));
549-
assert!(a.try_borrow_mut().is_some());
550-
}
551-
552544
#[test]
553545
fn weak_self_cyclic() {
554546
struct Cycle {

0 commit comments

Comments
 (0)