Commit Graph

28486 Commits

Author SHA1 Message Date
bors
cafa47506d auto merge of #16497 : michaelwoerister/rust/no_debug_attribute, r=pcwalton
Fixes #15332.
2014-08-15 14:06:17 +00:00
Michael Woerister
910dd2635c debuginfo: Add a "no_debug" attribute that allows to exclude functions from debuginfo generation. 2014-08-15 15:35:43 +02:00
wickerwaka
08d7fc76cf Change how libgetopts handles options grouped together
As soon as an option is found that takes an argument, consume the rest
of the string and store it into i_arg. Previously this would only happen
if the character after the option was not a recognized option.

Addresses issue #16348
2014-08-15 06:34:24 -07:00
Björn Steinbrink
a5590b3c75 Properly canonicalize crate paths specified via --extern
Crates that are resolved normally have their path canonicalized and all
symlinks resolved. This does currently not happen for paths specified
using the --extern option to rustc, which can lead to rustc thinking
that it encountered two different versions of a crate, when it's
actually the same version found through different paths.

To fix this, we must store the canonical path for crates found via
--extern and also use the canonical path when comparing paths.

Fixes #16496
2014-08-15 14:40:09 +02:00
bors
406de8d5dd auto merge of #16500 : jackheizer/rust/export-name, r=alexcrichton 2014-08-15 12:11:16 +00:00
Björn Steinbrink
6c5d97a5da Generate slightly better unoptimized code for for-loops
The discriminant for Option values is either 0 or 1, so we can just
truncate the value to an i1, which ends up as a no-op for Options
containing pointers.
2014-08-15 13:12:48 +02:00
bors
1d12b6d444 auto merge of #16494 : pnkfelix/rust/fsk-quotstx-followup, r=alexcrichton
Followup to PR #16477: a run-pass regression test for Issue #15750.
2014-08-15 10:26:18 +00:00
bors
36db3866c0 auto merge of #16424 : pcwalton/rust/where-clauses, r=nikomatsakis
These `where` clauses are accepted everywhere generics are currently
accepted and desugar during type collection to the type parameter bounds
we have today.

A new keyword, `where`, has been added. Therefore, this is a breaking
change. Change uses of `where` to other identifiers.

[breaking-change]

r? @nikomatsakis (or whoever)
2014-08-15 06:26:23 +00:00
Steven Fackler
89a0060997 std::io::util cleanup + fixes
* Fix `LimitReader`'s `Buffer::consume` impl to avoid limit underflow
* Make `MultiWriter` fail fast instead of always running through each
    `Writer`. This may or may not be what we want, but it at least
    doesn't throw any errors encountered in later `Writer`s into oblivion.
* Prevent `IterReader`'s `Reader::read` impl from returning EOF if given
    an empty buffer.

[breaking-change]
2014-08-14 23:14:56 -07:00
Luqman Aden
28882c44ef librustc: Fix trans for functional record update when discarding the result. 2014-08-14 22:45:57 -04:00
bors
bf0a925dcd auto merge of #16486 : kballard/rust/vim_conceal, r=chris
We shouldn't be setting conceallevel in the syntax file. Besides not
being able to undo this if we switch to another syntax later, it also
interferes with embedding rust in other filetypes (such as markdown).

Instead, set it in the ftplugin, where it belongs.
2014-08-15 02:36:14 +00:00
Luqman Aden
7e30ba8fc9 librustc: Don't create scratch for the base expr in function record update. 2014-08-14 22:16:35 -04:00
bors
6b5ec40d45 auto merge of #16435 : vadimcn/rust/windows, r=pcwalton
Using "win32" to mean "Windows" is confusing, especially now, that Rust supports win64 builds.
Let's call spade a spade.
2014-08-15 00:46:19 +00:00
Luqman Aden
715abbdc9c libcore: Get rid of useless mem::forget wrapper. 2014-08-14 19:07:56 -04:00
bors
dbb0cee682 auto merge of #16474 : MatejLach/rust/cargorun_fix, r=steveklabnik
This fixes #16451.

While moving things around, I also removed a bunch of unnecessary whitespace, however I can put it back in if that's undesired. 

Thanks.
2014-08-14 23:01:17 +00:00
Patrick Walton
604af3f6c0 librustc: Implement simple where clauses.
These `where` clauses are accepted everywhere generics are currently
accepted and desugar during type collection to the type parameter bounds
we have today.

A new keyword, `where`, has been added. Therefore, this is a breaking
change. Change uses of `where` to other identifiers.

[breaking-change]
2014-08-14 14:14:26 -07:00
bors
f8e0ede921 auto merge of #16468 : pcwalton/rust/as-renaming-import, r=alexcrichton
The old syntax will be removed after a snapshot.

RFC #47.

Issue #16461.

r? @brson
2014-08-14 21:01:19 +00:00
Patrick Walton
1c16accfc2 libsyntax: Accept use foo as bar; in lieu of use bar as foo;
The old syntax will be removed after a snapshot.

RFC #47.

Issue #16461.
2014-08-14 13:24:50 -07:00
Steve Klabnik
3f9ff2e85c Guide: array subscript notation 2014-08-14 16:06:23 -04:00
Steve Klabnik
baf305dbf2 Guide: iterators 2014-08-14 16:04:56 -04:00
Jack Heizer
614bfbe577 Add export_name to the attribute whitelist and a description in the rust manual 2014-08-14 12:29:07 -07:00
Patrick Walton
9907fa4acc librustc: Stop assuming that implementations and traits only contain
methods.

This paves the way to associated items by introducing an extra level of
abstraction ("impl-or-trait item") between traits/implementations and
methods. This new abstraction is encoded in the metadata and used
throughout the compiler where appropriate.

There are no functional changes; this is purely a refactoring.
2014-08-14 11:40:22 -07:00
bors
404978ea72 auto merge of #16122 : pcwalton/rust/lifetimes-in-unboxed-closures, r=pnkfelix
This patch primarily does two things: (1) it prevents lifetimes from
leaking out of unboxed closures; (2) it allows unboxed closure type
notation, call notation, and construction notation to construct closures
matching any of the three traits.

This breaks code that looked like:

    let mut f;
    {
        let x = &5i;
        f = |&mut:| *x + 10;
    }

Change this code to avoid having a reference escape. For example:

    {
        let x = &5i;
        let mut f; // <-- move here to avoid dangling reference
        f = |&mut:| *x + 10;
    }

I believe this is enough to consider unboxed closures essentially
implemented. Further issues (for example, higher-rank lifetimes) should
be filed as followups.

Closes #14449.

[breaking-change]

r? @pnkfelix
2014-08-14 16:36:19 +00:00
Patrick Walton
8d27232141 librustc: Tie up loose ends in unboxed closures.
This patch primarily does two things: (1) it prevents lifetimes from
leaking out of unboxed closures; (2) it allows unboxed closure type
notation, call notation, and construction notation to construct closures
matching any of the three traits.

This breaks code that looked like:

    let mut f;
    {
        let x = &5i;
        f = |&mut:| *x + 10;
    }

Change this code to avoid having a reference escape. For example:

    {
        let x = &5i;
        let mut f; // <-- move here to avoid dangling reference
        f = |&mut:| *x + 10;
    }

I believe this is enough to consider unboxed closures essentially
implemented. Further issues (for example, higher-rank lifetimes) should
be filed as followups.

Closes #14449.

[breaking-change]
2014-08-14 08:53:25 -07:00
bors
56b86aaf35 auto merge of #16484 : dotdash/rust/empty_struct_wrapper_arg, r=luqmana
Fixes #16441.
2014-08-14 14:51:19 +00:00
bors
e99eeb574e auto merge of #16470 : liigo/rust/rename-private-cmp-macros, r=brson
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-14 13:01:18 +00:00
bors
320c35ee34 auto merge of #16444 : steveklabnik/rust/fix_boxes_in_manual, r=brson
Fixes #16439
2014-08-14 11:16:19 +00:00
Jonas Hietala
0f40cf1f59 Add a test for complex divide by zero. 2014-08-14 13:07:35 +02:00
Felix S. Klock II
43c326ef6b Followup to PR #16477: a run-pass regression test for Issue #15750. 2014-08-14 11:55:47 +02:00
bors
32098bbb0d auto merge of #16440 : bheesham/rust/master, r=brson
* `rust.md`: changes for consistency

  * `guide-ffi.md`: wrapped inline code

NOTE: This is a duplicate of #16375. I completely messed up that fork, so I made a new fork.
2014-08-14 09:31:19 +00:00
Vadim Chugunov
88c27e099f Make it pass the pretty-printer test. 2014-08-14 01:55:51 -07:00
bors
259e806db6 auto merge of #16428 : mdinger/rust/sort_attributes, r=cmr
Targetting at fixing most of #16414.

Sorts these alphabetically:
* [Crate-only attributes](http://doc.rust-lang.org/rust.html#crate-only-attributes)
* [Function-only attributes](http://doc.rust-lang.org/rust.html#function-only-attributes)
* [Miscellaneous attributes](http://doc.rust-lang.org/rust.html#miscellaneous-attributes)
* [Lint check attributes](http://doc.rust-lang.org/rust.html#lint-check-attributes)
* [Built-in Traits](http://doc.rust-lang.org/rust.html#built-in-traits)
* [Types](http://doc.rust-lang.org/rust.html#types)
* [Deriving](http://doc.rust-lang.org/rust.html#deriving)
* [Compiler Features](http://doc.rust-lang.org/rust.html#compiler-features)

Doesn't modify these:
* [Operators](http://doc.rust-lang.org/rust.html#operators): An alternative sorting is unclear.
* [Marker types](http://doc.rust-lang.org/rust.html#marker-types): Could be sorted but uncertain how. See below.
* [Stability](http://doc.rust-lang.org/rust.html#stability): Already sorted by stability

---

[Marker types](http://doc.rust-lang.org/rust.html#marker-types) has an extra newline above `fail_` which may throw off formatting (see #16412) or it may be for some other reason. If the newline is just a typo, I can just remove it and format this alphabetically like so:
```rust
// Sorted alphabetically
a_bread
b_bread
c_bread
fail_
fail_bounds_check
a_type
b_type
c_type
```

Marker types is listed as likely to become out of date so I don't know if this is worth doing anyway.

[EDIT] modified `Marker types` now and tried to update the language items list.
2014-08-14 07:41:20 +00:00
bors
385c39a77b auto merge of #16332 : brson/rust/slicestab, r=aturon
This implements some of the recommendations from https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md.

Explanation in commits.
2014-08-14 05:36:25 +00:00
bors
9d45d63d0d auto merge of #15929 : pcwalton/rust/by-ref-closures, r=alexcrichton
by-reference upvars.

This partially implements RFC 38. A snapshot will be needed to turn this
on, because stage0 cannot yet parse the keyword.

Part of #12831.

r? @alexcrichton
2014-08-14 03:46:22 +00:00
bors
aa98b25c4f auto merge of #16477 : pnkfelix/rust/fsk-quotstx, r=brson
quote_expr macro: embed Ident using special encoding that retains hygiene state.

Fix #15750, #15962
2014-08-14 01:56:26 +00:00
Patrick Walton
a63003fe1a librustc: Parse, but do not fully turn on, the ref keyword for
by-reference upvars.

This partially implements RFC 38. A snapshot will be needed to turn this
on, because stage0 cannot yet parse the keyword.

Part of #12381.
2014-08-13 18:09:14 -07:00
Brian Anderson
fce442e75c Fix test fallout 2014-08-13 17:11:21 -07:00
Kevin Ballard
05e45b9e36 vim: Stop setting conceallevel in the syntax file
We shouldn't be setting conceallevel in the syntax file. Besides not
being able to undo this if we switch to another syntax later, it also
interferes with embedding rust in other filetypes (such as markdown).

Instead, set it in the ftplugin, where it belongs.
2014-08-13 16:52:26 -07:00
bors
28b5e4588f auto merge of #15934 : brson/rust/dur, r=aturon
Currently, the Timer methods take an integer number of ms. This is considered a bug because a) types, b) some timers have ns precision.

This plucks the `Duration` type from [rust-chrono](https://github.com/lifthrasiir/rust-chrono), plops it into `std::time`,  and replaces the arguments to `sleep`, `oneshot`, and `periodic` timers with it. It leaves the old methods intact as `sleep_ms`, `oneshot_ms`, and `periodic_ms`, for convenience.

Closes https://github.com/rust-lang/rust/issues/11189.

cc @lifthrasiir @aturon @kballard @alexcrichton
2014-08-13 23:11:28 +00:00
Brian Anderson
c3b9d5df62 Address some review feedback 2014-08-13 15:27:40 -07:00
Brian Anderson
bc450b17e3 core: Change the argument order on splitn and rsplitn for strs.
This makes it consistent with the same functions for slices,
and allows the search closure to be specified last.

[breaking-change]
2014-08-13 15:27:37 -07:00
Brian Anderson
4e1024f8d3 core: Put stability attributes all over the slice module
Much of this is as discussed[1]. Many things are marked

[1]: https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md
2014-08-13 15:27:34 -07:00
Brian Anderson
075256a070 Fix test fallout 2014-08-13 15:26:48 -07:00
Björn Steinbrink
4df0430da0 Fix handling of ignored arguments in FFI wrappers for rust functions
Fixes #16441.
2014-08-14 00:18:38 +02:00
mdinger
c69f7a9234 Sort Marker types and add missing language items 2014-08-13 18:11:10 -04:00
bors
0f09f51c61 auto merge of #16438 : phi-gamma/rust/doc-fixes, r=brson
Fixes wording in the *runtime*, *testing* and *unsafe* guides.
2014-08-13 21:26:28 +00:00
Matej Lach
bede9ecdfe Introduce the cargo run command earlier (squashed) 2014-08-13 20:26:18 +01:00
bors
86ecfa491f auto merge of #16476 : andreastt/rust/ato/consistency_if_expr_example, r=steveklabnik 2014-08-13 18:36:27 +00:00
Brian Anderson
02e39b05c6 Add a fixme about Duration representation 2014-08-13 11:31:48 -07:00
Brian Anderson
49a40d8ad1 Update docs 2014-08-13 11:31:48 -07:00
Brian Anderson
31281b4bd1 std: Fix build errors 2014-08-13 11:31:48 -07:00
Brian Anderson
500b600362 std: Remove Duration::new/new_opt/to_tuple
These all expose the underlying data representation and are
not the most convenient way of instantiation anyway.
2014-08-13 11:31:48 -07:00
Brian Anderson
c6b02f6558 std: Improve Duration comments 2014-08-13 11:31:48 -07:00
Brian Anderson
ee10f3501c std: Make connect_timeout return Err on zero duration
[breaking-change]
2014-08-13 11:31:48 -07:00
Brian Anderson
a391934ba8 Fix various fallout from timer changes 2014-08-13 11:31:48 -07:00
Brian Anderson
80d32438d6 Fix compiletest to use Duration 2014-08-13 11:31:48 -07:00
Brian Anderson
77cdaf018c std: Refactor time module a bit
Put `Duration` in `time::duration`, where the two constants can
be called just `MAX` and `MIN`. Reexport from `time`.
This provides more room for the time module to expand.
2014-08-13 11:31:48 -07:00
Brian Anderson
4475e6a095 std: connect_timeout requires a positive Duration
This is only breaking if you were previously specifying a duration
of zero for some mysterious reason.

[breaking-change]
2014-08-13 11:31:48 -07:00
Brian Anderson
9fdcddb317 std: Make the TCP/UDP connect_timeout methods take Duration
[breaking-change]
2014-08-13 11:31:48 -07:00
Brian Anderson
63cd4acf53 std: Clarify what timers do with zero and negative durations
Add tests. Also fix a bunch of broken time tests.
2014-08-13 11:31:47 -07:00
Brian Anderson
734834c7d6 std: Restore missing timer examples 2014-08-13 11:31:47 -07:00
Brian Anderson
8a5fe8655a std: Remove the zero constructor from Duration
This is a workaround for having to write `Zero::zero` and will
be solved at the language level someday.
2014-08-13 11:31:47 -07:00
Brian Anderson
1666dabcbc std: Remove ms-taking methods from timers 2014-08-13 11:31:47 -07:00
Brian Anderson
51e9728292 std: Change time::MAX to time::MAX_DURATION, etc. 2014-08-13 11:31:47 -07:00
Brian Anderson
6cb2093f74 std: Update Duration from upstream
From rust-chrono 4f34003e03e259bd5cbda0cb4d35325861307cc6
2014-08-13 11:31:47 -07:00
Brian Anderson
18f75a9197 std: Add comments to the time module 2014-08-13 11:31:47 -07:00
Brian Anderson
dc8b23bc1f std: Add sleep, oneshot and periodic timers, taking Duration 2014-08-13 11:31:47 -07:00
Brian Anderson
657b679b15 std: Rename sleep, periodic, and oneshot timers to sleep_ms, etc.
Rename io::timer::sleep, Timer::sleep, Timer::oneshot,
Timer::periodic, to sleep_ms, oneshot_ms, periodic_ms. These functions
all take an integer and interpret it as milliseconds.

Replacement functions will be added that take Duration.

[breaking-change]
2014-08-13 11:31:47 -07:00
Brian Anderson
5778ed4c92 std: Add a Duration type
Taken from rust-chrono[1]. Needed for timers per #11189.
Experimental.

[1]: https://github.com/lifthrasiir/rust-chrono
2014-08-13 11:31:47 -07:00
Brian Anderson
a4b354ca02 core: Add binary_search and binary_search_elem methods to slices.
These are like the existing bsearch methods but if the search fails,
it returns the next insertion point.

The new `binary_search` returns a `BinarySearchResult` that is either
`Found` or `NotFound`. For convenience, the `found` and `not_found`
methods convert to `Option`, ala `Result`.

Deprecate bsearch and bsearch_elem.
2014-08-13 11:30:15 -07:00
Brian Anderson
76d46af6d4 core: Rename ImmutableEqSlice to ImmutablePartialEqSlice
This is in the prelude and won't break much code.

[breaking-change]
2014-08-13 11:30:15 -07:00
Brian Anderson
12e851208d collections: Deprecate Vec::tailn. Same as slice_from 2014-08-13 11:30:15 -07:00
Brian Anderson
c9abc01a98 core: Rename MutableCloneableSlice::copy_from to clone_from_slice
Deprecate the previous.
2014-08-13 11:30:15 -07:00
Brian Anderson
d4c736b1f0 core: Deprecate ImmutableSlice::tailn and initn
These are equivalent to slice_from and slice_to.
2014-08-13 11:30:15 -07:00
Brian Anderson
033f28d436 core: Rename ImmutableSlice::unsafe_ref to unsafe_get
Deprecate the previous.
2014-08-13 11:30:14 -07:00
Brian Anderson
fbc93082ec std: Rename slice::Vector to Slice
This required some contortions because importing both raw::Slice
and slice::Slice makes rustc crash.

Since `Slice` is in the prelude, this renaming is unlikely to
casue breakage.

[breaking-change]
2014-08-13 11:30:14 -07:00
Brian Anderson
4f5b6927e8 std: Rename various slice traits for consistency
ImmutableVector -> ImmutableSlice
ImmutableEqVector -> ImmutableEqSlice
ImmutableOrdVector -> ImmutableOrdSlice
MutableVector -> MutableSlice
MutableVectorAllocating -> MutableSliceAllocating
MutableCloneableVector -> MutableCloneableSlice
MutableOrdVector -> MutableOrdSlice

These are all in the prelude so most code will not break.

[breaking-change]
2014-08-13 11:30:14 -07:00
Felix S. Klock II
9434920b24 rustc lexer: regression tests for embedded Idents.
I chose to make two of them because I wanted something close to an
"end-to-end" test (*), but at the same time I wanted a test that
would run on Windows (**).

(*) The run-make test serves as the end-to-end: It constructs an input
that is trying to subvert the hack and we are going to check that it
fails in the attempt).

(**) The compile-fail-fulldeps test serves as a more narrow test that
will be tested on all platforms.  It also attempts to subvert the
hack, testing that when you use `new_parser_from_tts`, the resulting
parser does not support reading embedded Idents.
2014-08-13 17:41:35 +02:00
Felix S. Klock II
c3ce245ba6 quote_expr macro: embed Ident using special encoding that preserves hygiene.
This adds support to `quote_expr!` and friends for round-trip hygienic
preservation of Ident.

Here are the pieces of the puzzle:

* adding a method for encoding Ident for re-reading into token tree.

* Support for reading such encoded Idents in the lexer.  Note that one
  must peek ahead for MOD_SEP after scan_embedded_hygienic_ident.

* To ensure that encoded Idents are only read when we are in the midst
  of expanding a `quote_expr` or similar, added a
  `read_embedded_ident` flag on `StringReader`.

* pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
2014-08-13 17:40:15 +02:00
Andreas Tolfsen
0edc55dc21 Guide: Add missing integer type to section on if expressions 2014-08-13 15:58:12 +01:00
bors
d917770792 auto merge of #16381 : pnkfelix/rust/fsk-rust.md-fixes, r=alexcrichton
rust.md: Explicitly point out how special `'static` is.

Drive-by: fix description of `&content` to point out that `&'f type` is (as of today) only for type expressions.
2014-08-13 14:16:27 +00:00
bors
9d554212de auto merge of #16421 : ipetkov/rust/cmd-fd-fix-retry, r=alexcrichton
Retry pull requesting of https://github.com/rust-lang/rust/pull/16407 after accidentally messing up rebasing of branches and making bors think the PR was merged
2014-08-13 05:56:20 +00:00
bors
6291781592 auto merge of #16460 : pcwalton/rust/borrowck-closure-issue, r=nikomatsakis
This fixes borrow checking for closures. Code like this will break:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            let p = &this.x;
            &mut this.x;
        };
        r()
    }

Change this code to not take multiple mutable references to the same value. For
example:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            &mut this.x;
        };
        r()
    }

Closes #16361.

[breaking-change]

r? @nikomatsakis
2014-08-13 04:11:22 +00:00
Liigo Zhuang
0186246afe libcore: rename private cmp macros
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-13 11:41:29 +08:00
bors
ee87234eed auto merge of #16458 : pcwalton/rust/borrowck-for-moves, r=nikomatsakis
`for` loop heads.

This breaks code like:

    let x = Some(box 1i);
    for &a in x.iter() {
    }

Change this code to obey the borrow checking rules. For example:

    let x = Some(box 1i);
    for &ref a in x.iter() {
    }

Closes #16205.

[breaking-change]

r? @nikomatsakis
2014-08-13 02:26:23 +00:00
Ivan Petkov
3fe0ba9afc libnative: process spawning should not close inherited file descriptors
* The caller should be responsible for cleaning up file descriptors
* If a caller safely creates a file descriptor (via
  native::io::file::open) the returned structure (FileDesc) will try to
  clean up the file, failing in the process and writing error messages
  to the screen.
* This should not happen as the caller has no public interface for
  telling the FileDesc structure to NOT free the underlying fd.
* Alternatively, if another file is opened under the same fd held by
  the FileDesc structure returned by native::io::file::open, it will
  close the wrong file upon destruction.
2014-08-12 19:09:18 -07:00
bors
e189122e9a auto merge of #16452 : epdtry/rust/unreachable-item-ice, r=pcwalton
This code produces an ICE:

```rust
#![crate_type = "rlib"]
fn main() {
    if true { return }
    // remaining code is unreachable
    match () {
        () => { static MAGIC: uint = 0; }
    }
}
```
([playpen](http://is.gd/iwOISB))

The error is "encode_symbol: id not found 18", where 18 is the `NodeId` of the declaration of `MAGIC`.  The problem is that `rustc` tries to emit metadata for `MAGIC`, but some of the information is missing because `MAGIC` never gets translated by `trans_item` - the entire body of the `match` gets skipped because the `match` itself is unreachable.

This branch simplifies the handling of inner items by always processing them using the `trans_item` visitor, instead of sometimes using the visitor and sometimes waiting until `trans_stmt` encounters the item.  This fixes the ICE by making the translation of the item no longer depend on the declaration being reachable code.  This branch also reverts #16059 and #16359, since the new change to item translation fixes the same problems as those but is simpler.
2014-08-13 00:41:22 +00:00
Stuart Pernsteiner
0f847ba74d more consistent handling of inner items 2014-08-12 16:14:27 -07:00
Stuart Pernsteiner
428d5ac5b9 Revert "avoid redundant translation of items during monomorphization"
This reverts commit f97f65f7b7.

Conflicts:
	src/librustc/middle/trans/base.rs
	src/librustc/middle/trans/foreign.rs
	src/librustc/middle/trans/monomorphize.rs
2014-08-12 16:14:27 -07:00
Stuart Pernsteiner
d5a94c4a88 Revert "don't translate items when monomorphizing foreign-ABI functions"
This reverts commit 0c158b4fbf.
2014-08-12 16:13:11 -07:00
Patrick Walton
7579185b4c librustc: Use the correct categorized mutable type for the pattern in
`for` loop heads.

This breaks code like:

    let x = Some(box 1i);
        for &a in x.iter() {
    }

Change this code to obey the borrow checking rules. For example:

    let x = Some(box 1i);
        for &ref a in x.iter() {
    }

Closes #16205.

[breaking-change]
2014-08-12 15:02:51 -07:00
bors
51c7e20d53 auto merge of #16433 : aturon/rust/deprecated-in-crate, r=alexcrichton
Previously the stability lint considered cross-crate items only. That's appropriate for unstable and experimental levels, but not for deprecation.

In addition to changing the lint, this PR takes care of the fallout: a number of deprecated items that were being used throughout libstd.

Closes #16409

Due to deny(deprecated), this is a:

[breaking-change]
2014-08-12 22:01:25 +00:00
Patrick Walton
f1799fdfca librustc: Record unique immutable borrows in the restrictions table.
This fixes borrow checking for closures. Code like this will break:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            let p = &this.x;
            &mut this.x;
        };
        r()
    }

Change this code to not take multiple mutable references to the same value. For
example:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            &mut this.x;
        };
        r()
    }

Closes #16361.

[breaking-change]
2014-08-12 14:30:05 -07:00
Aaron Turon
d7484b86fc Allow deprecation in deprecated libraries 2014-08-12 13:35:56 -07:00
Aaron Turon
ffd87daeed Deprecation fallout in libsync 2014-08-12 13:35:56 -07:00
Aaron Turon
f77cabecbb Deprecation fallout in libcollections 2014-08-12 13:35:56 -07:00
Aaron Turon
0b5204f55e Enable deprecation lint on crate-local items
Previously the lint considered cross-crate items only. That's
appropriate for unstable and experimental levels, but not for
deprecation.

Closes #16409

Due to deny(deprecation), this is a:

[breaking-change]
2014-08-12 13:07:12 -07:00
bors
4bb4a43917 auto merge of #16454 : pcwalton/rust/types-in-path-patterns, r=brson
patterns.

This breaks code like:

    fn main() {
        match Some("foo") {
            None::<int> => {}
            Some(_) => {}
        }
    }

Change this code to not contain a type error. For example:

    fn main() {
        match Some("foo") {
            None::<&str> => {}
            Some(_) => {}
        }
    }

Closes #16353.

[breaking-change]

r? @huonw
2014-08-12 20:06:30 +00:00
Steve Klabnik
ee3f07481f Guide: patterns.
Fixes #4417.
2014-08-12 15:33:01 -04:00
Philipp Gesang
061cdec5df
guide-unsafe.md: fix wording
Following a suggestion by Huon Wilson.
2014-08-12 21:30:02 +02:00
bors
e2273d9456 auto merge of #16081 : luqmana/rust/nr, r=pcwalton
Fixes #15763
2014-08-12 18:16:33 +00:00
Patrick Walton
857ba988f1 libsyntax: Don't strip types and lifetimes from single-segment paths in
patterns.

This breaks code like:

    fn main() {
        match Some("foo") {
            None::<int> => {}
            Some(_) => {}
        }
    }

Change this code to not contain a type error. For example:

    fn main() {
        match Some("foo") {
            None::<&str> => {}
            Some(_) => {}
        }
    }

Closes #16353.

[breaking-change]
2014-08-12 10:33:16 -07:00
Steve Klabnik
5eb4e1a659 ~ -> Box in the manual
Fixes #16439
2014-08-12 07:58:36 -04:00
bors
c7d0b5259d auto merge of #16434 : vadimcn/rust/many-crates-but-no-match, r=alexcrichton 2014-08-12 09:31:17 +00:00
bors
c1eaafe8ab auto merge of #16425 : nham/rust/fix_nan_format, r=alexcrichton
Currently, this:

    println!("{}", std::f64::NAN);

prints "-NaN". This commit is an attempt to change that to "NaN" instead.
2014-08-12 07:31:17 +00:00
Vadim Chugunov
1b2dc760af Replace "ignore-win32" in tests with "ignore-windows" 2014-08-12 00:14:00 -07:00
Bheesham Persaud
a43dadb204 Minor changes to rust.md, and guide-ffi.md.
* `rust.md`: whanges for consistency

  * `guide-ffi.md`: wrapped inline code
2014-08-12 03:13:50 -04:00
Vadim Chugunov
3dfd12967a Replace #[cfg(target_os = "win32")] with #[cfg(target_os = "windows")] 2014-08-12 00:13:43 -07:00
Vadim Chugunov
98332b1a06 Replace all references to "Win32" with "Windows".
For historical reasons, "Win32" has been used in Rust codebase to mean "Windows OS in general".
This is confusing, especially now, that Rust supports Win64 builds.

[breaking-change]
2014-08-12 00:10:26 -07:00
Philipp Gesang
2c7ef330fc
guide-unsafe.md: fix noun 2014-08-12 07:39:57 +02:00
Philipp Gesang
c2bf0ed4dd
guide-testing.md: add auxiliary verb 2014-08-12 07:39:56 +02:00
Philipp Gesang
b8f512d220
guide-runtime.md: remove redundant verb 2014-08-12 07:39:53 +02:00
bors
e8204a84c7 auto merge of #16195 : P1start/rust/more-index, r=aturon
Implement `Index` for `RingBuf`, `HashMap`, `TreeMap`, `SmallIntMap`, and `TrieMap`.

If there’s anything that I missed or should be removed, let me know.
2014-08-12 05:11:18 +00:00
Luqman Aden
71e19d5286 librustc: Don't use an alloca per return if the function doesn't have nested returns. 2014-08-11 21:53:54 -07:00
P1start
8f71cb06bc Implement Index for TrieMap 2014-08-12 15:33:05 +12:00
P1start
11b8f9c3f6 Implement Index for SmallIntMap
This also deprecates SmallIntMap::get. Use indexing instead.
2014-08-12 15:33:05 +12:00
P1start
2dd6bc6887 Implement Index for TreeMap 2014-08-12 15:33:05 +12:00
P1start
32f5898bea Implement Index for HashMap
This also deprecates HashMap::get. Use indexing instead.
2014-08-12 15:33:05 +12:00
P1start
fd10d209cd Implement Index for RingBuf
This also deprecates RingBuf::get. Use indexing instead.
2014-08-12 15:32:56 +12:00
bors
49a970f244 auto merge of #16284 : alexcrichton/rust/issue-16272, r=aturon
There was a bug in both libnative and libuv which prevented child processes from
being spawned correctly on windows when one of the arguments was an empty
string. The libuv bug has since been fixed upstream, and the libnative bug was
fixed as part of this commit.

When updating libuv, this also includes a fix for #15149.

Closes #15149
Closes #16272
2014-08-12 03:31:20 +00:00
nham
04233a1675 Change std::fmt::{Float,LowerExp,UpperExp} to not print '-NaN' for f32::NAN and f64::NAN 2014-08-11 22:24:01 -04:00
Luqman Aden
0ad97c042a librustc: Don't use Load/Store for structural values. 2014-08-11 19:20:11 -07:00
Luqman Aden
5aedcb1e91 librustc: Don't allow return_address intrinsic in functions that don't use an out pointer. 2014-08-11 19:20:10 -07:00
Patrick Walton
9dac85f92d librustc: Add an intrinsic to retrieve the return pointer of a function.
This is needed for some GC stuff in Servo.
2014-08-11 19:20:10 -07:00
Luqman Aden
d302813888 Reenable ignored test and add run-pass test. 2014-08-11 19:20:10 -07:00
Luqman Aden
68cbd6c929 librustc: Use separate stack slot for each return. 2014-08-11 19:20:10 -07:00
Vadim Chugunov
06d44aaad3 Fix many-crates-but-no-match test. (Issue #16348) 2014-08-11 18:41:47 -07:00
bors
9dcf89567e auto merge of #16417 : jasonthompson/rust/docs/slice3, r=alexcrichton
- Moved examples for permutations and next into trait definition as
   comments on pull request #16244.
- Fixed (hopefully) issue with erronious commit of changes to src/llvm.
2014-08-12 00:26:13 +00:00
bors
9e191cdf3c auto merge of #16427 : brson/rust/https, r=thestinger 2014-08-11 22:46:16 +00:00
Steve Klabnik
8175cba597 Guide: vectors 2014-08-11 16:21:41 -04:00
Brian Anderson
4e0a992845 Download snapshots using HTTPS
cc #16123
2014-08-11 12:31:24 -07:00
Brian Anderson
21a70b38ba Update docs to use HTTPS for static.rust-lang.org addresses
cc #16123
2014-08-11 12:31:16 -07:00
mdinger
2867d1f24a Sort most attributes alphabetically 2014-08-11 15:29:44 -04:00
bors
6faad3ec3a auto merge of #16416 : nick29581/rust/log, r=pnkfelix
Previously we would accept an empty log level without an equals sign, but not with one. This addresses that minor nit. E.g., `RUST_LOG=rustc::middle::trans=` will work the same as `RUST_LOG=rustc::middle::trans`.
2014-08-11 11:06:08 +00:00
Jason Thompson
371e8cf273 API docs/examples for std::slice
- API doc/example for next() in Permutations
 - API doc/example for permutations() in ImmutableCloneableVector
 - Moved examples for permutations and next into trait definition as
   comments on pull request #16244.
 - Fix erroneus inclusion of src/llvm in older commit.
2014-08-11 06:49:00 -04:00
Nick Cameron
81241dce80 Accept empty log level 2014-08-11 11:13:27 +01:00
bors
5e720f0e54 auto merge of #16196 : huonw/rust/fail-dead-code, r=alexcrichton
The fail macro defines some function/static items internally, which got
a dead_code warning when `fail!()` is used inside a dead function. This
is ugly and unnecessarily reveals implementation details, so the
warnings can be squashed.

Fixes #16192.
2014-08-11 09:01:06 +00:00
Huon Wilson
07aadc2e8b core/std: squash dead_code warnings from fail! invocations.
The fail macro defines some function/static items internally, which got
a dead_code warning when `fail!()` is used inside a dead function. This
is ugly and unnecessarily reveals implementation details, so the
warnings can be squashed.

Fixes #16192.
2014-08-11 18:26:31 +10:00
bors
9c772cd391 auto merge of #16379 : parir/rust/guide-typos, r=kballard
This PR fixes some minor grammar and spelling issues in the guide.
2014-08-11 07:11:07 +00:00
bors
e7a5e8ff3b auto merge of #16399 : superlogical/rust/patch-2, r=steveklabnik 2014-08-11 05:21:10 +00:00
Peer Aramillo Irizar
9151599ec8 Fix some minor issues in the guide. 2014-08-11 07:12:22 +02:00
bors
4d27b4875e auto merge of #15410 : LemmingAvalanche/rust/patch-1, r=alexcrichton
People reading the tutorial may not be familiar with the convention of naming lists, vectors and the like as xs, ys, etc. Without some explanation of the reasoning behind it, it might come off as just throwaway non-descriptive names. Languages like Haskell gets flak from using short, non-descriptive names, while in reality, there are clear conventions and reasons for using certain terse variable names. 

This is just a proposed explanation of this convention, as I've interpreted it - I assumed that the convention came from a language like Haskell, so I tailored it according to that. So beware that I might have misjudged how it is used in the Rust language, or at least how it is used in the Rust tutorial.
2014-08-11 03:36:11 +00:00
bors
c4a63fabe3 auto merge of #16182 : jbcrail/rust/fix-test-comments, r=sfackler 2014-08-10 21:56:11 +00:00
LemmingAvalanche
14e245bd47 Note naming convention of lists (xs, ys, ...)
People reading the tutorial may not be familiar with the convention of naming lists, vectors and the like as xs, ys, etc. Without some explanation of the reasoning behind it, it might come off as just throwaway non-descriptive names. Languages like Haskell gets flak from using short, non-descriptive names, while in reality, there are clear conventions and reasons for using certain terse variable names.

I assumed that the convention came from a language like Haskell, so I
tailored the explanation according to that.
2014-08-10 22:51:22 +02:00
bors
23276f9dfe auto merge of #16400 : chuckries/rust/patch-1, r=huonw
These are already coded as traits.
2014-08-10 15:46:13 +00:00
bors
69c58bcf6f auto merge of #16185 : luqmana/rust/match-drop, r=pcwalton
Fixes #15571.
Fixes #16151.

r? @pcwalton
2014-08-10 13:56:16 +00:00
Huon Wilson
f3d88c320d lint: dead_code ignores items with leading underscores.
This generalises the behaviour with struct fields (which recieve no
dead_code warning if they have a leading _), and other similar lints, to
all items, e.g. `fn _foo() {} fn main() {}` has no warnings.
2014-08-10 22:49:41 +10:00
Chuck Ries
0e47f9481e remove outdated comment
These are already coded as traits.
2014-08-10 04:11:33 -07:00
bors
d4d608fabd auto merge of #16395 : superlogical/rust/patch-1, r=alexcrichton 2014-08-10 08:56:15 +00:00
Jake Scott
954bae9df1 Fix typo convering to converting 2014-08-10 20:26:57 +12:00
bors
be6c7cf882 auto merge of #16387 : Gankro/rust/doc-search, r=cmr
Fixes str/struct ambiguity (by removing the synonym) and pushes raw searches to the history instead of processed ones. 

# [Live Version Here](http://cg.scs.carleton.ca/~abeinges/doc/std/)
2014-08-10 06:31:15 +00:00
Jake Scott
e7db11c90b Fix typo 2014-08-10 14:12:15 +12:00
Joseph Crail
2016742e07 Fix misspelled comments for tests. 2014-08-09 22:08:36 -04:00
bors
351cc4fc99 auto merge of #16359 : epdtry/rust/mono-item-dedup-foreign, r=alexcrichton
Extend the changes from #16059 to the new generic foreign functions introduced by #15831.
2014-08-09 23:26:18 +00:00
bors
4136d5f44d auto merge of #16356 : ruud-v-a/rust/fix-f32-doc, r=steveklabnik
On a side note (but maybe this is not the right place to ask), the name `Float::two_pi` is inconsistent with `f32::consts::PI_2`.
2014-08-09 21:41:19 +00:00
Alexis Beingessner
1d784d4661 rustdoc: use raw search in URL
fixes #16385
fixes #16271
2014-08-09 15:59:49 -04:00
Alexis Beingessner
0f5ce0f0df removing 'str'='struct' search synonym
fixes #16384
2014-08-09 15:59:47 -04:00
bors
e55e27db1e auto merge of #16350 : hirschenberger/rust/issue-15917, r=alexcrichton
Adding test for issue #15917 which was previously fixed with #15709
2014-08-09 19:56:21 +00:00
bors
48ee81682a auto merge of #16346 : vadimcn/rust/win64-cabi, r=brson
This fixes
run-pass/extern-pass-TwoU64s.rs
run-pass/extern-pass-empty.rs
run-pass/extern-return-TwoU64s.rs
2014-08-09 18:11:22 +00:00
bors
beda30e7ae auto merge of #16342 : alexcrichton/rust/issue-16341, r=huonw
Now that rustdoc is spawning a child task, the program won't exit with a default
error code if the main task fails (because it never fails). This commit forces
the main task to wait for a child task in order to correctly propagate failure.

Closes #16341
2014-08-09 16:16:23 +00:00
Luqman Aden
71df8e655c librustc: Encode upvar_borrow_map in metadata. 2014-08-09 07:32:33 -07:00
Luqman Aden
5dca9fb261 librustc: Also use new alloca if matching on an arg or upvar which we reassign in the arm body. 2014-08-09 07:32:33 -07:00
Luqman Aden
d7c0f7d1c0 librustc: Don't use the same alloca for match binding which we reassign to in arm body. 2014-08-09 07:32:33 -07:00
bors
f9a4323c08 auto merge of #16340 : thestinger/rust/pie, r=brson
Rust already builds all code as position independent by default, so the
linker can be told to build a position independent executable if it's
not disabled with `-C relocation-model=dynamic-no-pic`. Position
independent code does have a significant cost on i686 (not on x86_64 or
ARM) but there's no significant cost to linking code that's already
position independent as a position independent executable.

Address space layout randomization makes exploiting vulnerabilities much
more difficult by providing a statistical defence against an attempt to
find or modify existing code / data. Without ASLR, it's trivial to use a
vulnerability to take over control of the process via return-oriented
programming.

Rust code can be used for return-oriented programming whether it is safe
or unsafe, so even a fully safe application needs to be built as a
position independent executable to defend against vulnerabilities in
unsafe blocks or C libraries.

Sample program:

    extern crate libc;

    use std::mem;

    static mut global: u32 = 5;
    static constant: u32 = 5;
    fn foo() {}

    fn main() {
        let local = 5;
        println!("stack: {}, global: {}, constant: {}, fn: {}, lib fn: {}",
                 &local as *const u32,
                 unsafe { &global as *const u32 },
                 &constant as *const u32,
                 unsafe { mem::transmute::<_, *const ()>(foo) },
                 unsafe { mem::transmute::<_, *const ()>(libc::mprotect) });
    }

Before:

    stack: 0x3ff15eb9f94, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x32749547530
    stack: 0x3b5d47d80e4, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x394469a7530
    stack: 0x3fe2c4e5564, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x399734a2530
    stack: 0x3e525e0fb24, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x2f62a810530
    stack: 0x3b50fb3eae4, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x2e590e86530

After:

    stack: 0x38cf12c90a4, global: 0x3e2d46b488, constant: 0x3e2d23cf80, fn: 0x3e2d1c2510, lib fn: 0x2617d3b4530
    stack: 0x3d733faf474, global: 0x7eb1839488, constant: 0x7eb160af80, fn: 0x7eb1590510, lib fn: 0x32d30c1f530
    stack: 0x3bb42212ec4, global: 0x5bbb365488, constant: 0x5bbb136f80, fn: 0x5bbb0bc510, lib fn: 0x3595e6c1530
    stack: 0x39f678c1ab4, global: 0x22c4e3c488, constant: 0x22c4c0df80, fn: 0x22c4b93510, lib fn: 0x3835b727530
    stack: 0x3afb25bd394, global: 0x493eab2488, constant: 0x493e883f80, fn: 0x493e809510, lib fn: 0x3478d6a7530

This may also be necessary on other platforms, but I can only test on
Linux right now. Note that GDB gained support for debugging position
independent executables in version 7.1 (March 2010).
2014-08-09 13:21:20 +00:00
bors
1712ab2300 auto merge of #16253 : luqmana/rust/muv, r=nikomatsakis
Fixes #11958.
2014-08-09 11:36:22 +00:00
Luqman Aden
f765759af2 Add tests. 2014-08-09 03:00:41 -07:00
bors
87134c7d72 auto merge of #16326 : pnkfelix/rust/fsk-add-path-suffix-lookup, r=huonw
Extended `ast_map::Map` with an iterator over all node id's that match a path suffix.

Extended pretty printer to let users choose particular items to pretty print, either by indicating an integer node-id, or by providing a path suffix.

 * Example 1: the suffix `typeck::check::check_struct` matches the item with the path `rustc::middle::typeck::check::check_struct` when compiling the `rustc` crate.

 * Example 2: the suffix `and` matches `core::option::Option::and` and `core::result::Result::and` when compiling the `core` crate.

Refactored `pprust` slightly to support the pretty printer changes.

(See individual commits for more description.)
2014-08-09 09:51:23 +00:00
Felix S. Klock II
97e82cc2df rust.md: Explicitly point out how special 'static is.
Drive-by: fix description of `&content` to point out that `&'f type`
is (as of today) only for type expressions.
2014-08-09 11:15:04 +02:00
Felix S. Klock II
db0e71f10a pretty printer: Added some run-make tests of path-suffix lookup functionality. 2014-08-09 10:19:06 +02:00
Felix S. Klock II
575ea18d46 pretty-printer: let users choose particular items to pretty print.
With this change:

  * `--pretty variant=<node-id>` will print the item associated with
    `<node-id>` (where `<node-id>` is an integer for some node-id in
    the AST, and `variant` means one of {`normal`,`expanded`,...}).

  * `--pretty variant=<path-suffix>` will print all of the items that
    match the `<path-suffix>` (where `<path-suffix>` is a suffix of a
    path, and `variant` again means one of {`normal`,`expanded`,...}).

    Example 1: the suffix `typeck::check::check_struct` matches the
    item with the path `rustc::middle::typeck::check::check_struct`
    when compiling the `rustc` crate.

    Example 2: the suffix `and` matches `core::option::Option::and`
    and `core::result::Result::and` when compiling the `core` crate.

Both of the `--pretty variant=...` modes will include the full path to
the item in a comment that follows the item.

Note that when multiple paths match, then either:

  1. all matching items are printed, in series; this is what happens in
     the usual pretty-print variants, or

  2. the compiler signals an error; this is what happens in flowgraph
     printing.

----

Some drive-by improvements:

Heavily refactored the pretty-printing glue in driver.rs, introducing
a couple local traits to avoid cut-and-pasting very code segments that
differed only in how they accessed the `Session` or the
`ast_map::Map`. (Note the previous code had three similar calls to
`print_crate` which have all been unified in this revision; the
addition of printing individual node-ids exacerbated the situation
beyond tolerance.) We may want to consider promoting some of these
traits, e.g. `SessionCarrier`, for use more generally elsewhere in the
compiler; right now I have to double check how to access the `Session`
depending on what context I am hacking in.

Refactored `PpMode` to make the data directly reflect the fundamental
difference in the categories (in terms of printing source-code with
various annotations, versus printing a control-flow graph).

(also, addressed review feedback.)
2014-08-09 10:18:02 +02:00
Felix S. Klock II
8a80e0fdab Helper method for pprust::State for printing instances of ast_map::Node. 2014-08-09 10:17:40 +02:00
Felix S. Klock II
a9b1a3b40f refactored pprust::State constructor methods out from pprust::print_crate.
(Groundwork for pretty-printing only selected items in an input crate.)
2014-08-09 10:17:40 +02:00
Felix S. Klock II
4c2ff0ab17 ast_map: Added iterator over all node id's that match a path suffix.
This is useful e.g. for tools need a node-id, such as the flowgraph
pretty printer, since it can avoids the need to first pretty-print the
whole expanded,identified input in order to find out what the node-id
actually is.

It currently only supports path suffixes thst are made up of module
names (e.g. you cannot use the type instantiation form `a::<int>::b`
or `option::Option::unwrap_or` as a path suffix for this tool, though
the tool will produce paths that have non-modulues in the portion of
the path that is not included in the suffix).

(addressed review feedback too)
2014-08-09 10:17:31 +02:00
Luqman Aden
ead3edb7b9 librustc: Update unused mut lint to properly track moved upvars. 2014-08-08 23:43:38 -07:00
Luqman Aden
6559323a51 librustc: Allow mutation of moved upvars. 2014-08-08 23:43:38 -07:00
bors
a23d6795a5 auto merge of #16323 : c-nixon/rust/master, r=alexcrichton
This allows rustc to be built with msys2's mingw64

Fixes #16347.
2014-08-09 05:51:19 +00:00
bors
413328b0f2 auto merge of #15964 : huonw/rust/gensym-test, r=alexcrichton
This requires avoiding `quote_...!` for constructing the parts of the
__test module, since that stringifies and reinterns the idents, losing
the special gensym'd nature of them. (#15962.)
2014-08-09 03:06:21 +00:00
Huon Wilson
edc9191921 testsuite: implement #[reexport_test_harness_name] to get access to the
default entrypoint of the --test binary.

This allows one to, e.g., run tests under libgreen by starting it
manually, passing in the test entrypoint.
2014-08-09 13:00:58 +10:00
Huon Wilson
c3284733e3 move a test into a run make, to check external affect rather than
implementation details.

(Mainly to avoid accessing the secret internal test module symbol name.)
2014-08-09 13:00:58 +10:00
bors
39bafb09fd auto merge of #16314 : Ryman/rust/ringbuf_non_pow2, r=huonw
See test for details.
2014-08-09 01:21:23 +00:00
nham
9315d841c7 Remove the dist function; it is more efficient to compare squared distances 2014-08-08 21:02:51 -04:00
bors
a1429bca5a auto merge of #16277 : Gankro/rust/responsive-docs, r=cmr
* move some sidebar contents to a title bar when small
* inline description toggle when small
* make out-of-band and in-band content share space, rather than float and clash
* compress wording of out-of-band content to avoid line-wrap as much as possible

## [Live Version Here](http://cg.scs.carleton.ca/~abeinges/doc/index.html)

Pages Of Interest:
* [Vec](http://cg.scs.carleton.ca/~abeinges/doc/std/vec/struct.Vec.html) (small path)
* [TreeSet](http://cg.scs.carleton.ca/~abeinges/doc/collections/treemap/struct.TreeSet.html) (long path)
* [std](http://cg.scs.carleton.ca/~abeinges/doc/std/index.html) (for stability dash)

TBD in a future PR is to convert links in the sidebar into a series of nest ul/li's, so that they can easily be moved to a drop-down in the new title bar. I think this is out of scope for this PR, but am willing to implement it now if desired.
2014-08-08 21:36:11 +00:00
Tobias Bucher
cd6eb12270 Add division by zero case to the CheckedDiv comment 2014-08-08 22:45:50 +02:00
bors
57630eb809 auto merge of #16336 : retep998/rust/master, r=brson
Several of the tests in `make check-fast` were failing so this fixes those tests.
2014-08-08 19:51:11 +00:00
nham
3bd158c665 Add example of estimating pi using Monte Carlo simulation to std::rand 2014-08-08 15:37:06 -04:00
Stuart Pernsteiner
0c158b4fbf don't translate items when monomorphizing foreign-ABI functions 2014-08-08 11:26:21 -07:00
bors
98f1b0fb68 auto merge of #16333 : steveklabnik/rust/guide_strings, r=brson
I _think_ this is the right place to introduce strings. It's a bit hard to talk about without understanding pointers and ownership, but you need to have some idea of what's going on...
2014-08-08 18:06:11 +00:00
Ruud van Asseldonk
c56fa5f266 libcore: Fix documentation comment for f32. 2014-08-08 18:30:23 +02:00
bors
ca89cfb0e3 auto merge of #16255 : steveklabnik/rust/guide_methods, r=nikomatsakis
Shifting some things around here, as I think this is a better order.
2014-08-08 16:21:10 +00:00
Steve Klabnik
50ffe0ccab Guide: method syntax 2014-08-08 10:39:48 -04:00
bors
86decf638e auto merge of #16327 : mdinger/rust/typo, r=steveklabnik
Fix typo. It's possible it's `These modules` but I think it's supposed to be singular because it's not refering to nested modules.
2014-08-08 14:36:10 +00:00
bors
67a05bd793 auto merge of #16349 : nikomatsakis/rust/snapshot-20140808, r=nikomatsakis 2014-08-08 12:51:13 +00:00
Falco Hirschenberger
6b9a202899 Adding test for issue #15917 which was previously fixed with #15709 2014-08-08 14:18:10 +02:00
Niko Matsakis
4fd797e757 Register new snapshot 12e0f72 2014-08-08 07:55:00 -04:00
bors
3b1f983584 auto merge of #16325 : froydnj/rust/vec-grammar-fix, r=alexcrichton
Just a small typo noticed while reading through documentation.
2014-08-08 11:06:12 +00:00
Chris Nixon
c377f9e3d4 Move system header includes above valgrind.h include
This allows rustc to be build under msys2's mingw64 gcc
2014-08-08 10:42:41 +01:00
bors
c5b8d89b27 auto merge of #16309 : steveklabnik/rust/guide_tasks, r=brson
I wasn't 100% sure of what level of detail I wanted to go into things here. For example, 1:1 vs M:N tasks seems like a better distinction to leave to the Guide.
2014-08-08 07:26:15 +00:00
Vadim Chugunov
d1e03b3bb7 Implement Win64 system ABI. 2014-08-07 23:11:55 -07:00
Eduardo Bautista
b1428279f1 Single curly braces instead of double are being used 2014-08-08 00:52:09 -05:00
Eduardo Bautista
59f23aec07 Update error message on compile 2014-08-08 00:47:47 -05:00
bors
0ba2d04224 auto merge of #16279 : nham/rust/fix_slice_docs, r=alexcrichton
This does a few things:

 - remove references to ~[] and the OwnedVector trait, which are both
   obsolete
 - correct the docs to say that this is the slice module, not the vec
   module
 - add a sentence pointing out that vectors are distinct from Vec
 - remove documentation on Vec.

closes #15459
2014-08-08 05:41:15 +00:00
bors
aae7901a78 auto merge of #16285 : alexcrichton/rust/rename-share, r=huonw
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use`
statement, but the `NoShare` struct is no longer part of `std::kinds::marker`
due to #12660 (the build cannot bootstrap otherwise).

All code referencing the `Share` trait should now reference the `Sync` trait,
and all code referencing the `NoShare` type should now reference the `NoSync`
type. The functionality and meaning of this trait have not changed, only the
naming.

Closes #16281
[breaking-change]
2014-08-08 03:51:15 +00:00
nham
cb0aa8ac71 Cleanup collections::slice documentation.
This does a few things:

 - remove references to ~[] and the OwnedVector trait, which are both
   obsolete
 - correct the docs to say that this is the slice module, not the vec
   module
 - add a sentence pointing out that vectors are distinct from Vec
 - remove documentation on Vec.

closes #15459
2014-08-07 23:45:39 -04:00
Alex Crichton
d9038fc3b3 rustdoc: Set a nonzero exit status on failure
Now that rustdoc is spawning a child task, the program won't exit with a default
error code if the main task fails (because it never fails). This commit forces
the main task to wait for a child task in order to correctly propagate failure.

Closes #16341
2014-08-07 20:19:18 -07:00
Daniel Micay
3cbff72da2 enable PIE by default on Linux for full ASLR
Rust already builds all code as position independent by default, so the
linker can be told to build a position independent executable if it's
not disabled with `-C relocation-model=dynamic-no-pic`. Position
independent code does have a significant cost on i686 (not on x86_64 or
ARM) but there's no significant cost to linking code that's already
position independent as a position independent executable.

Address space layout randomization makes exploiting vulnerabilities much
more difficult by providing a statistical defence against an attempt to
find or modify existing code / data. Without ASLR, it's trivial to use a
vulnerability to take over control of the process via return-oriented
programming.

Rust code can be used for return-oriented programming whether it is safe
or unsafe, so even a fully safe application needs to be built as a
position independent executable to defend against vulnerabilities in
unsafe blocks or C libraries.

Sample program:

    extern crate libc;

    use std::mem;

    static mut global: u32 = 5;
    static constant: u32 = 5;
    fn foo() {}

    fn main() {
        let local = 5;
        println!("stack: {}, global: {}, constant: {}, fn: {}, lib fn: {}",
                 &local as *const u32,
                 unsafe { &global as *const u32 },
                 &constant as *const u32,
                 unsafe { mem::transmute::<_, *const ()>(foo) },
                 unsafe { mem::transmute::<_, *const ()>(libc::mprotect) });
    }

Before:

    stack: 0x3ff15eb9f94, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x32749547530
    stack: 0x3b5d47d80e4, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x394469a7530
    stack: 0x3fe2c4e5564, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x399734a2530
    stack: 0x3e525e0fb24, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x2f62a810530
    stack: 0x3b50fb3eae4, global: 0x6ab488, constant: 0x47db40, fn: 0x4030e0, lib fn: 0x2e590e86530

After:

    stack: 0x38cf12c90a4, global: 0x3e2d46b488, constant: 0x3e2d23cf80, fn: 0x3e2d1c2510, lib fn: 0x2617d3b4530
    stack: 0x3d733faf474, global: 0x7eb1839488, constant: 0x7eb160af80, fn: 0x7eb1590510, lib fn: 0x32d30c1f530
    stack: 0x3bb42212ec4, global: 0x5bbb365488, constant: 0x5bbb136f80, fn: 0x5bbb0bc510, lib fn: 0x3595e6c1530
    stack: 0x39f678c1ab4, global: 0x22c4e3c488, constant: 0x22c4c0df80, fn: 0x22c4b93510, lib fn: 0x3835b727530
    stack: 0x3afb25bd394, global: 0x493eab2488, constant: 0x493e883f80, fn: 0x493e809510, lib fn: 0x3478d6a7530

This may also be necessary on other platforms, but I can only test on
Linux right now. Note that GDB gained support for debugging position
independent executables in version 7.1 (March 2010).
2014-08-07 22:57:00 -04:00
bors
87d2bf400c auto merge of #16273 : steveklabnik/rust/guide_generics, r=brson 2014-08-08 02:01:16 +00:00
bors
8888d7c8e9 auto merge of #16206 : steveklabnik/rust/guide_lambdas, r=brson 2014-08-07 23:36:17 +00:00
Steve Klabnik
dac73ad3c1 Guide: Traits 2014-08-07 18:12:36 -04:00
bors
12e0f72f51 auto merge of #16334 : nikomatsakis/rust/mission-snapshot, r=achrichto 2014-08-07 21:51:19 +00:00
Niko Matsakis
1fcc4f9c5f Remove spawn-stack-too-big.rs, which is too flaky. 2014-08-07 16:53:58 -04:00
Peter Atashian
24ebbb4420 windows: Fix INVALID_HANDLE_VALUE
Made INVALID_HANDLE_VALUE actually a HANDLE.
Removed all useless casts during INVALID_HANDLE_VALUE comparisons.

Signed-off-by: Peter Atashian <retep998@gmail.com>
2014-08-07 16:40:12 -04:00
Steve Klabnik
e0fa999891 Guide: strings 2014-08-07 16:37:39 -04:00
Steve Klabnik
b1435ed593 Guide: tasks 2014-08-07 15:21:57 -04:00
mdinger
0582a2d6e7 Fix typo 2014-08-07 15:14:16 -04:00
bors
50834e7de4 auto merge of #16317 : adrienbrault/rust/patch-1, r=kballard 2014-08-07 18:56:11 +00:00
Steve Klabnik
aa8602e20a Guide: closures 2014-08-07 14:11:14 -04:00
bors
4879ca7924 auto merge of #15831 : rpjohnst/rust/generic-foreign-fns, r=alexcrichton
This allows for things like this:

    extern "C" fn callback<T>(t: T) { /* ... */ }
    extern "C" {
        fn take_callback(c: extern fn(i32));
    }

and later:

    take_callback(callback::<i32>);

Closes #12502.
2014-08-07 15:56:43 +00:00
Alex Crichton
1f760d5d1a Rename Share to Sync
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use`
statement, but the `NoShare` struct is no longer part of `std::kinds::marker`
due to #12660 (the build cannot bootstrap otherwise).

All code referencing the `Share` trait should now reference the `Sync` trait,
and all code referencing the `NoShare` type should now reference the `NoSync`
type. The functionality and meaning of this trait have not changed, only the
naming.

Closes #16281
[breaking-change]
2014-08-07 08:54:38 -07:00
Nathan Froyd
0d974eecd3 fix grammar in Vec.retain's doc comment 2014-08-07 11:27:06 -04:00
Huon Wilson
3826026f98 rustc: gensym the module names for --test to avoid introducing user-accessible names.
This requires avoiding `quote_...!` for constructing the parts of the
__test module, since that stringifies and reinterns the idents, losing
the special gensym'd nature of them. (#15962.)
2014-08-07 21:54:13 +10:00
Niko Matsakis
fcab98038c Temporary bootstrapping hack: introduce syntax for r egion bounds like 'b:'a,
meaning `'b outlives 'a`. Syntax currently does nothing but is needed for full
fix to #5763. To use this syntax, the issue_5763_bootstrap feature guard is
required.
2014-08-07 07:23:59 -04:00
Peter Atashian
feb219d23f windows: Fix several tests on 64-bit.
Signed-off-by: Peter Atashian <retep998@gmail.com>
2014-08-07 04:05:00 -04:00
bors
1a53c00117 auto merge of #16220 : tshepang/rust/temp, r=steveklabnik 2014-08-07 07:16:04 +00:00
Adrien Brault
c186b4be6b Fix typo in the tutorial 2014-08-06 23:09:08 -07:00
bors
e9c5c4c9bd auto merge of #16316 : forticulous/rust/char-Fix, r=alexcrichton
Signature for `from_digit` in `Char` wasn't using `Self` so there was no way to use this method
2014-08-07 04:21:04 +00:00
bors
7be8f0af03 auto merge of #16306 : pnkfelix/rust/fsk-ast-refactor-PatWild, r=alexcrichton
AST refactoring: merge PatWild and PatWildMulti into one variant with a flag
2014-08-07 02:26:07 +00:00
fort
ef03363059 Char::from_digit signature fix 2014-08-06 18:46:54 -07:00
Kevin Butler
64896d6103 libcollections: Fix RingBuf growth for non-power-of-two capacities 2014-08-07 02:11:13 +01:00
bors
8fe73f1166 auto merge of #16291 : nham/rust/byte_literals, r=alexcrichton
This replaces many instances chars being casted to u8 with byte literals.
2014-08-06 23:41:05 +00:00
bors
b9308d1ff0 auto merge of #16225 : pczarn/rust/iter-refactoring, r=kballard
Simplifying the code of methods: `nth`, `fold`, `rposition`, and iterators: `Filter`, `FilterMap`, `SkipWhile`.

```
before
test iter::bench_multiple_take      ... bench:        15 ns/iter (+/- 0)
test iter::bench_rposition          ... bench:       349 ns/iter (+/- 94)
test iter::bench_skip_while         ... bench:       158 ns/iter (+/- 6)

after
test iter::bench_multiple_take      ... bench:        15 ns/iter (+/- 0)
test iter::bench_rposition          ... bench:       314 ns/iter (+/- 2)
test iter::bench_skip_while         ... bench:       107 ns/iter (+/- 0)
```
@koalazen has the code for `Skip`.

Once #16011 is fixed, `min_max` could use a for loop.
2014-08-06 21:56:07 +00:00
bors
51e19e7501 auto merge of #16308 : alexcrichton/rust/rollup, r=alexcrichton 2014-08-06 19:26:19 +00:00
Alex Crichton
ffa258846a Merge commit '3b41f3256228ffb01225eab671ef301aa18337d7' into rollup 2014-08-06 11:25:47 -07:00
Alex Crichton
d29123b35d Merge commit 'd92eaf0273af8c09112f951b2f483505b2f3e8c9' into rollup 2014-08-06 11:25:45 -07:00
Alex Crichton
1652d4ab08 Merge commit 'c6c3f47f7c72ddf45ba1bf6bae6bec3699d7212e' into rollup 2014-08-06 11:25:42 -07:00
Alex Crichton
0f9ee795f9 Merge commit 'cb8bd83888cddc37c912be648ce5a814b08ceb25' into rollup 2014-08-06 11:25:36 -07:00
Alex Crichton
10c8105842 Merge commit '74ae05ad90d1e809663702f374bba6e62671692c' into rollup 2014-08-06 11:25:22 -07:00
Alex Crichton
720746a139 Merge commit '881bfb1a180a1b545daa9da1539ec4c8ebda7ed1' into rollup 2014-08-06 11:25:14 -07:00
Alexis Beingessner
dd437ee6ed make rustdoc more responsive
* move some sidebar contents to a title bar when small
* inline description toggle when small
* make out-of-band and in-band content share space, rather than float and clash
* compress wording of out-of-band content to avoid line-wrap as much as possible
2014-08-06 14:06:52 -04:00
bors
dd20f09611 auto merge of #15985 : jfager/rust/r6334, r=pnkfelix
Closes #6334
2014-08-06 17:31:19 +00:00
nham
96d1712511 Use byte literals in libgetopts 2014-08-06 13:06:37 -04:00
nham
efdb77b8d4 Remove cast to char in libserialize::hex 2014-08-06 12:23:21 -04:00
bors
e5df5f5606 auto merge of #15865 : jamesrhurst/rust/ctags-regex, r=alexcrichton
Previously the implementation detection regex would detect
`impl fmt::Show for MyStruct` as `fmt`. Now it will be detected as
`fmt::Show for MyStruct`. Implementations such as `impl MyStruct` will
still be detected as `MyStruct`.
2014-08-06 15:51:19 +00:00
Felix S. Klock II
d3202354f5 AST refactoring: merge PatWild and PatWildMulti into one variant with a flag. 2014-08-06 17:04:44 +02:00
bors
8fcfd02d85 auto merge of #16276 : nham/rust/fix_marker_docs, r=steveklabnik 2014-08-06 13:21:27 +00:00
bors
b09a02b415 auto merge of #16263 : brson/rust/morestack, r=alexcrichton 2014-08-06 10:26:30 +00:00
Piotr Czarnecki
a55149b84e core: Refactor iterators
Simplifying the code of methods: nth, fold, rposition
and iterators: Filter, FilterMap, SkipWhile
Adding basic benchmarks
2014-08-06 11:20:37 +01:00
Simon Sapin
3b41f32562 Rustdoc: Add padding on <code>
… to separate text from the edge of the newly added background.
2014-08-06 11:07:35 +01:00
Simon Sapin
7f388068b9 Rustdoc: Highlight <code> elements (from Markdown backticks) 2014-08-06 11:03:18 +01:00
Simon Sapin
d92eaf0273 Gtksourceview language spec: add the \0 escape sequence. 2014-08-06 10:18:22 +01:00
bors
84782c4e26 auto merge of #16258 : aturon/rust/stabilize-atomics, r=alexcrichton
This commit stabilizes the `std::sync::atomics` module, renaming it to
`std::sync::atomic` to match library precedent elsewhere, and tightening
up behavior around incorrect memory ordering annotations.

The vast majority of the module is now `stable`. However, the
`AtomicOption` type has been deprecated, since it is essentially unused
and is not truly a primitive atomic type. It will eventually be replaced
by a higher-level abstraction like MVars.

Due to deprecations, this is a:

[breaking-change]
2014-08-06 08:31:28 +00:00