Commit Graph

26487 Commits

Author SHA1 Message Date
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
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
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
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
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
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
bors 021bea15fc auto merge of #14813 : cmr/rust/once-docs-unsafe, r=alexcrichton 2014-06-12 21:22:01 +00:00
bors 3a9228b7ea auto merge of #14811 : forticulous/rust/refcell-show, r=alexcrichton
Show impl for RefCell and friends
2014-06-12 19:36:53 +00:00
Michael Woerister c7426cf05a debuginfo: Fix issue with unique type IDs not being passed to LLVM for LLVM 3.4 2014-06-12 18:48:14 +02:00
Michael Woerister 0a98a4e422 debuginfo: Generate cross-crate unique type identifiers for debuginfo types.
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.

Fixes #13681.
2014-06-12 18:39:01 +02:00
bors 8b87c3a2a8 auto merge of #14809 : zzmp/rust/patch-2, r=alexcrichton
Previously, the type system's restrictions on borrowing were summarized as

> The previous example showed that the type system forbids any borrowing of owned boxes found in aliasable, mutable memory.

This did not jive with the example, which allowed mutations so long as the borrowed reference had been returned. Also, the language has changed to no longer allow aliasable mutable locations. This changes the summary to read

> The previous example showed that the type system forbids mutations of owned boxed values while they are being borrowed. In general, the type system also forbids borrowing a value as mutable if it is already being borrowed - either as a mutable reference or an immutable one.

This adds more general information for the experienced reader as well, to offer a more complete understanding.
2014-06-12 16:02:05 +00:00
bors c0a6f72e8b auto merge of #14805 : zzmp/rust/patch-1, r=alexcrichton
The guide previously stated:

> The compiler will automatically convert a box box point to a reference like &point.

This fixes the doubled word `box`, so the statement reads

> The compiler will automatically convert a box point to a reference like &point.

The code it is referring to is `compute_distance(&on_the_stack, on_the_heap);`, so a single `box` is appropriate.
2014-06-12 14:17:13 +00:00
bors 87bf47a0f7 auto merge of #14801 : pcwalton/rust/name-shadowing-in-one-pattern, r=alexcrichton
bindings and function arguments.

Issue #14581.

To fix code that this breaks, give the pattern identifiers different names.

[breaking-change]

r? @brson
2014-06-12 12:32:13 +00:00
bors 614e448b02 auto merge of #14800 : reem/rust/patch-1, r=alexcrichton
According to #14767 and the grammar right above this documentation, nested comments are supported.
2014-06-12 10:47:03 +00:00
bors fce98e5262 auto merge of #14799 : mcreinhard/rust/tilde-fix, r=alexcrichton
Replaced `~Drawable` with `Box<Drawable>` in tutorial
2014-06-11 22:02:00 -07:00
bors f03863ae7d auto merge of #14713 : darnuria/rust/Improve_std_os_documentation_#2, r=alexcrichton
Improving documentation, consistency, removes evils empty lines etc...
2014-06-11 19:06:58 -07:00
Axel Viala 6dc06249d7 Improve docs and refactore std::os. 2014-06-12 02:17:52 +02:00
Alex Crichton cac7a2053a std: Remove i18n/l10n from format!
* 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-11 16:04:24 -07:00
Alex Crichton 3316b1eb7c rustc: Remove ~[T] from the language
The following features have been removed

* box [a, b, c]
* ~[a, b, c]
* box [a, ..N]
* ~[a, ..N]
* ~[T] (as a type)
* deprecated_owned_vector lint

All users of ~[T] should move to using Vec<T> instead.
2014-06-11 15:02:17 -07:00
Patrick Walton c23748c59c librustc: Forbid identifiers that shadow in the same pattern in let
bindings and function arguments.

Issue #14581.

To fix code that this breaks, give the pattern identifiers different names.

[breaking-change]
2014-06-11 13:23:04 -07:00
bors f9260d41d6 auto merge of #14746 : alexcrichton/rust/libsync, r=brson
This commit is the final step in the libstd facade, #13851. The purpose of this
commit is to move libsync underneath the standard library, behind the facade.
This will allow core primitives like channels, queues, and atomics to all live
in the same location.

There were a few notable changes and a few breaking changes as part of this
movement:

* The `Vec` and `String` types are reexported at the top level of libcollections
* The `unreachable!()` macro was copied to libcore
* The `std::rt::thread` module was moved to librustrt, but it is still
  reexported at the same location.
* The `std::comm` module was moved to libsync
* The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`.
  It is now a private module with types/functions being reexported under
  `sync::comm`. This is a breaking change for any existing users of duplex
  streams.
* All concurrent queues/deques were moved directly under libsync. They are also
  all marked with #![experimental] for now if they are public.
* The `task_pool` and `future` modules no longer live in libsync, but rather
  live under `std::sync`. They will forever live at this location, but they may
  move to libsync if the `std::task` module moves as well.

[breaking-change]
2014-06-11 11:47:04 -07:00
bors f0f9095f1d auto merge of #14250 : alexcrichton/rust/gc, r=brson
This commit removes `@T` from the compiler by moving the AST to using `Gc<T>`. This also starts treating `Gc<T>` as `@T` in the same way that `Box<T>` is the same as `~T` in the compiler.

After this hits a snapshot, the `@T` syntax should be able to be removed completely.
2014-06-11 10:02:04 -07:00
Alex Crichton b1c9ce9c6f sync: Move underneath libstd
This commit is the final step in the libstd facade, #13851. The purpose of this
commit is to move libsync underneath the standard library, behind the facade.
This will allow core primitives like channels, queues, and atomics to all live
in the same location.

There were a few notable changes and a few breaking changes as part of this
movement:

* The `Vec` and `String` types are reexported at the top level of libcollections
* The `unreachable!()` macro was copied to libcore
* The `std::rt::thread` module was moved to librustrt, but it is still
  reexported at the same location.
* The `std::comm` module was moved to libsync
* The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`.
  It is now a private module with types/functions being reexported under
  `sync::comm`. This is a breaking change for any existing users of duplex
  streams.
* All concurrent queues/deques were moved directly under libsync. They are also
  all marked with #![experimental] for now if they are public.
* The `task_pool` and `future` modules no longer live in libsync, but rather
  live under `std::sync`. They will forever live at this location, but they may
  move to libsync if the `std::task` module moves as well.

[breaking-change]
2014-06-11 10:00:43 -07:00
Alex Crichton 54c2a1e1ce rustc: Move the AST from @T to Gc<T> 2014-06-11 09:51:37 -07:00
Alex Crichton 53ad426e92 syntax: Move the AST from @T to Gc<T> 2014-06-11 09:11:40 -07:00
Alex Crichton 531ed3d599 rustc: Update how Gc<T> is recognized
This commit uses the same trick as ~/Box to map Gc<T> to @T internally inside
the compiler. This moves a number of implementations of traits to the `gc`
module in the standard library.

This removes functions such as `Gc::new`, `Gc::borrow`, and `Gc::ptr_eq` in
favor of the more modern equivalents, `box(GC)`, `Deref`, and pointer equality.

The Gc pointer itself should be much more useful now, and subsequent commits
will move the compiler away from @T towards Gc<T>

[breaking-change]
2014-06-11 09:11:40 -07:00
bors c54ce27b39 auto merge of #14789 : aochagavia/rust/prelude, r=alexcrichton 2014-06-11 07:42:07 -07:00
bors ea41101b35 auto merge of #14788 : Sawyer47/rust/issue-13214, r=huonw
Closes #13214
2014-06-11 06:02:10 -07:00
bors db9e0a1142 auto merge of #14787 : alexcrichton/rust/issue-14784, r=pcwalton
This is another case of #13246. The RAII lock wasn't being destroyed until after
the allocation was free'd due to destructor scheduling.

Closes #14784
2014-06-11 04:22:02 -07:00
bors 4fdc27e55e auto merge of #14786 : pcwalton/rust/enum-to-float-casts, r=alexcrichton
If this breaks your code, take a deep breath, go for a walk, and
consider why you're relying on the sign extension semantics of
enum-to-float casts.

[breaking-change]

Closes #8230.
2014-06-10 23:37:06 -07:00
theptrk f3020c3f1f Fix unclear wording of comment 2014-06-10 20:29:09 -07:00
fort a8f581fad1 Show impl for Ref & RefMut 2014-06-10 19:24:48 -07:00
bors f92a8facf9 auto merge of #14768 : riccieri/rust/detransmute-arena, r=alexcrichton
**Update**

I've reimplemented this using `Cell` and `RefCell`, as suggested by @alexcrichton. By taking care with the duration of the borrows, I was able to maintain the recursive allocation feature (now covered by a test) without the use of `Unsafe`, and without breaking the non-aliasing `&mut` invariant.

**Original**

Changes both `Arena` and `TypedArena` to contain an inner struct wrapped in a `Unsafe`, and change field access to go through those instead of transmuting `&self` to `&mut self`.

Part of #13933
2014-06-10 18:07:07 -07:00
Corey Richardson 8472849529 sync: Once is no longer unsafe, update docs 2014-06-10 17:55:04 -07:00
Zach Pomerantz 4f90025b68 Update description to reflect language changes
Previously, the type system's restrictions on borrowing were summarized as

> The previous example showed that the type system forbids any borrowing of owned boxes found in aliasable, mutable memory

This did not jive with the example, which allowed mutations so long as the borrowed reference had been returned. Also, the language has changed to no longer allow aliasable mutable locations. This changes the summary to read

> The previous example showed that the type system forbids mutations of owned boxed values while they are being borrowed. In general, the type system also forbids borrowing a value as mutable if it is already being borrowed - either as a mutable reference or an immutable one.

This adds more general information for the experienced reader as well, to offer a more complete understanding.
2014-06-10 17:36:02 -07:00
Zach Pomerantz 782c52a924 Removed doubled wording.
The guide previously stated:

> The compiler will automatically convert a box box point to a reference like &amp;point.

This fixes the doubled word `box`, so the statement reads

> The compiler will automatically convert a box point to a reference like &amp;point.

The code it is referring to is `compute_distance(&on_the_stack, on_the_heap);`, so a single `box` is appropriate.
2014-06-10 16:53:04 -07:00
Jonathan Reem e5ebdb4c07 Remove outdated info about nested block comments. Fixes #14767 2014-06-10 15:58:54 -07:00
bors b1302f9c4f auto merge of #14764 : jbcrail/rust/fix-more-comments, r=alexcrichton 2014-06-10 15:17:01 -07:00
Michael Reinhard a0eca23786 Fix deprecated use of ~ 2014-06-10 14:44:27 -07:00
bors 7f777a5ba4 auto merge of #14752 : jakub-/rust/issue-11940, r=alexcrichton
Fixes #8315
Fixes #11940
2014-06-10 13:17:10 -07:00
bors 9bb8f88d3a auto merge of #14696 : jakub-/rust/dead-struct-fields, r=alexcrichton
This uncovered some dead code, most notably in middle/liveness.rs, which I think suggests there must be something fishy with that part of the code.

The #[allow(dead_code)] annotations on some of the fields I am not super happy about but as I understand, marker type may disappear at some point.
2014-06-10 09:49:29 -07:00
Joseph Crail c2c9946372 Fix more misspelled comments and strings. 2014-06-10 11:24:17 -04:00