]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #12299 : sfackler/rust/limit-return, r=alexcrichton
bors [Sun, 16 Feb 2014 02:56:29 +0000 (18:56 -0800)]
auto merge of #12299 : sfackler/rust/limit-return, r=alexcrichton

This is useful in contexts like this:

```rust
let size = rdr.read_be_i32() as uint;
let mut limit = LimitReader::new(rdr.by_ref(), size);
let thing = read_a_thing(&mut limit);
assert!(limit.limit() == 0);
```

10 years agoauto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfackler
bors [Sun, 16 Feb 2014 00:36:27 +0000 (16:36 -0800)]
auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfackler

It's too easy to forget the `rust` tag to test something.

Closes #11698

10 years agoauto merge of #12235 : huonw/rust/raii-lock, r=alexcrichton
bors [Sat, 15 Feb 2014 23:21:28 +0000 (15:21 -0800)]
auto merge of #12235 : huonw/rust/raii-lock, r=alexcrichton

- adds a `LockGuard` type returned by `.lock` and `.trylock` that unlocks the mutex in the destructor
- renames `mutex::Mutex` to `StaticNativeMutex`
- adds a `NativeMutex` type with a destructor
- removes `LittleLock`
- adds `#[must_use]` to `sync::mutex::Guard` to remind people to use it

10 years agoConvert some unnecessary StaticNativeMutexes to NativeMutexes.
Huon Wilson [Sat, 15 Feb 2014 04:01:00 +0000 (15:01 +1100)]
Convert some unnecessary StaticNativeMutexes to NativeMutexes.

10 years agostd::unstable::mutex: streamline & clarify documentation.
Huon Wilson [Sat, 15 Feb 2014 03:24:51 +0000 (14:24 +1100)]
std::unstable::mutex: streamline & clarify documentation.

10 years agosync: Add `#[must_use]` to the Mutex guard.
Huon Wilson [Sat, 15 Feb 2014 01:53:23 +0000 (12:53 +1100)]
sync: Add `#[must_use]` to the Mutex guard.

This helps people remember to save the return value to keep the mutex
locked as appropriate.

10 years agostd: add a NativeMutex type as a wrapper to destroy StaticNativeMutex.
Huon Wilson [Sat, 15 Feb 2014 01:01:52 +0000 (12:01 +1100)]
std: add a NativeMutex type as a wrapper to destroy StaticNativeMutex.

This obsoletes LittleLock, and so it is removed.

10 years agostd: Rename unstable::mutex::Mutex to StaticNativeMutex.
Huon Wilson [Sat, 15 Feb 2014 00:18:49 +0000 (11:18 +1100)]
std: Rename unstable::mutex::Mutex to StaticNativeMutex.

This better reflects its purpose and design.

10 years agostd: add tests for the _noguard lock/signal/wait methods on Mutex.
Huon Wilson [Thu, 13 Feb 2014 08:29:13 +0000 (19:29 +1100)]
std: add tests for the _noguard lock/signal/wait methods on Mutex.

10 years agostd: add an RAII unlocker to Mutex.
Huon Wilson [Thu, 13 Feb 2014 06:17:50 +0000 (17:17 +1100)]
std: add an RAII unlocker to Mutex.

This automatically unlocks its lock when it goes out of scope, and
provides a safe(ish) method to call .wait.

10 years agoAdd a method to LimitReader to return the limit
Steven Fackler [Sat, 15 Feb 2014 21:51:37 +0000 (13:51 -0800)]
Add a method to LimitReader to return the limit

This is useful in contexts like this:

let size = rdr.read_be_i32() as uint;
let mut limit = LimitReader::new(rdr.by_ref(), size);
let thing = read_a_thing(&mut limit);
assert!(limit.limit() == 0);

10 years agoauto merge of #12272 : alexcrichton/rust/snapshot, r=kballard
bors [Sat, 15 Feb 2014 22:06:26 +0000 (14:06 -0800)]
auto merge of #12272 : alexcrichton/rust/snapshot, r=kballard

This notably contains the `extern mod` => `extern crate` change.

Closes #9880

10 years agoauto merge of #12296 : dotdash/rust/byval_noalias, r=cmr
bors [Sat, 15 Feb 2014 20:46:23 +0000 (12:46 -0800)]
auto merge of #12296 : dotdash/rust/byval_noalias, r=cmr

Function parameters that are to be passed by value but don't fit into a
single register are currently passed by creating a copy on the stack and
passing a pointer to that copy to the callee. Since the copy is made
just for the function call, there are no aliases.

For example, this sometimes allows LLVM to eliminate unnecessary calls
to drop glue. Given

````rust
struct Foo {
    a: int,
    b: Option<~str>,
}

extern {
    fn eat(eat: Option<~str>);
}

pub fn foo(v: Foo) {
    match v {
        Foo { a: _, b } => unsafe { eat(b) }
    }
}
````

LLVM currently can't eliminate the drop call for the string, because it
only sees a _pointer_ to Foo, for which it has to expect an alias. So we
get:

````llvm
; Function Attrs: uwtable
define void @_ZN3foo20h9f32c90ae7201edbxaa4v0.0E(%struct.Foo* nocapture) unnamed_addr #0 {
"_ZN34std..option..Option$LT$$UP$str$GT$9glue_drop17hc39b3015f3b9c69dE.exit":
  %1 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 1, i32 0
  %2 = load { i64, i64, [0 x i8] }** %1, align 8
  store { i64, i64, [0 x i8] }* null, { i64, i64, [0 x i8] }** %1, align 8
  %3 = ptrtoint { i64, i64, [0 x i8] }* %2 to i64
  %.fca.0.insert = insertvalue { i64 } undef, i64 %3, 0
  tail call void @eat({ i64 } %.fca.0.insert)
  %4 = load { i64, i64, [0 x i8] }** %1, align 8
  %5 = icmp eq { i64, i64, [0 x i8] }* %4, null
  br i1 %5, label %_ZN3Foo9glue_drop17hf611996539d3036fE.exit, label %"_ZN8_$UP$str9glue_drop17h15dbdbe2b8897a98E.exit.i.i"

"_ZN8_$UP$str9glue_drop17h15dbdbe2b8897a98E.exit.i.i": ; preds = %"_ZN34std..option..Option$LT$$UP$str$GT$9glue_drop17hc39b3015f3b9c69dE.exit"
  %6 = bitcast { i64, i64, [0 x i8] }* %4 to i8*
  tail call void @free(i8* %6) #1
  br label %_ZN3Foo9glue_drop17hf611996539d3036fE.exit

_ZN3Foo9glue_drop17hf611996539d3036fE.exit:       ; preds = %"_ZN34std..option..Option$LT$$UP$str$GT$9glue_drop17hc39b3015f3b9c69dE.exit", %"_ZN8_$UP$str9glue_drop17h15dbdbe2b8897a98E.exit.i.i"
  ret void
}
````

But with the `noalias` attribute, it can safely optimize that to:

````llvm
define void @_ZN3foo20hd28431f929f0d6c4xaa4v0.0E(%struct.Foo* noalias nocapture) unnamed_addr #0 {
_ZN3Foo9glue_drop17he9afbc09d4e9c851E.exit:
  %1 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 1, i32 0
  %2 = load { i64, i64, [0 x i8] }** %1, align 8
  store { i64, i64, [0 x i8] }* null, { i64, i64, [0 x i8] }** %1, align 8
  %3 = ptrtoint { i64, i64, [0 x i8] }* %2 to i64
  %.fca.0.insert = insertvalue { i64 } undef, i64 %3, 0
  tail call void @eat({ i64 } %.fca.0.insert)
  ret void
}
````

10 years agoDeclare by-value on-stack parameters to be noalias
Björn Steinbrink [Sat, 15 Feb 2014 20:31:20 +0000 (21:31 +0100)]
Declare by-value on-stack parameters to be noalias

Function parameters that are to be passed by value but don't fit into a
single register are currently passed by creating a copy on the stack and
passing a pointer to that copy to the callee. Since the copy is made
just for the function call, there are no aliases.

For example, this sometimes allows LLVM to eliminate unnecessary calls
to drop glue. Given

````rust
struct Foo {
    a: int,
    b: Option<~str>,
}

extern {
    fn eat(eat: Option<~str>);
}

pub fn foo(v: Foo) {
    match v {
        Foo { a: _, b } => unsafe { eat(b) }
    }
}
````

LLVM currently can't eliminate the drop call for the string, because it
only sees a _pointer_ to Foo, for which it has to expect an alias. So we
get:

````llvm
; Function Attrs: uwtable
define void @_ZN3foo20h9f32c90ae7201edbxaa4v0.0E(%struct.Foo* nocapture) unnamed_addr #0 {
"_ZN34std..option..Option$LT$$UP$str$GT$9glue_drop17hc39b3015f3b9c69dE.exit":
  %1 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 1, i32 0
  %2 = load { i64, i64, [0 x i8] }** %1, align 8
  store { i64, i64, [0 x i8] }* null, { i64, i64, [0 x i8] }** %1, align 8
  %3 = ptrtoint { i64, i64, [0 x i8] }* %2 to i64
  %.fca.0.insert = insertvalue { i64 } undef, i64 %3, 0
  tail call void @eat({ i64 } %.fca.0.insert)
  %4 = load { i64, i64, [0 x i8] }** %1, align 8
  %5 = icmp eq { i64, i64, [0 x i8] }* %4, null
  br i1 %5, label %_ZN3Foo9glue_drop17hf611996539d3036fE.exit, label %"_ZN8_$UP$str9glue_drop17h15dbdbe2b8897a98E.exit.i.i"

"_ZN8_$UP$str9glue_drop17h15dbdbe2b8897a98E.exit.i.i": ; preds = %"_ZN34std..option..Option$LT$$UP$str$GT$9glue_drop17hc39b3015f3b9c69dE.exit"
  %6 = bitcast { i64, i64, [0 x i8] }* %4 to i8*
  tail call void @free(i8* %6) #1
  br label %_ZN3Foo9glue_drop17hf611996539d3036fE.exit

_ZN3Foo9glue_drop17hf611996539d3036fE.exit:       ; preds = %"_ZN34std..option..Option$LT$$UP$str$GT$9glue_drop17hc39b3015f3b9c69dE.exit", %"_ZN8_$UP$str9glue_drop17h15dbdbe2b8897a98E.exit.i.i"
  ret void
}
````

But with the `noalias` attribute, it can safely optimize that to:

````llvm
define void @_ZN3foo20hd28431f929f0d6c4xaa4v0.0E(%struct.Foo* noalias nocapture) unnamed_addr #0 {
_ZN3Foo9glue_drop17he9afbc09d4e9c851E.exit:
  %1 = getelementptr inbounds %struct.Foo* %0, i64 0, i32 1, i32 0
  %2 = load { i64, i64, [0 x i8] }** %1, align 8
  store { i64, i64, [0 x i8] }* null, { i64, i64, [0 x i8] }** %1, align 8
  %3 = ptrtoint { i64, i64, [0 x i8] }* %2 to i64
  %.fca.0.insert = insertvalue { i64 } undef, i64 %3, 0
  tail call void @eat({ i64 } %.fca.0.insert)
  ret void
}
````

10 years agoauto merge of #12270 : bstrie/rust/pnoise, r=huonw
bors [Sat, 15 Feb 2014 18:51:26 +0000 (10:51 -0800)]
auto merge of #12270 : bstrie/rust/pnoise, r=huonw

Mostly just style fixes, but also remove a heap allocation and switch to using a buffered writer rather than doing 60,000 `println!`s.

10 years agoClean up the Perlin noise benchmark
Ben Striegel [Fri, 14 Feb 2014 19:03:39 +0000 (14:03 -0500)]
Clean up the Perlin noise benchmark

10 years agoauto merge of #12282 : cmr/rust/cleanup-ptr, r=huonw
bors [Sat, 15 Feb 2014 17:36:26 +0000 (09:36 -0800)]
auto merge of #12282 : cmr/rust/cleanup-ptr, r=huonw

10 years agoimpl fmt::Pointer for &T and &mut T
Corey Richardson [Sat, 15 Feb 2014 05:10:31 +0000 (00:10 -0500)]
impl fmt::Pointer for &T and &mut T

10 years agostd: clean up ptr a bit
Corey Richardson [Fri, 14 Feb 2014 23:42:01 +0000 (18:42 -0500)]
std: clean up ptr a bit

10 years agoauto merge of #12286 : sfackler/rust/no-conditions, r=alexcrichton
bors [Sat, 15 Feb 2014 11:56:27 +0000 (03:56 -0800)]
auto merge of #12286 : sfackler/rust/no-conditions, r=alexcrichton

10 years agoauto merge of #12283 : kballard/rust/env-args-bytes, r=erickt
bors [Sat, 15 Feb 2014 10:36:27 +0000 (02:36 -0800)]
auto merge of #12283 : kballard/rust/env-args-bytes, r=erickt

Change `os::args()` and `os::env()` to use `str::from_utf8_lossy()`.
Add new functions `os::args_as_bytes()` and `os::env_as_bytes()` to retrieve the args/env as byte vectors instead.

The existing methods were left returning strings because I expect that the common use-case is to want string handling.

Fixes #7188.

10 years agoFix all code examples
Alex Crichton [Sat, 15 Feb 2014 07:44:22 +0000 (23:44 -0800)]
Fix all code examples

10 years agoauto merge of #12230 : DaGenix/rust/io-decorator-changes, r=sfackler
bors [Sat, 15 Feb 2014 07:46:29 +0000 (23:46 -0800)]
auto merge of #12230 : DaGenix/rust/io-decorator-changes, r=sfackler

I created RefReader and RefWriter structs that wrap a mutable reference to a Reader or Writer value. This works exactly like the ByRef struct in the iter module and allows passing a reference to a Reader or Writer to function expecting a Reader or Writer by value with the caller retaining ownership to the original value.

I also modified LimitReader to take the wrapped Reader by value instead of by reference.

@sfackler

10 years agoRemove broken link to old conditions tutorial
Steven Fackler [Sat, 15 Feb 2014 07:44:31 +0000 (23:44 -0800)]
Remove broken link to old conditions tutorial

10 years agoUpdate rustdoc testing to test all code blocks
Alex Crichton [Sat, 15 Feb 2014 07:30:10 +0000 (23:30 -0800)]
Update rustdoc testing to test all code blocks

It's too easy to forget the `rust` tag to have a code example tested, and it's
far more common to have testable code than untestable code.

This alters rustdoc to have only two directives, `ignore` and `should_fail`. The
`ignore` directive ignores the code block entirely, and the `should_fail`
directive has been fixed to only fail the test if the code execution fails, not
also compilation.

10 years agoextern mod => extern crate
Alex Crichton [Fri, 14 Feb 2014 18:10:06 +0000 (10:10 -0800)]
extern mod => extern crate

This was previously implemented, and it just needed a snapshot to go through

10 years agoRegister new snapshots
Alex Crichton [Fri, 14 Feb 2014 18:03:53 +0000 (10:03 -0800)]
Register new snapshots

This enables the parser error for `extern mod` => `extern crate` transitions.

10 years agoUpdate LimitReader to take the Reader to wrap by value
Palmer Cox [Fri, 14 Feb 2014 04:28:11 +0000 (23:28 -0500)]
Update LimitReader to take the Reader to wrap by value

10 years agoCreate RefReader and RefWriter adaptor structs
Palmer Cox [Fri, 14 Feb 2014 04:27:53 +0000 (23:27 -0500)]
Create RefReader and RefWriter adaptor structs

RefReader and RefWriter allow a caller to pass a Reader or Writer
instance by reference to generic functions that are expecting arguments
by value.

10 years agoUse str::from_utf8_lossy() for os::env() and friends
Kevin Ballard [Fri, 14 Feb 2014 23:18:51 +0000 (15:18 -0800)]
Use str::from_utf8_lossy() for os::env() and friends

Parse the environment by default with from_utf8_lossy. Also provide
byte-vector equivalents (e.g. os::env_as_bytes()).

Unfortunately, setenv() can't have a byte-vector equivalent because of
Windows support, unless we want to define a setenv_bytes() that fails
under Windows for non-UTF8 (or non-UTF16).

10 years agoUse str::from_utf8_lossy() in os::args(), add os::args_as_bytes()
Kevin Ballard [Fri, 14 Feb 2014 22:42:40 +0000 (14:42 -0800)]
Use str::from_utf8_lossy() in os::args(), add os::args_as_bytes()

os::args() was using str::raw::from_c_str(), which would assert if the
C-string wasn't valid UTF-8. Switch to using from_utf8_lossy() instead,
and add a separate function os::args_as_bytes() that returns the ~[u8]
byte-vectors instead.

10 years agoAdd c_str::CString.as_bytes_no_nul()
Kevin Ballard [Fri, 14 Feb 2014 23:42:35 +0000 (15:42 -0800)]
Add c_str::CString.as_bytes_no_nul()

10 years agoauto merge of #12274 : brson/rust/mkfiles, r=alexcrichton
bors [Sat, 15 Feb 2014 04:51:26 +0000 (20:51 -0800)]
auto merge of #12274 : brson/rust/mkfiles, r=alexcrichton

I've been working on binary installers and ended up taking this detour, which does a few things:

* It expands the documentation on the build system with new comments in Makefile.in
* It displays some of that documentation via `make help`
* Removes some unused and broken snapshot code
* Adds `NO_MKFILE_DEPS` to convenience makefile hacking
* Moves almost all of Makefile.in to files in `mk/`

The documentation provided by `make help` and its implementation are somewhat quirky.

10 years agoauto merge of #12276 : alexcrichton/rust/issue-8449, r=kballard
bors [Sat, 15 Feb 2014 03:31:28 +0000 (19:31 -0800)]
auto merge of #12276 : alexcrichton/rust/issue-8449, r=kballard

This was just waiting for compiler-rt support, which was added in #12027

Closes #8449

10 years agoEnable 64-bit checked multiplication on 32-bit
Alex Crichton [Fri, 14 Feb 2014 20:54:15 +0000 (12:54 -0800)]
Enable 64-bit checked multiplication on 32-bit

This was just waiting for compiler-rt support, which was added in #12027

Closes #8449

10 years agomk: Address review feedback
Brian Anderson [Sat, 15 Feb 2014 03:17:50 +0000 (19:17 -0800)]
mk: Address review feedback

10 years agoauto merge of #12277 : alexcrichton/rust/fix-rustdoc-render, r=huonw
bors [Sat, 15 Feb 2014 01:51:29 +0000 (17:51 -0800)]
auto merge of #12277 : alexcrichton/rust/fix-rustdoc-render, r=huonw

The std macros used to be injected with a filename of "<std-macros>", but macros
are now injected with a filename of "<{} macros>" where `{}` is filled in with
the crate name. This updates rustdoc to understand this new system so it'll
render source more frequently.

10 years agomk: Move version info to top of main.mk
Brian Anderson [Fri, 14 Feb 2014 19:24:22 +0000 (11:24 -0800)]
mk: Move version info to top of main.mk

Just so it's easier to find.

10 years agomk: Improve build system help commands
Brian Anderson [Fri, 14 Feb 2014 11:34:18 +0000 (03:34 -0800)]
mk: Improve build system help commands

10 years agomk: Add NO_MKFILE_DEPS for turning off rebuild from makefile changes
Brian Anderson [Fri, 14 Feb 2014 08:10:06 +0000 (00:10 -0800)]
mk: Add NO_MKFILE_DEPS for turning off rebuild from makefile changes

10 years agomk: Move most of Makefile.in to .mk files
Brian Anderson [Fri, 14 Feb 2014 07:55:49 +0000 (23:55 -0800)]
mk: Move most of Makefile.in to .mk files

Because the build system treats Makefile.in and the .mk files slightly
differently (.in is copied, .mk are included), this makes the system
more uniform. Fewer build system changes will require a complete
reconfigure.

10 years agomk: Remove the concept of 'snapshot transitions'
Brian Anderson [Fri, 14 Feb 2014 07:25:07 +0000 (23:25 -0800)]
mk: Remove the concept of 'snapshot transitions'

This way of doing snapshots hasn't been used since 2011.

10 years agomk: Add some serious documentation and 'make help'
Brian Anderson [Fri, 14 Feb 2014 05:22:08 +0000 (21:22 -0800)]
mk: Add some serious documentation and 'make help'

'make help' is implemented in a fairly ridiculous way, using awk
to parse comments out of Makefile.in and displaying them.

10 years agoauto merge of #12271 : kballard/rust/vim-extern-crate, r=huonw
bors [Fri, 14 Feb 2014 23:51:29 +0000 (15:51 -0800)]
auto merge of #12271 : kballard/rust/vim-extern-crate, r=huonw

10 years agoAdd crate keyword to gedit language spec
Kevin Ballard [Fri, 14 Feb 2014 23:37:22 +0000 (15:37 -0800)]
Add crate keyword to gedit language spec

10 years agoAdd crate to emacs and kate modefiles
Kevin Ballard [Fri, 14 Feb 2014 22:36:37 +0000 (14:36 -0800)]
Add crate to emacs and kate modefiles

10 years agoauto merge of #12195 : kballard/rust/rustdoc-strip-impls-of-stripped, r=cmr
bors [Fri, 14 Feb 2014 21:36:35 +0000 (13:36 -0800)]
auto merge of #12195 : kballard/rust/rustdoc-strip-impls-of-stripped, r=cmr

Strip trait impls for types that are stripped either due to the strip-hidden or strip-private passes.

This fixes the search index including trait methods on stripped structs (which breaks searching), and it also removes private types from the implementors list of a trait.

Fixes #9981 and #11439.

10 years agoUpdate restrictions on rustdoc source rendering
Alex Crichton [Fri, 14 Feb 2014 21:11:36 +0000 (13:11 -0800)]
Update restrictions on rustdoc source rendering

The std macros used to be injected with a filename of "<std-macros>", but macros
are now injected with a filename of "<{} macros>" where `{}` is filled in with
the crate name. This updates rustdoc to understand this new system so it'll
render source more frequently.

10 years agoauto merge of #12267 : alexcrichton/rust/rollup, r=alexcrichton
bors [Fri, 14 Feb 2014 20:21:51 +0000 (12:21 -0800)]
auto merge of #12267 : alexcrichton/rust/rollup, r=alexcrichton

The last commit has the closed PRs

10 years agoAdd CheckedDiv to vim syntax
Kevin Ballard [Fri, 14 Feb 2014 20:02:18 +0000 (12:02 -0800)]
Add CheckedDiv to vim syntax

10 years agoUpdate vim syntax for extern crate
Kevin Ballard [Fri, 14 Feb 2014 19:27:53 +0000 (11:27 -0800)]
Update vim syntax for extern crate

10 years agoTest fixes and rebase conflicts from rollups
Alex Crichton [Fri, 14 Feb 2014 16:42:23 +0000 (08:42 -0800)]
Test fixes and rebase conflicts from rollups

PRs closed as part of this:

Closes #12212 r=alexcrichton
Closes #12215 r=brson
Closes #12246 r=pcwalton
Closes #12247 r=cmr
Closes #12251 r=brson
Closes #12255 r=alexcrichton
Closes #12257 r=alexcrichton
Closes #12258 r=huonw
Closes #12259 r=huonw
Closes #12263 r=kballard
Closes #12269 r=alexcrichton

10 years agotutorial: stronger wording in build instructions
Corey Richardson [Fri, 14 Feb 2014 18:55:30 +0000 (13:55 -0500)]
tutorial: stronger wording in build instructions

10 years agorustdoc: Strip impls of traits on #[doc(hidden)] types
Kevin Ballard [Tue, 11 Feb 2014 22:42:23 +0000 (14:42 -0800)]
rustdoc: Strip impls of traits on #[doc(hidden)] types

In the strip-hidden pass, record all types that were stripped, and make
a second pass stripping all impls of traits for these types.

10 years agorustdoc: Strip impls of stripped private types
Kevin Ballard [Tue, 11 Feb 2014 22:29:23 +0000 (14:29 -0800)]
rustdoc: Strip impls of stripped private types

In strip-private, also strip impls of traits for private types. This
fixes the search index so searching for "drop", "eq", etc doesn't throw
an exception.

10 years agoAdd MKFILE_DEPS to compiler-rt target
Alex Crichton [Fri, 14 Feb 2014 16:13:19 +0000 (08:13 -0800)]
Add MKFILE_DEPS to compiler-rt target

Currently when you run `make -jN` it's likely that you'll remove compiler-rt and
then it won't get cp'd back into the right place. I believe the reason for this
is that the compiler-rt library target never got updated so make decided it
never needed to copy the files back into place. The files were all there at the
beginning of `make`, but then we may clean out the stage0 versions if we unzip
the snapshot again.

10 years agoauto merge of #12205 : alexcrichton/rust/nodefaultlibs, r=brson
bors [Fri, 14 Feb 2014 18:41:45 +0000 (10:41 -0800)]
auto merge of #12205 : alexcrichton/rust/nodefaultlibs, r=brson

This will hopefully bring us closer to #11937. We're still using gcc's idea of
"startup files", but this should prevent us from leaking in dependencies that we
don't quite want (libgcc for example once compiler-rt is what we use).

10 years agoInvoke gcc with -nodefaultlibs
Alex Crichton [Tue, 4 Feb 2014 16:37:07 +0000 (08:37 -0800)]
Invoke gcc with -nodefaultlibs

This will hopefully bring us closer to #11937. We're still using gcc's idea of
"startup files", but this should prevent us from leaking in dependencies that we
don't quite want (libgcc for example once compiler-rt is what we use).

10 years agoRemoved the obsolete ast::CallSugar (previously used by `do`).
Eduard Burtescu [Fri, 14 Feb 2014 08:28:32 +0000 (10:28 +0200)]
Removed the obsolete ast::CallSugar (previously used by `do`).

10 years agoExpand ItemDecorator extensions in all contexts
Steven Fackler [Fri, 14 Feb 2014 06:57:43 +0000 (22:57 -0800)]
Expand ItemDecorator extensions in all contexts

Now that fold_item can return multiple items, this is pretty trivial. It
also recursively expands generated items so ItemDecorators can generate
items that are tagged with ItemDecorators!

Closes #4913

10 years agoAdd test for #8860
Edward Wang [Fri, 14 Feb 2014 05:27:05 +0000 (13:27 +0800)]
Add test for #8860

10 years agoRemoved libextra dependency from libsyntax.
HeroesGrave [Fri, 14 Feb 2014 03:51:26 +0000 (16:51 +1300)]
Removed libextra dependency from libsyntax.

10 years agoAdd function doc comments for extra::url::*
Dave Hodder [Thu, 13 Feb 2014 22:28:22 +0000 (22:28 +0000)]
Add function doc comments for extra::url::*

10 years agoEnsure an error is raised on infinite recursion
Flavio Percoco [Thu, 13 Feb 2014 20:19:03 +0000 (21:19 +0100)]
Ensure an error is raised on infinite recursion

10 years agoDon't copy &Trait and &mut Trait to temporaries for every call.
Eduard Burtescu [Thu, 13 Feb 2014 19:52:53 +0000 (21:52 +0200)]
Don't copy &Trait and &mut Trait to temporaries for every call.

10 years agoextra: Capture stdout/stderr of tests by default
Alex Crichton [Wed, 12 Feb 2014 18:25:09 +0000 (10:25 -0800)]
extra: Capture stdout/stderr of tests by default

When tests fail, their stdout and stderr is printed as part of the summary, but
this helps suppress failure messages from #[should_fail] tests and generally
clean up the output of the test runner.

10 years agoreturn value/use extra::test::black_box in benchmarks
lpy [Wed, 12 Feb 2014 15:39:21 +0000 (23:39 +0800)]
return value/use extra::test::black_box in benchmarks

10 years agoauto merge of #12207 : alexcrichton/rust/up-llvm, r=sfackler
bors [Fri, 14 Feb 2014 15:26:40 +0000 (07:26 -0800)]
auto merge of #12207 : alexcrichton/rust/up-llvm, r=sfackler

Includes an upstream commit by pcwalton to improve codegen of our enums getting
moved around.

This also introduces a new commit on top of our stack of patches to fix a mingw32 build issue. I have submitted the patch upstream: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140210/204653.html

I verified that this builds on the try bots, which amazes me because I think that c++11 is turned on now, but I guess we're still lucky!

Closes #10613 (pcwalton's patch landed)
Closes #11992 (llvm has removed these options)

10 years agoUpgrade LLVM
Alex Crichton [Thu, 6 Feb 2014 19:29:28 +0000 (11:29 -0800)]
Upgrade LLVM

Includes an upstream commit by pcwalton to improve codegen of our enums getting
moved around.

10 years agoauto merge of #12234 : sfackler/rust/restructure-item-decorator, r=huonw
bors [Fri, 14 Feb 2014 14:11:43 +0000 (06:11 -0800)]
auto merge of #12234 : sfackler/rust/restructure-item-decorator, r=huonw

The old method of building up a list of items and threading it through
all of the decorators was unwieldy and not really scalable as
non-deriving ItemDecorators become possible. The API is now that the
decorator gets an immutable reference to the item it's attached to, and
a callback that it can pass new items to. If we want to add syntax
extensions that can modify the item they're attached to, we can add that
later, but I think it'll have to be separate from ItemDecorator to avoid
strange ordering issues.

@huonw

10 years agoauto merge of #12192 : luqmana/rust/fix-cross, r=alexcrichton
bors [Fri, 14 Feb 2014 09:41:46 +0000 (01:41 -0800)]
auto merge of #12192 : luqmana/rust/fix-cross, r=alexcrichton

Fix some fall out from the big command line option changes.

10 years agoauto merge of #12186 : alexcrichton/rust/no-sleep-2, r=brson
bors [Fri, 14 Feb 2014 08:26:47 +0000 (00:26 -0800)]
auto merge of #12186 : alexcrichton/rust/no-sleep-2, r=brson

Any single-threaded task benchmark will spend a good chunk of time in `kqueue()` on osx and `epoll()` on linux, and the reason for this is that each time a task is terminated it will hit the syscall. When a task terminates, it context switches back to the scheduler thread, and the scheduler thread falls out of `run_sched_once` whenever it figures out that it did some work.

If we know that `epoll()` will return nothing, then we can continue to do work locally (only while there's work to be done). We must fall back to `epoll()` whenever there's active I/O in order to check whether it's ready or not, but without that (which is largely the case in benchmarks), we can prevent the costly syscall and can get a nice speedup.

I've separated the commits into preparation for this change and then the change itself, the last commit message has more details.

10 years agoauto merge of #12162 : eddyb/rust/ast-map-cheap-path, r=nikomatsakis
bors [Fri, 14 Feb 2014 07:06:46 +0000 (23:06 -0800)]
auto merge of #12162 : eddyb/rust/ast-map-cheap-path, r=nikomatsakis

10 years agoRefactored ast_map and friends, mainly to have Paths without storing them.
Eduard Burtescu [Fri, 14 Feb 2014 05:07:09 +0000 (07:07 +0200)]
Refactored ast_map and friends, mainly to have Paths without storing them.

10 years agoTweak ItemDecorator API
Steven Fackler [Thu, 13 Feb 2014 07:53:52 +0000 (23:53 -0800)]
Tweak ItemDecorator API

The old method of building up a list of items and threading it through
all of the decorators was unwieldy and not really scalable as
non-deriving ItemDecorators become possible. The API is now that the
decorator gets an immutable reference to the item it's attached to, and
a callback that it can pass new items to. If we want to add syntax
extensions that can modify the item they're attached to, we can add that
later, but I think it'll have to be separate from ItemDecorator to avoid
strange ordering issues.

10 years agoauto merge of #12256 : brson/rust/android, r=alexcrichton
bors [Fri, 14 Feb 2014 05:51:52 +0000 (21:51 -0800)]
auto merge of #12256 : brson/rust/android, r=alexcrichton

Android bot has been having some problems. A few details in the commits.

10 years agoStop looping on error waiting for android test results
Brian Anderson [Fri, 14 Feb 2014 05:19:06 +0000 (21:19 -0800)]
Stop looping on error waiting for android test results

These seem to be causing iloops on the bots. Let's rather see the errors.

10 years agocompiletest: Run all android tests serially
Brian Anderson [Fri, 14 Feb 2014 05:17:02 +0000 (21:17 -0800)]
compiletest: Run all android tests serially

This is an attempt to isolate test failures on the bots. It may also
eliminate problems with the emulators breaking by reducing the chance
of OOM.

10 years agoauto merge of #12172 : alexcrichton/rust/green-improvements, r=brson
bors [Fri, 14 Feb 2014 04:36:55 +0000 (20:36 -0800)]
auto merge of #12172 : alexcrichton/rust/green-improvements, r=brson

These commits pick off some low-hanging fruit which were slowing down spawning green threads. The major speedup comes from fixing a bug in stack caching where we never used any cached stacks!

The program I used to benchmark is at the end. It was compiled with `rustc --opt-level=3 bench.rs --test` and run as `RUST_THREADS=1 ./bench --bench`. I chose to use `RUST_THREADS=1` due to #11730 as the profiles I was getting interfered too much when all the schedulers were in play (and shouldn't be after #11730 is fixed). All of the units below are in ns/iter as reported by `--bench` (lower is better).

|               | green | native | raw    |
| ------------- | ----- | ------ | ------ |
| osx before    | 12699 | 24030  | 19734  |
| linux before  | 10223 | 125983 | 122647 |
| osx after     |  3847 | 25771  | 20835  |
| linux after   |  2631 | 135398 | 122765 |

Note that this is *not* a benchmark of spawning green tasks vs native tasks. I put in the native numbers just to get a ballpark of where green tasks are. This is benchmark is *clearly* benefiting from stack caching. Also, OSX is clearly not 5x faster than linux, I think my VM is just much slower.

All in all, this ended up being a nice 4x speedup for spawning a green task when you're using a cached stack.

```rust
extern mod extra;
extern mod native;
use std::rt::thread::Thread;

#[bench]
fn green(bh: &mut extra::test::BenchHarness) {
    let (p, c) = SharedChan::new();
    bh.iter(|| {
        let c = c.clone();
        spawn(proc() {
            c.send(());
        });
        p.recv();
    });
}

#[bench]
fn native(bh: &mut extra::test::BenchHarness) {
    let (p, c) = SharedChan::new();
    bh.iter(|| {
        let c = c.clone();
        native::task::spawn(proc() {
            c.send(());
        });
        p.recv();
    });
}

#[bench]
fn raw(bh: &mut extra::test::BenchHarness) {
    bh.iter(|| {
        Thread::start(proc() {}).join()
    });
}
```

10 years agoRemove two allocations from spawning a green task
Alex Crichton [Tue, 11 Feb 2014 00:13:50 +0000 (16:13 -0800)]
Remove two allocations from spawning a green task

Two unfortunate allocations were wrapping a proc() in a proc() with
GreenTask::build_start_wrapper, and then boxing this proc in a ~proc() inside of
Context::new(). Both of these allocations were a direct result from two
conditions:

1. The Context::new() function has a nice api of taking a procedure argument to
   start up a new context with. This inherently required an allocation by
   build_start_wrapper because extra code needed to be run around the edges of a
   user-provided proc() for a new task.

2. The initial bootstrap code only understood how to pass one argument to the
   next function. By modifying the assembly and entry points to understand more
   than one argument, more information is passed through in registers instead of
   allocating a pointer-sized context.

This is sadly where I end up throwing mips under a bus because I have no idea
what's going on in the mips context switching code and don't know how to modify
it.

Closes #7767
cc #11389

10 years agoDon't require an allocation for on_exit messages
Alex Crichton [Mon, 10 Feb 2014 22:49:56 +0000 (14:49 -0800)]
Don't require an allocation for on_exit messages

Instead, use an enum to allow running both a procedure and sending the task
result over a channel. I expect the common case to be sending on a channel (e.g.
task::try), so don't require an extra allocation in the common case.

cc #11389

10 years agoDon't allocate in LocalHeap::new()
Alex Crichton [Mon, 10 Feb 2014 22:41:57 +0000 (14:41 -0800)]
Don't allocate in LocalHeap::new()

One of these is allocated for every task, trying to cut down on allocations

cc #11389

10 years agoFix a bug where cached stacks weren't re-used
Alex Crichton [Mon, 10 Feb 2014 22:17:10 +0000 (14:17 -0800)]
Fix a bug where cached stacks weren't re-used

The condition was the wrong direction and it also didn't take equality into
account. Tests were added for both cases.

For the small benchmark of `task::try(proc() {}).unwrap()`, this takes the
iteration time on OSX from 15119 ns/iter to 6179 ns/iter (timed with
RUST_THREADS=1)

cc #11389

10 years agoauto merge of #12061 : pongad/rust/delorderable, r=cmr
bors [Fri, 14 Feb 2014 03:16:59 +0000 (19:16 -0800)]
auto merge of #12061 : pongad/rust/delorderable, r=cmr

#12057

10 years agoRemoved num::Orderable
Michael Darakananda [Thu, 6 Feb 2014 07:34:33 +0000 (02:34 -0500)]
Removed num::Orderable

10 years agoauto merge of #12017 : FlaPer87/rust/replace-mod-crate, r=alexcrichton
bors [Fri, 14 Feb 2014 00:32:01 +0000 (16:32 -0800)]
auto merge of #12017 : FlaPer87/rust/replace-mod-crate, r=alexcrichton

The first setp for #9880 is to add a new `crate` keyword. This PR does exactly that. I took a chance to refactor `parse_item_foreign_mod` and I broke it down into 2 separate methods to isolate each feature.

The next step will be to push a new stage0 snapshot and then get rid of all `extern mod` around the code.

10 years agoauto merge of #12248 : alexcrichton/rust/rollup, r=alexcrichton
bors [Thu, 13 Feb 2014 23:17:21 +0000 (15:17 -0800)]
auto merge of #12248 : alexcrichton/rust/rollup, r=alexcrichton

This passed `make check` locally, so hopefully it passes on bors!

10 years agomk: Fix non-android cross builds.
Luqman Aden [Tue, 11 Feb 2014 21:51:08 +0000 (16:51 -0500)]
mk: Fix non-android cross builds.

10 years agoRebase conflicts from this giant stack of patches
Alex Crichton [Thu, 13 Feb 2014 20:50:46 +0000 (12:50 -0800)]
Rebase conflicts from this giant stack of patches

List of PRs contained in this rollup:

Closes #12167 r=alexcrichton
Closes #12200 r=alexcrichton
Closes #12206 r=pcwalton
Closes #12209 r=huonw
Closes #12211 r=pcwalton
Closes #12217 r=brson
Closes #12218 r=alexcrichton
Closes #12220 r=alexcrichton
Closes #12222 r=kballard
Closes #12225 r=alexcrichton
Closes #12227 r=kballard
Closes #12237 r=alexcrichton
Closes #12240 r=kballard

10 years agoLift $dst outside the closure in write!
Alex Crichton [Thu, 13 Feb 2014 12:31:19 +0000 (04:31 -0800)]
Lift $dst outside the closure in write!

If you were writing to something along the lines of `self.foo` then with the new
closure rules it meant that you were borrowing `self` for the entirety of the
closure, meaning that you couldn't format other fields of `self` at the same
time as writing to a buffer contained in `self`.

By lifting the borrow outside of the closure the borrow checker can better
understand that you're only borrowing one of the fields at a time. This had to
use type ascription as well in order to preserve trait object coercions.

10 years agoremove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset)
JeremyLetang [Mon, 10 Feb 2014 21:50:42 +0000 (16:50 -0500)]
remove duplicate function from std::ptr (is_null, is_not_null, offset, mut_offset)

10 years agoRegister new snapshots
Alex Crichton [Thu, 13 Feb 2014 00:40:17 +0000 (16:40 -0800)]
Register new snapshots

10 years agomk: make NO_REBUILD more forceful and more general.
Huon Wilson [Thu, 13 Feb 2014 08:35:43 +0000 (19:35 +1100)]
mk: make NO_REBUILD more forceful and more general.

Previously crates like `green` and `native` would still depend on their
parents when running `make check-stage2-green NO_REBUILD=1`, this
ensures that they only depend on their source files.

Also, apply NO_REBUILD to the crate doc tests, so, for example,
`check-stage2-doc-std` will use an already compiled `rustdoc` directly.

10 years agoRelax an assertion in start_selection()
Alex Crichton [Thu, 13 Feb 2014 04:51:42 +0000 (20:51 -0800)]
Relax an assertion in start_selection()

It asserted that the previous count was always nonnegative, but DISCONNECTED is
a valid value for it to see. In order to continue to remember to store
DISCONNECTED after DISCONNECTED was seen, I also added a helper method.

Closes #12226

10 years agostd::comm: replace Handle.id with a method.
Huon Wilson [Thu, 13 Feb 2014 03:10:29 +0000 (14:10 +1100)]
std::comm: replace Handle.id with a method.

The `id` shouldn't be changed by external code, and exposing it publicly
allows to be accidentally changed.

Also, remove the first element special case in the `select!` macro.

10 years agoAdd documentation for conditional-compilation
Tobias Bucher [Wed, 12 Feb 2014 23:38:14 +0000 (00:38 +0100)]
Add documentation for conditional-compilation

This documents in-source conditions using #[cfg(...)] and configurations
pre-defined by the compiler.

Fix #7962.

10 years agoAdd some missing Show implementations in libstd
Brendan Zabarauskas [Wed, 12 Feb 2014 19:41:34 +0000 (06:41 +1100)]
Add some missing Show implementations in libstd

10 years agoMove base64 and hex from libextra to libserialize
Liigo Zhuang [Wed, 12 Feb 2014 00:40:52 +0000 (08:40 +0800)]
Move base64 and hex from libextra to libserialize

10 years agoRemove a source of O(n^2) running time in bigints.
Felix S. Klock II [Sun, 9 Feb 2014 22:13:47 +0000 (23:13 +0100)]
Remove a source of O(n^2) running time in bigints.

::num::bigint, Remove a source of O(n^2) running time in `fn shr_bits`.

I'll cut to the chase: On my laptop, this brings the running time on
`pidigits 2000` (from src/test/bench/shootout-pidigits.rs) from this:
```
% time ./pidigits 2000 > /dev/null

real 0m7.695s
user 0m7.690s
sys 0m0.005s
```
to this:
```
% time ./pidigits 2000 > /dev/null

real 0m0.322s
user 0m0.318s
sys 0m0.004s
```

The previous code was building up a vector by repeatedly making a
fresh copy for each element that was unshifted onto the front,
yielding quadratic running time.  This fixes that by building up the
vector in reverse order (pushing elements onto the end) and then
reversing it.

(Another option would be to build up a zero-initialized vector of the
desired length and then installing all of the shifted result elements
into their target index, but this was easier to hack up quickly, and
yields the desired asymptotic improvement.  I have been thinking of
adding a `vec::from_fn_rev` to handle this case, maybe I will try that
this weekend.)

10 years agoResolve type variables when checking casting to char
Seo Sanghyeon [Wed, 12 Feb 2014 15:42:28 +0000 (00:42 +0900)]
Resolve type variables when checking casting to char