Commit Graph

31787 Commits

Author SHA1 Message Date
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
Brian Anderson
e59fb9eb62 mk: Don't emit landing pads in stage 0.
Reduces time to build stage0 from 11:30 to 9:40 on my machine.
2014-08-08 16:54:26 -07:00
Alexis Beingessner
e8006f3c74 Make small doc contributions less onerous/intimidating 2014-08-08 19:36:32 -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
1272a83bfa auto merge of #16321 : gioele/rust/use-local-rust, r=brson
This commit makes the configuration system autodetect a `rustc` that
is already installed and use that instead of downloading a snapshot.
2014-08-08 09:11:13 +00: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