Commit Graph

29911 Commits

Author SHA1 Message Date
Alex Crichton
f20b1293fc Register new snapshots 2014-06-14 10:28:09 -07:00
bors
d64f18c490 auto merge of #14884 : huonw/rust/getoptsfail, r=alexcrichton 2014-06-14 10:36:46 +00:00
bors
dbd29ea96e auto merge of #14874 : pcwalton/rust/enum-to-float-casts-part-deux, r=alexcrichton
Closes #14794.

If you're casting from an enum to a float, cast through an integer
first.

[breaking-change]

r? @alexcrichton
2014-06-14 08:46:48 +00:00
bors
18c451fc49 auto merge of #14739 : zwarich/rust/mut-unique-path, r=nikomatsakis
Implement the stronger guarantees for mutable borrows proposed in #12624.
2014-06-14 06:36:49 +00:00
bors
2c6caad1ba auto merge of #14878 : vtsatskin/rust/rustdoc-sidebar-click-targets, r=alexcrichton
There was feedback gathered by @bjz which request for larger click targets in the rustdoc sidebar. Here's my attempt at that.

My only concern with this patch is the removal of `<br>` between sidebar links. This may break formatting for text-only viewers of this documentation. If there is a large enough demographic of people that will be affected, perhaps we can try switching the structure of each sidebar block sidebar to an `<ol>` with each item as a `<li>`. 

* Change links to display:block for click larger targets
* Remove linebreaks due to extra space
* Adjust margins so that element spacing stays the same
* Sidebar item hover background colour chosen from `<pre>` styling
2014-06-14 04:46:46 +00:00
Cameron Zwarich
6fc788916c Reorganize code in check_loans
Move analyze_restrictions_on_use and check_if_path_is_moved so that all
of the code related to assignments is in a contiguous block at the end
of the file.
2014-06-13 20:48:10 -07:00
Cameron Zwarich
5878b5edb0 Add new tests for uses of mutably borrowed paths 2014-06-13 20:48:10 -07:00
Cameron Zwarich
d7de4e9aff Enforce stronger guarantees for mutable borrows
Implement the stronger guarantees for mutable borrows from #12624. This
removes the ability to read from a mutably borrowed path for the
duration of the borrow, and enforces a unique access path for any
mutable borrow, for both reads and writes.

This makes mutable borrows work better with concurrent accesses from
multiple threads, and it opens the door for allowing moves out of
mutably borrowed values, as long as a new value is written before the
mutable borrow ends. This also aligns Rust more closely with academic
languages based on substructural types and separation logic.

The most common situation triggering an error after this change is a
call to a function mutably borrowing self with self.field as one of the
arguments. The workaround is to bind self.field to a temporary, but the
need for these temporaries will hopefully go away after #6268 is fixed.

Another situation that triggers an error is using the head expression of
a match in an arm that binds a variable with a mutable reference. The
use of the head expression needs to be replaced with an expression that
reconstructs it from match-bound variables.

This fixes #12624.

[breaking-change]
2014-06-13 20:48:09 -07:00
Cameron Zwarich
159e27aebb Fix all violations of stronger guarantees for mutable borrows
Fix all violations in the Rust source tree of the stronger guarantee
of a unique access path for mutable borrows as described in #12624.
2014-06-13 20:48:09 -07:00
Cameron Zwarich
036833ece9 Rename analyze_move_out_from to analyze_restrictions_on_use
Also rename MoveError to UseError and MoveOk / MoveWhileBorrowed to
UseOk / UseWhileBorrowed.
2014-06-13 20:48:09 -07:00
Cameron Zwarich
24b1b79cf1 Make analyze_move_out_from take a BorrowKind
Currently analyze_move_out_from ignores the BorrowKind of loans, but the
same logic is useful when restricted to loans of specific borrow kinds.
2014-06-13 20:48:09 -07:00
Cameron Zwarich
45a1b97764 Make analyze_move_out_from more field-sensitive
Currently analyze_move_out_from checks all restrictions on all base
paths of the move path, but it only needs to check restrictions from
loans of the base paths, and can disregard restrictions from loans of
extensions of those base paths.
2014-06-13 20:48:09 -07:00
Cameron Zwarich
8c0e1ce6c9 Make check_for_move_of_borrowed_path take an &LoanPath rather than an &Rc<LoanPath>
It doesn't actually need the Rc, and it reduces the net number of
pointer manipulations.
2014-06-13 20:48:09 -07:00
Cameron Zwarich
d2d8fa2a09 Make analyze_move_out_from use a loop rather than recursion
It will be simpler to make some of the changes that I need to make to
analyze_move_out if it uses a loop rather than recursion.
2014-06-13 20:48:09 -07:00
Huon Wilson
09eb95f241 getopts: derive Eq for types. 2014-06-14 11:20:47 +10:00
bors
1cde9d8cbb auto merge of #14866 : bjz/rust/bitwise, r=alexcrichton 2014-06-14 01:11:44 +00:00
Huon Wilson
0642cbbde0 getopts: format failure messages with Show.
This obsoletes the old `to_err_msg` method. Replace

    println!("Error: {}", failure.to_err_msg())

    let string = failure.to_err_msg();

with

    println!("Error: {}", failure)

    let string = failure.to_str();

[breaking-change]
2014-06-14 11:11:09 +10:00
Patrick Walton
1a852a6df7 librustc: Remove useless code to handle let _ = ...
This code didn't do anything, but was a vestige of the old semantics for
`let _ = ...`.

Closes #10488. (As near as I can tell anyhow.)
2014-06-13 17:58:37 -07:00
bors
3851d68a27 auto merge of #14750 : bachm/rust/master, r=alexcrichton
This adds the missing `get_mut` method to the `MutableVector` trait, and implements it for `&'a mut [T]`.
2014-06-13 22:46:35 +00:00
Valentin Tsatskin
0188bebbb7 rustdoc: Larger click areas for sidebar items
* Change links to display:block for click larger targets
* Remove linebreaks due to extra space
* Adjust margins so that element spacing stays the same
* Sidebar item hover background colour chosen from <pre> styling
2014-06-13 15:15:37 -07:00
bors
63dcc9a4df auto merge of #14867 : alexcrichton/rust/rollup, r=alexcrichton 2014-06-13 20:57:30 +00:00
Alex Crichton
b7af25060a Rolling up PRs in the queue
Closes #14797 (librustc: Fix the issue with labels shadowing variable names by making)
Closes #14823 (Improve error messages for io::fs)
Closes #14827 (libsyntax: Allow `+` to separate trait bounds from objects.)
Closes #14834 (configure: Don't sync unused submodules)
Closes #14838 (Remove typo on collections::treemap::UnionItems)
Closes #14839 (Fix the unused struct field lint for struct variants)
Closes #14840 (Clarify `Any` docs)
Closes #14846 (rustc: [T, ..N] and [T, ..N+1] are not the same)
Closes #14847 (Audit usage of NativeMutex)
Closes #14850 (remove unnecessary PaX detection)
Closes #14856 (librustc: Take in account mutability when casting array to raw ptr.)
Closes #14859 (librustc: Forbid `transmute` from being called on types whose size is)
Closes #14860 (Fix `quote_pat!` & parse outer attributes in `quote_item!`)
2014-06-13 13:53:55 -07:00
Huon Wilson
f907d9772c syntax: parse outer attributes in quote_item! calls.
Fixes #14857.
2014-06-13 13:53:55 -07:00
Huon Wilson
9d5ec04d18 syntax: fix quote_pat! & unignore a quotation test. 2014-06-13 13:53:55 -07:00
Patrick Walton
c9f3f47702 librustc: Forbid transmute from being called on types whose size is
only known post-monomorphization, and report `transmute` errors before
the code is generated for that `transmute`.

This can break code that looked like:

    unsafe fn f<T>(x: T) {
        let y: int = transmute(x);
    }

Change such code to take a type parameter that has the same size as the
type being transmuted to.

Closes #12898.

[breaking-change]
2014-06-13 13:53:55 -07:00
Luqman Aden
8c4a10a159 librustc: Take in account mutability when casting array to raw ptr. 2014-06-13 13:53:35 -07:00
Daniel Micay
d884cc83b0 remove unnecessary PaX detection
Rust no longer has support for JIT compilation, so it doesn't currently
require a PaX MPROTECT exception. The extended attributes are preferred
over modifying the binaries so it's not actually going to work on most
systems like this anyway.

If JIT compilation ends up being supported again, it should handle this
by *always* applying the exception via an extended attribute without
performing auto-detection of PaX on the host. The `paxctl` tool is only
necessary with the older method involving modifying the ELF binary.
2014-06-13 13:53:35 -07:00
Alex Crichton
ac7b9ddc54 Audit usage of NativeMutex
Once a native mutex has been used once, it is never allowed to be moved again.
This is because some pthreads implementations take pointers inside the mutex
itself.

This commit adds stern wording around the methods on native mutexes, and fixes
one use case in the codebase. The Mutex type in libsync was susceptible to
movement, so the inner static mutex is now boxed to ensure that the address of
the native mutex is constant.
2014-06-13 13:53:34 -07:00
Alex Crichton
b612ae9ede rustc: [T, ..N] and [T, ..N+1] are not the same
This commit fixes a bug in the calculation of the hash of a type which didn't
factor in the length of a constant-sized vector. As a result of this, a type
placed into an Any of a fixed length could be peeled out with any other fixed
length in a safe manner.
2014-06-13 13:53:34 -07:00
P1start
00e1a69237 Clarify Any docs
The `Any` docs previously did not state that only `'static` types implement it.
2014-06-13 13:53:34 -07:00
Jakub Wieczorek
42d538e615 Fix the unused struct field lint for struct variants
Fixes #14837.
2014-06-13 13:53:34 -07:00
Renato Riccieri Santos Zannon
c17af5d7fd Remove typo on collections::treemap::UnionItems
The docstring stated it was a intersection iterator, when in fact it is the union iterator
2014-06-13 13:53:34 -07:00
Alex Crichton
49fe690477 configure: Don't sync unused submodules
If the compiler is built with --{llvm,jemalloc,libuv}-root, then the configure
script can skip updating these submodules.

Closes #14822
2014-06-13 13:53:34 -07:00
Patrick Walton
9b9ef44233 libsyntax: Allow + to separate trait bounds from objects.
RFC #27.

After a snapshot, the old syntax will be removed.

This can break some code that looked like `foo as &Trait:Send`. Now you
will need to write `foo as (&Trait+Send)`.

Closes #12778.

[breaking-change]
2014-06-13 13:53:34 -07:00
Alex Crichton
03ec8e5cc9 std: Rebase better errors on master 2014-06-13 13:53:34 -07:00
Yehuda Katz
298412a6e8 Improve error messages for io::fs 2014-06-13 13:53:34 -07:00
Patrick Walton
2ed4734873 librustc: Fix the issue with labels shadowing variable names by making
the leading quote part of the identifier for the purposes of hygiene.

This adopts @jbclements' solution to #14539.

I'm not sure if this is a breaking change or not.

Closes #12512.

[breaking-change]
2014-06-13 13:53:34 -07:00
bors
e7f11f20e5 auto merge of #14604 : nikomatsakis/rust/issue-5527-namespace-substs, r=pcwalton
The current setup is to have a single vector of type parameters in
scope at any one time. We then have to concatenate the parameters from
the impl/trait with those of the method. This makes a lot of things
awkward, most notably associated fns ("static fns"). This branch
restructures the substitutions into three distinct namespaces (type,
self, fn). This makes most of the "type parameter management"
trivial. This also sets us up to support UFCS (though I haven't made
any particular changes in that direction in this patch).

Along the way, this patch fixes a few miscellaneous bits of code cleanup:

1. Patch resolve to detect references to out-of-scope type parameters,
   rather than checking for "out of bound" indices during substitution
   (fixes #14603).

2. Move def out of libsyntax into librustc where it belongs. I should have
   moved DefId too, but didn't.
   
3. Permit homogeneous tuples like `(T, T, T)` to be used as fixed-length
   vectors like `[T, ..3]`. This is awfully handy, though public facing.
   I suppose it requires an RFC.

4. Add some missing tests.

cc #5527

r? @pcwalton or @pnkfelix
2014-06-13 19:02:11 +00:00
Patrick Walton
30772d94b1 librustc: Forbid enum-to-float casts.
Closes #14794.

If you're casting from an enum to a float, cast through an integer
first.

[breaking-change]
2014-06-13 11:23:47 -07:00
Niko Matsakis
9153d8ad6c Introduce VecPerParamSpace and use it to represent sets of types and
parameters

This involves numerous substeps:

1. Treat Self same as any other parameter.
2. No longer compute offsets for method parameters.
3. Store all generic types (both trait/impl and method) with a method,
   eliminating odd discrepancies.
4. Stop doing unspeakable things to static methods and instead just use
   the natural types, now that we can easily add the type parameters from
   trait into the method's polytype.
5. No doubt some more. It was hard to separate these into distinct commits.

Fixes #13564
2014-06-13 13:20:24 -04:00
Brendan Zabarauskas
ffa4ae81e4 Add Bitwise::{swap_bytes, rotate_left, rotate_right} methods 2014-06-13 09:28:32 -07:00
bors
0422934e24 auto merge of #14831 : alexcrichton/rust/format-intl, r=brson
* The select/plural methods from format strings are removed
* The # character no longer needs to be escaped
* The \-based escapes have been removed
* '{{' is now an escape for '{'
* '}}' is now an escape for '}'

Closes #14810
[breaking-change]
2014-06-13 14:42:03 +00:00
bors
c119903f62 auto merge of #13222 : nick29581/rust/dxr4, r=brson
Adds a -Z flag `save-analysis` which runs after the analysis phase of the compiler and saves a bunch of info into a CSV file for the crate. This is designed to work with the DXR code browser, but is frontend-independent, that is this info should be useful for all kinds of code browsers, IDEs, or other tools.

I need to squash commits before landing (there will probably be a fair few to come), please ignore them for now and just comment on the changes.
2014-06-13 09:57:06 +00:00
Nick Cameron
984e9afae5 Dump results of analysis phase as CSV
Adds the option -Zsave-analysis which will dump the results of syntax and type checking into CSV files. These can be interpreted by tools such as DXR to provide semantic information about Rust programs for code search, cross-reference, etc.

Authored by Nick Cameron and Peter Elmers (@pelmers; including enums, type parameters/generics).
2014-06-13 21:09:50 +12:00
Valerii Hiora
41522aaf72 There should be no metadata to read on iOS 2014-06-13 11:41:00 +03:00
bachm
78053f0825 added get_mut() for [T] 2014-06-13 09:55:36 +02:00
Valerii Hiora
ebc6474668 Cosmetic fixes & comments 2014-06-13 10:18:12 +03:00
bors
5d9bceb144 auto merge of #14858 : alexcrichton/rust/no-jemalloc-on-travis, r=thestinger
Turns out they don't have the `je_` prefix, so we can't use the system-installed
jemalloc.
2014-06-13 04:22:01 +00:00
bors
c20aed0930 auto merge of #14819 : michaelwoerister/rust/unique_type_id, r=alexcrichton
With this change, rustc creates a unique type identifier for types in debuginfo. These type identifiers are used by LLVM to correctly handle link-time-optimization scenarios but also help rustc with dealing with inlining from other crates. For more information, see the documentation block at the top of librustc/middle/trans/debuginfo.rs and also [my blog post about the topic](http://michaelwoerister.github.io/2014/06/05/rust-debuginfo-and-unique-type-identifiers.html). This should fix the LTO issues that have been popping up lately. 

The changes to the debuginfo module's inner workings are also improved by this. Metadata uniquing of pointer types is not handled explicitly instead of relying on LLVM doing the right thing behind the scenes, and region parameters on types should not lead to metadata duplication anymore.

There are two things that I'd like to get some feedback on:
1. IDs for named items consist of two parts: The [Strict Version Hash](https://github.com/mozilla/rust/blob/0.10/src/librustc/back/svh.rs#L11) of their defining crate and the AST node id of their definition within that crate. My question is: Is the SVH a good choice for identifying the crate? Is it even going to stay? The [crate-id RFC](https://github.com/rust-lang/rfcs/pull/109) got me confused.
2. Unique Type Identifiers can be arbitrary strings and right now the format is rather verbose. For debugging this is nice, because one can infer a lot about a type from the type id alone (it's more or less a signature). For deeply nested generics, id strings could get rather long though. One option to limit the id size would be to use some hashcode instead of the full id (anything that avoids collision as much as possible). Another option would be to use a more compact representation, like ty_encode. This reduces size but also readability.
Since these ID's only show up in LLVM IR, I'm inclined to just leave in the verbose format for now, and only act if sizes of rlibs become a problem.
2014-06-13 01:52:02 +00:00
bors
7c7f4b0e0b auto merge of #14816 : theptrk/rust/unclear-comment, r=huonw
The old comment left it unclear if this is creating a random value or doing a check as to whether or not the generator is available or some other operation.

See: http://stackoverflow.com/questions/24153311/when-is-rng-gen-not-true
2014-06-13 00:07:05 +00:00