Commit Graph

31419 Commits

Author SHA1 Message Date
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
bors
15833d91ac auto merge of #16429 : steveklabnik/rust/guide_vectors, r=cmr
Since https://github.com/rust-lang/rust/pull/16380 didn't get pulled in yet, I added it in here too.

This covers the very, very, very basics of vectors. I wanted to have a section that mentioned them, but I'm
unsure what else I should cover. So I just did the absolute simplest things. Feedback very welcome.
2014-08-11 20:31:20 +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
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
bors
4ed40ffe8e auto merge of #16373 : brson/rust/nopads, r=pcwalton
Reduces time to build stage0 from 11:30 to 9:40 on my machine.

There's a tradeoff here since doing this will make the stage1 compile-fail tests fail.

r? @pcwalton
2014-08-10 02:56:16 +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
0cdeb15c31 auto merge of #16371 : Gankro/rust/friendly-contrib, r=brson
Had someone experience deep existential dread over building all of Rust on Windows just to do some minor fixes to the docs. This seems entirely unnecessary between reviewers + Bors for most purely english changes.
2014-08-10 01:11:16 +00: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
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