Commit Graph

26487 Commits

Author SHA1 Message Date
Alex Crichton 06f3f9a0c9 rustdoc: Inline static documentation across crates 2014-06-06 19:51:24 -07:00
Alex Crichton 2290dbb8cc rustc: Avoid 16-byte filenames in rlibs
In addition to avoiding 16-byte filenames with bytecode files, this commit also
avoids 16-byte filenames with object files pulled in from native libraries.
2014-06-06 19:51:19 -07:00
Michael Woerister 6a43af3f84 Add workaround for archive reading bug in LLDB.
LLDB contains a bug that makes it crash if an archive it reads
contains a file the name of which is exactly 16 bytes long. This
bug recently has made it impossible to debug Rust applications with
LLDB because some standard libraries triggered it indirectly:
For rlibs, rustc includes the LLVM bytecode in the archive, giving
it the extension ".bc.deflate". For liballoc (for example) this
results in the 16 character filename "alloc.bc.deflate", which is
bad.

This commit replaces the ".bc.deflate" suffix with
".bytecode.deflate" which itself is already longer than 16 bytes,
thus making sure that the bug won't be run into anymore.

The bug could still be run into with 14 character filenames because
then the .o files will trigger it. However, this is much more rare
and working around it would introduce more complexity than necessary
at the moment. It can always be done later on, if the need arises.

Fixes #14356.
2014-06-06 19:51:19 -07:00
Luqman Aden 735e518a81 librustc: Update AutoObject adjustment in writeback. 2014-06-06 19:51:17 -07:00
Alex Crichton f35328caed rustc: Avoid UB with signed division/remainder
Division and remainder by 0 are undefined behavior, and are detected at runtime.
This commit adds support for ensuring that MIN / -1 is also checked for at
runtime, as this would cause signed overflow, or undefined behvaior.

Closes #8460
2014-06-06 19:51:13 -07:00
Alex Crichton 9fd075f5af rustc: Encode argument names for traits
This ensures that rustdoc can properly document inlined traits across crates.

Closes #14670
2014-06-06 19:51:08 -07:00
bors bd6683c729 auto merge of #14702 : nikomatsakis/rust/issue-5527-namespace-substs-b, r=pnkfelix
Separate out initial refactorings for PR #14604
2014-06-06 17:02:00 -07:00
Niko Matsakis 4a51e9c549 Fix resolve to not permit refs to type vars from outer fns
(Fixes #14603)
2014-06-06 19:51:24 -04:00
Niko Matsakis 3fecd10428 Add missing test case for contravariant trait matching 2014-06-06 19:51:23 -04:00
Niko Matsakis bc5eb7d98c Stop passing around Option<&substs> in trans and just pass &substs, making the code more regular 2014-06-06 19:51:23 -04:00
Niko Matsakis 0f03b5608c Move Def out of syntax crate, where it does not belong 2014-06-06 19:51:23 -04:00
Niko Matsakis 14d626a9fa Simplify MonoId not to include parameters which, given coherence, are purely derived 2014-06-06 19:46:38 -04:00
Niko Matsakis f24a53757e Move subst data structures into subst.rs, fix capitalization 2014-06-06 19:46:38 -04:00
bors 8a414858ac auto merge of #14680 : Kimundi/rust/master, r=brson
Also updated/corrected a few other details in the tuple and struct sections.
2014-06-06 15:21:59 -07:00
Jonathan S f2f1991c81 Make sync::raw::Sem use Unsafe to manage mutability instead of transmuting an unsafe pointer 2014-06-06 15:24:14 -05:00
bors 61d79175c0 auto merge of #14318 : zwarich/rust/check-loans-refactor, r=nikomatsakis
I tried to split up the less mechanical changes into separate commits so they are easier to review. One thing I'm not quite sure of is whether `MoveReason` should just be replaced with `move_data::MoveKind`.
2014-06-06 12:17:10 -07:00
Cameron Zwarich f1542a6a7d Add a test for borrowck errors with multiple closure captures.
When converting check_loans to use ExprUseVisitor I encountered a few
issues where the wrong number of errors were being emitted for multiple
closure captures, but there is no existing test for this.
2014-06-06 11:59:33 -07:00
Cameron Zwarich 74eb4b4b57 Add new tests for borrowck field-sensitivity. 2014-06-06 11:59:33 -07:00
Cameron Zwarich c53d296e12 Change check_loans to use ExprUseVisitor. 2014-06-06 11:59:33 -07:00
Cameron Zwarich 78934b03e3 Add a kind_of_move_of_path method to FlowedMoveData. 2014-06-06 11:59:33 -07:00
Cameron Zwarich 40e3fb4c0b Use the MoveReason to determine a more precise MoveKind in gather_moves. 2014-06-06 11:59:33 -07:00
Cameron Zwarich 5ccb7644be Add a move reason to the Move ConsumeMode.
Currently it is not possible to distinguish moves caused by captures
in the ExprUseVisitor interface. Since check_Loans needs to make that
distinction for generating good diagnostics, this is necessary for
check_loans to switch to ExprUseVisitor.
2014-06-06 11:59:33 -07:00
Cameron Zwarich f63fad5d60 Add an Init mode to MutateMode.
This isn't necessary right now, but check_loans needs to be able to
distinguish between initialization and writes in the ExprUseVisitor
mutate callback.
2014-06-06 11:59:32 -07:00
Cameron Zwarich 0339b27e6d Fix mem_categorization to treat an AutoObject adjustment as an rvalue.
Currently mem_categorization categorizes an AutoObject adjustment the
same as the original expression. This can cause two moves to be
generated for the same underlying expression. Currently this isn't a
problem in practice, since check_loans doesn't rely on ExprUseVisitor.
2014-06-06 11:59:32 -07:00
Cameron Zwarich d123188b20 Clean up check_loans.
Refactor a number of functions in check_loans to take node IDs and spans
rather than taking expressions directly. Also rename some variables to
make them less ambiguous.

This is the first step towards using ExprUseVisitor in check_loans, as
now some of the interfaces more closely match those used in
ExprUseVisitor.
2014-06-06 11:59:32 -07:00
bors 3744940706 auto merge of #14677 : alexcrichton/rust/issue-2665, r=brson
There's no need to distribute these ABI helpers for tests with the standard rust
distribution they're only needed for our tests.

Closes #2665
2014-06-06 10:36:55 -07:00
bors 124e997f36 auto merge of #14676 : brson/rust/double-rainbow, r=alexcrichton 2014-06-06 08:07:07 -07:00
bors 76baa5f086 auto merge of #14668 : aochagavia/rust/pr3, r=alexcrichton
Closes https://github.com/mozilla/rust/issues/14577
Closes https://github.com/mozilla/rust/issues/14639
2014-06-06 03:01:57 -07:00
bors 732e057815 auto merge of #14667 : aochagavia/rust/pr2, r=huonw 2014-06-06 01:21:54 -07:00
Adolfo Ochagavía 501b904bb7 Change to_str().to_string() to just to_str() 2014-06-06 09:56:59 +02:00
Adolfo Ochagavía 75891274c4 Document BigInt's new and from_slice methods
Fixes https://github.com/mozilla/rust/issues/14639
2014-06-06 09:09:59 +02:00
Adolfo Ochagavía 7d07a1e74b Fix documentation for `slice()`
Fixes https://github.com/mozilla/rust/issues/14577
2014-06-06 09:09:58 +02:00
bors 100ff4cf30 auto merge of #14669 : TeXitoi/rust/relicense-shootout-meteor, r=brson
part of #14248, fix #14420

Removed @richo's contribution (outdated comment)

Quoting @brson: let's move forward with this one. The only
statement I'm missing is @richo's and it sounds like his was a
minor patch.
2014-06-05 23:36:56 -07:00
bors ae9577052d auto merge of #14664 : reem/rust/lifetimes-guide-grammar, r=brson
Removed strange fragment-like thing in the intro.
2014-06-05 20:16:53 -07:00
Alex Crichton 5cdc36517e mk: Move rust_test_helpers out of libstd
There's no need to distribute these ABI helpers for tests with the standard rust
distribution they're only needed for our tests.

Closes #2665
2014-06-05 17:55:41 -07:00
bors 5ec49c7924 auto merge of #14641 : darnuria/rust/add_documentation_to_std_os, r=alexcrichton
Just opening a pull request for adding code examples and documentation to std::os.

More to come soon.
2014-06-05 16:41:53 -07:00
bors ba3ba002d5 auto merge of #14538 : alexcrichton/rust/libcollections, r=brson
As with the previous commit with `librand`, this commit shuffles around some
`collections` code. The new state of the world is similar to that of librand:

* The libcollections crate now only depends on libcore and liballoc.
* The standard library has a new module, `std::collections`. All functionality
  of libcollections is reexported through this module.

I would like to stress that this change is purely cosmetic. There are very few
alterations to these primitives.

There are a number of notable points about the new organization:

* std::{str, slice, string, vec} all moved to libcollections. There is no reason
  that these primitives shouldn't be necessarily usable in a freestanding
  context that has allocation. These are all reexported in their usual places in
  the standard library.

* The `hashmap`, and transitively the `lru_cache`, modules no longer reside in
  `libcollections`, but rather in libstd. The reason for this is because the
  `HashMap::new` contructor requires access to the OSRng for initially seeding
  the hash map. Beyond this requirement, there is no reason that the hashmap
  could not move to libcollections.

  I do, however, have a plan to move the hash map to the collections module. The
  `HashMap::new` function could be altered to require that the `H` hasher
  parameter ascribe to the `Default` trait, allowing the entire `hashmap` module
  to live in libcollections. The key idea would be that the default hasher would
  be different in libstd. Something along the lines of:

      // src/libstd/collections/mod.rs

      pub type HashMap<K, V, H = RandomizedSipHasher> =
            core_collections::HashMap<K, V, H>;

  This is not possible today because you cannot invoke static methods through
  type aliases. If we modified the compiler, however, to allow invocation of
  static methods through type aliases, then this type definition would
  essentially be switching the default hasher from `SipHasher` in libcollections
  to a libstd-defined `RandomizedSipHasher` type. This type's `Default`
  implementation would randomly seed the `SipHasher` instance, and otherwise
  perform the same as `SipHasher`.

  This future state doesn't seem incredibly far off, but until that time comes,
  the hashmap module will live in libstd to not compromise on functionality.

* In preparation for the hashmap moving to libcollections, the `hash` module has
  moved from libstd to libcollections. A previously snapshotted commit enables a
  distinct `Writer` trait to live in the `hash` module which `Hash`
  implementations are now parameterized over.

  Due to using a custom trait, the `SipHasher` implementation has lost its
  specialized methods for writing integers. These can be re-added
  backwards-compatibly in the future via default methods if necessary, but the
  FNV hashing should satisfy much of the need for speedier hashing.

A list of breaking changes:

* HashMap::{get, get_mut} no longer fails with the key formatted into the error
  message with `{:?}`, instead, a generic message is printed. With backtraces,
  it should still be not-too-hard to track down errors.

* The HashMap, HashSet, and LruCache types are now available through
  std::collections instead of the collections crate.

* Manual implementations of hash should be parameterized over `hash::Writer`
  instead of just `Writer`.

[breaking-change]
2014-06-05 15:01:54 -07:00
Alex Crichton 760b93adc0 Fallout from the libcollections movement 2014-06-05 13:55:11 -07:00
Alex Crichton 6a585375a0 std: Recreate a `collections` module
As with the previous commit with `librand`, this commit shuffles around some
`collections` code. The new state of the world is similar to that of librand:

* The libcollections crate now only depends on libcore and liballoc.
* The standard library has a new module, `std::collections`. All functionality
  of libcollections is reexported through this module.

I would like to stress that this change is purely cosmetic. There are very few
alterations to these primitives.

There are a number of notable points about the new organization:

* std::{str, slice, string, vec} all moved to libcollections. There is no reason
  that these primitives shouldn't be necessarily usable in a freestanding
  context that has allocation. These are all reexported in their usual places in
  the standard library.

* The `hashmap`, and transitively the `lru_cache`, modules no longer reside in
  `libcollections`, but rather in libstd. The reason for this is because the
  `HashMap::new` contructor requires access to the OSRng for initially seeding
  the hash map. Beyond this requirement, there is no reason that the hashmap
  could not move to libcollections.

  I do, however, have a plan to move the hash map to the collections module. The
  `HashMap::new` function could be altered to require that the `H` hasher
  parameter ascribe to the `Default` trait, allowing the entire `hashmap` module
  to live in libcollections. The key idea would be that the default hasher would
  be different in libstd. Something along the lines of:

      // src/libstd/collections/mod.rs

      pub type HashMap<K, V, H = RandomizedSipHasher> =
            core_collections::HashMap<K, V, H>;

  This is not possible today because you cannot invoke static methods through
  type aliases. If we modified the compiler, however, to allow invocation of
  static methods through type aliases, then this type definition would
  essentially be switching the default hasher from `SipHasher` in libcollections
  to a libstd-defined `RandomizedSipHasher` type. This type's `Default`
  implementation would randomly seed the `SipHasher` instance, and otherwise
  perform the same as `SipHasher`.

  This future state doesn't seem incredibly far off, but until that time comes,
  the hashmap module will live in libstd to not compromise on functionality.

* In preparation for the hashmap moving to libcollections, the `hash` module has
  moved from libstd to libcollections. A previously snapshotted commit enables a
  distinct `Writer` trait to live in the `hash` module which `Hash`
  implementations are now parameterized over.

  Due to using a custom trait, the `SipHasher` implementation has lost its
  specialized methods for writing integers. These can be re-added
  backwards-compatibly in the future via default methods if necessary, but the
  FNV hashing should satisfy much of the need for speedier hashing.

A list of breaking changes:

* HashMap::{get, get_mut} no longer fails with the key formatted into the error
  message with `{:?}`, instead, a generic message is printed. With backtraces,
  it should still be not-too-hard to track down errors.

* The HashMap, HashSet, and LruCache types are now available through
  std::collections instead of the collections crate.

* Manual implementations of hash should be parameterized over `hash::Writer`
  instead of just `Writer`.

[breaking-change]
2014-06-05 13:55:10 -07:00
bors 3ec321f535 auto merge of #14647 : BurntSushi/rust/fix-14185, r=alexcrichton
This fix suppresses dead_code warnings from code generated by regex! when
the result of regex! is unused. Correct behavior should be a single
unused variable warning.

Regression tests are included for both `let` and `static` bound regex!
values.

see #14185
2014-06-05 13:26:53 -07:00
Marvin Löbel 792fae35f7 Purged "record" from the manual.
Also updated/corrected a few other details in the tuple and struct sections.
2014-06-05 21:31:57 +02:00
bors d70a9b93d0 auto merge of #14526 : pczarn/rust/hashmap-opt, r=alexcrichton
An interface that gives a better control over the load factor and the minimum capacity for HashMap.
The size of `HashMap<K, V>` is now 64 bytes by default on a 64-bit platform (or at least 40 bytes, that is 3 words less, with FNV and without minimum capacity)

Unanswered questions about `ResizePolicy`

* should it control the `INITIAL_CAPACITY`?
* should it fully control the resizing behavior? Even though the capacity always changes by a factor of 2.
* is caching `grow_at` desirable?

special thanks to @eddyb and @pnkfelix
2014-06-05 11:06:53 -07:00
Brian Anderson b45553f075 How about a less cringe-worthy double-failure message? 2014-06-05 10:21:35 -07:00
Axel Viala 85adc09b19 Improve documentation on std::os::env. 2014-06-05 17:36:15 +02:00
bors 57e7147f3e auto merge of #14644 : alexcrichton/rust/more-no-runtime-use-cases, r=brson
A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.
2014-06-05 08:26:51 -07:00
bors bb57e417ea auto merge of #14643 : jakub-/rust/infinite-loop-unreachable, r=alexcrichton 2014-06-05 06:46:54 -07:00
bors a7ac6a4eb7 auto merge of #14642 : aochagavia/rust/pr, r=alexcrichton
The contents of a `RingBuf` are shown in the same way as the contents of a `Vector`. See the tests for examples.
2014-06-05 05:11:54 -07:00
bors f2821f2c29 auto merge of #14640 : tomjakubowski/rust/fix-14636, r=huonw
Previously, documentation for an inlined trait (i.e. a trait imported
and reexported from another crate) didn't display the trait's supertraits.

Closes #14636
2014-06-05 03:36:52 -07:00
Axel Viala f377dfe5ac Adding examples and possible failures for getcwd.
For both window and unix platforms.
2014-06-05 11:39:01 +02:00
Tom Jakubowski 2382bf42df rustdoc: Include supertraits on inlined traits
Previously, documentation for an inlined trait (i.e. a trait imported
and reexported from another crate) didn't display the trait's
supertraits.

Closes #14636
2014-06-05 01:43:30 -07:00
Guillaume Pinot ec8ef0d24d relicense shootout-meteor.rs
part of #14248, fix #14420

Removed @richo's contribution (outdated comment)

Quoting @brson: let's move forward with this one. The only
statement I'm missing is @richo's and it sounds like his was a
minor patch.
2014-06-05 10:39:09 +02:00
bors 0c74911f87 auto merge of #14568 : erickt/rust/slice-update, r=alexcrichton
This PR adds two features to make it possible to transform an `Iterator<u8>` into a `Reader`. The first patch adds a method to mutable slices that allows it to be updated with an `Iterator<T>` without paying for the bounds cost. The second adds a Iterator adaptor, `IterReader`, to provide that `Reader` interface.

I had two questions. First, are these named the right things? Second, should `IterReader` instead wrap an `Iterator<Result<u8, E>>`? This would allow you to `IterReader::new(rdr.bytes())`, which could be useful if you want to apply some iterator transformations on a reader while still exporting the Reader interface, but I'd expect there'd be a lot of overhead annotating each byte with an error result.
2014-06-05 00:51:48 -07:00
Jonathan Reem 7e0cc34d62 Fixed weird grammar in lifetimes guide. 2014-06-04 22:27:21 -07:00
bors 073c8f10fc auto merge of #14592 : alexcrichton/rust/rustdoc-links, r=huonw
These are a few assorted fixes for some issues I found this morning (details in the commits).
2014-06-04 22:21:43 -07:00
bors 422d54bed2 auto merge of #14610 : alexcrichton/rust/issue-14008, r=brson
This commit removes the <M: Any + Send> type parameter from Option::expect in
favor of just taking a hard-coded `&str` argument. This allows this function to
move into libcore.

Previous code using strings with `expect` will continue to work, but code using
this implicitly to transmit task failure will need to unwrap manually with a
`match` statement.

[breaking-change]
Closes #14008
2014-06-04 20:41:44 -07:00
Brian Anderson 9b228f8424 core: Apply stability attributes to ptr mod
* null and mut_null are unstable. Their names may change if the unsafe
  pointer types change.
* copy_memory and copy_overlapping_memory are unstable. We think they
  aren't going to change.
* set_memory and zero_memory are experimental. Both the names and
  the semantics are under question.
* swap and replace are unstable and probably won't change.
* read is unstable, probably won't change
* read_and_zero is experimental. It's necessity is in doubt.
* mem::overwrite is now called ptr::write to match read and is
  unstable. mem::overwrite is now deprecated
* array_each, array_each_with_len, buf_len, and position are
  all deprecated because they use old style iteration and their
  utility is generally under question.
2014-06-04 18:21:21 -07:00
bors aa09561bb6 auto merge of #14633 : huonw/rust/nodylibc, r=alexcrichton
libc: only provide an rlib.

There's absolutely no reason for `libc` to be offered as a dynamic
library.
2014-06-04 15:26:50 -07:00
Andrew Gallant 0f73bf32fe Fixes #14185.
This fix suppresses dead_code warnings from code generated by regex! when
the result of regex! is unused. Correct behavior should be a single
unused variable warning.

Regression tests are included for both `let` and `static` bound regex!
values.
2014-06-04 16:59:27 -04:00
bors ef9bf3a4ee auto merge of #14630 : cmr/rust/rewrite-lexer, r=alexcrichton
These are a pain to rebase, so I'm separating this from the rest of my work.
Nothing controversial here, just some simple refactoring and removal of an
unused entry in the token table. Brings the lexer into 2012 with methods!
2014-06-04 13:06:47 -07:00
Corey Richardson 181e5f3fc8 syntax: use doc comments in the interner 2014-06-04 12:10:46 -07:00
Corey Richardson 46d1af28b5 syntax: methodify the lexer 2014-06-04 12:10:46 -07:00
Alex Crichton 0c7c93b8e8 std: Improve non-task-based usage
A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

* Invoking get() on a TLD key will return None if no task is available

* Invoking replace() on a TLD key will fail if no task is available.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.
2014-06-04 11:13:12 -07:00
bors 7645982efc auto merge of #14623 : exscape/rust-fork/master, r=alexcrichton
Unlike ImmutableClonableVector::permutations() which returns an iterator,
cloning the entire array each iteration, these methods mutate the vector in-place.
For that reason, these methods are much faster; between 35-55 times faster,
depending on the benchmark. They also generate permutations in lexicographical order.
2014-06-04 11:06:49 -07:00
Piotr Czarnecki 2202b104d4 collections: optimize `HashMap`. Add `DefaultResizePolicy`.
Refactored the load factor and the minimum capacity out of HashMap.
The size of HashMap<K, V> is now 64 bytes by default on a 64-bit platform
(or 48 bytes, that is 2 words less, with FNV)
Added a documentation in a few places to clarify the behavior.
2014-06-04 19:04:38 +02:00
Jakub Wieczorek b9752b68ae Fix an ICE when a function argument is of the bottom type
Fixes #13352
2014-06-04 18:38:02 +02:00
Jakub Wieczorek 6d3e89e33c Mark the exit of infinite loops as unreachable 2014-06-04 18:37:46 +02:00
bors a6401b5226 auto merge of #14616 : forticulous/rust/rc-show, r=alexcrichton
Show impl for Rc
2014-06-04 08:11:51 -07:00
Adolfo Ochagavía 8e4e3abb1d Implement Show for RingBuf 2014-06-04 16:40:30 +02:00
Axel Viala 650909244e Add code example to std::os::getenv for unix. 2014-06-04 16:02:48 +02:00
Huon Wilson 96cc48fba2 libc: only provide an rlib.
There's absolutely no reason for `libc` to be offered as a dynamic
library.
2014-06-04 19:10:40 +10:00
bors d130acc0d0 auto merge of #14635 : BurntSushi/rust/regex-doco-touchups, r=alexcrichton 2014-06-03 23:51:41 -07:00
bors 5a6dc40a10 auto merge of #14634 : BurntSushi/rust/fix-13843, r=alexcrichton
An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.

I'd just assume that an empty regex is an invalid regex and that an error should be returned (I can't think of any reason to use an empty regex?), but it's probably better to be consistent with other regex libraries.
2014-06-03 22:01:43 -07:00
Corey Richardson 5343eb7e0c Add comments for the token table 2014-06-03 21:01:53 -07:00
Corey Richardson 024df5c8a6 syntax: shuffle some allocation out of binop_to_str 2014-06-03 21:00:55 -07:00
Andrew Gallant 179fc6dbfd Some minor documentation touchups for libregex. Fixes #13800. 2014-06-03 23:45:54 -04:00
Andrew Gallant 9d39178f2f Fixes #13843.
An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.
2014-06-03 23:04:59 -04:00
bors 3eeaa84a50 auto merge of #14628 : luqmana/rust/fcr, r=nikomatsakis
#14589.
2014-06-03 19:36:42 -07:00
Alex Crichton 1827241840 rustdoc: Put primitives in respective modules
The logical location for the documentation of a primitive is in the module that
declared it was a module for that primitive.
2014-06-03 18:49:14 -07:00
bors 507c1a0fc9 auto merge of #14632 : luqmana/rust/cu, r=huonw
The distinction doesn't make sense any more since we don't have do blocks anymore.
2014-06-03 17:46:46 -07:00
Alex Crichton 896cfcc67f std: Remove generics from Option::expect
This commit removes the <M: Any + Send> type parameter from Option::expect in
favor of just taking a hard-coded `&str` argument. This allows this function to
move into libcore.

Previous code using strings with `expect` will continue to work, but code using
this implicitly to transmit task failure will need to unwrap manually with a
`match` statement.

[breaking-change]
Closes #14008
2014-06-03 17:19:56 -07:00
Luqman Aden 559ff5e64b librustc: remove check::FnKind enum since we only ever use one variant. 2014-06-03 19:04:29 -04:00
bors f5ead0dd66 auto merge of #14627 : Indiv0/rust/fix-crateid-doc-typo, r=alexcrichton
Example URL in CrateId documentation is:

    `gihub.com/mozilla/rust`

Instead of:

    `github.com/mozilla/rust`

Also update libsyntax/crateid.rs licensing header for 2014.
2014-06-03 16:01:44 -07:00
bors 2ec3eeaba8 auto merge of #14626 : klutzy/rust/issue-14618, r=alexcrichton
As part of removing `pub use` glob, two extra import globs were
injected to make `quote_expr!` work. However the globs caused
`unused_import` warning in some places.

Quasiquoter needed the globs since it generated idents (e.g. `TyU`)
rather than absolute paths (`::syntax::ast::TyU`).
This patch removes the extra globs and makes quasiquoter use absolute
paths.

Fixes #14618

cc @sfackler
2014-06-03 14:06:42 -07:00
Luqman Aden 0a9eafaa1c librustc: Try to resolve before coercions. 2014-06-03 15:38:04 -04:00
bors 8d8a291e1c auto merge of #14625 : japaric/rust/slice-tojson, r=alexcrichton
Let me know if the amount of tests is enough or too much.
2014-06-03 11:46:51 -07:00
Nikita Pekin 296102ec86 Fix typo "gihub" in libsyntax/crateid.
Update licensing header for 2014.
2014-06-03 14:30:59 -04:00
bors 7fa5baa7ca auto merge of #14622 : reillywatson/rust/master, r=alexcrichton 2014-06-03 10:01:40 -07:00
klutzy 1ec6de3ecf syntax: Make quasiquoter use absolute paths
As part of removing `pub use` glob, two extra import globs were
injected to make `quote_expr!` work. However the globs caused
`unused_import` warning in some places.

Quasiquoter needed the globs since it generated idents (e.g. `TyU`)
rather than absolute paths (`::syntax::ast::TyU`).
This patch removes the extra globs and makes quasiquoter use absolute
paths.

Fixes #14618
2014-06-04 02:00:03 +09:00
Jorge Aparicio a413d005a7 Implement ToJson for &[T], and add tests. Closes #14619 2014-06-03 10:52:54 -05:00
Reilly Watson 5b80172f10 Doc: grammar fix in intro.md 2014-06-03 10:24:54 -04:00
Thomas Backman 3b5d6fd254 Add next_permutation and prev_permutation onto MutableOrdVector<T>.
Unlike ImmutableClonableVector::permutations() which returns an iterator,
cloning the entire array each iteration, these methods mutate the vector in-place.
For that reason, these methods are much faster; between 35-55 times faster,
depending on the benchmark. They also generate permutations in lexicographical order.
2014-06-03 16:11:47 +02:00
Piotr Jawniak 468cabf8d9 Update README file for src/ directory 2014-06-03 14:06:54 +02:00
bors 918dbfea60 auto merge of #14609 : aturon/rust/issue-12882, r=alexcrichton 2014-06-02 20:51:30 -07:00
Erick Tryzelaar 30a8bcbe3d std: add `IterReader` to adapt iterators into readers 2014-06-02 20:42:41 -07:00
bors eb1664600c auto merge of #14605 : jakub-/rust/pattern-matching-refactor, r=pcwalton
I've been working around these parts of code and it seems like it could use a bit of a refactor. This is the first step.
2014-06-02 19:01:32 -07:00
fort c6f10f8831 Adding show impl for Rc 2014-06-02 18:53:08 -07:00
bors 63e9b8f105 auto merge of #14601 : skade/rust/remove-notrust-tags, r=alexcrichton
Now that rustdoc understands proper language tags
as the code not being Rust, we can tag everything
properly. `norust` as a negative statement is a bad
tag.

This change tags examples in other languages by
their language. Plain notations are marked as `text`.
Console examples are marked as `console`.

Also fix markdown.rs to not highlight non-rust code.

Amends the documentation to reflect the new
behaviour.
2014-06-02 17:16:31 -07:00
bors 455f574470 auto merge of #14598 : alexcrichton/rust/triage, r=huonw
Closes #10764
2014-06-02 15:26:29 -07:00
Aaron Turon 7526a80ede Document failure cases for `char_at` and friends. 2014-06-02 15:22:17 -07:00
bors 837013717a auto merge of #14509 : klutzy/rust/de-pub-use-glob, r=alexcrichton
This patchset removes `pub use` usage except for `test/`.
cc #11870
2014-06-02 12:46:31 -07:00
Jakub Wieczorek 774f36b5d8 Remove further code duplication 2014-06-02 20:49:44 +02:00
Jakub Wieczorek 19e10e3a81 Improve code reuse in check_match::specialize() 2014-06-02 18:41:48 +02:00
Alex Crichton 60e0f6fbb0 test: Add tests for closed issue #10764
Closes #10764
2014-06-02 09:24:03 -07:00
Alex Crichton f02f739a82 rustdoc: Correctly inline required/provided methods
Apparently relying on provided_source in ty::Method is unreliable!

Closes #14594
2014-06-02 09:18:32 -07:00
Alex Crichton 287af7fa1a rustdoc: Deduplicate lists of implementors
Inlining caused implementors to show up multiple times.

cc #14584
2014-06-02 09:18:26 -07:00
klutzy 976c8324e1 syntax: Remove use of `pub use` globs
`quote_expr!` now injects two more (priv) `use` globs.
This may cause extra unused_imports warning.
2014-06-02 23:21:40 +09:00
klutzy e38fde71b1 doc: Remove use of `pub use` globs 2014-06-02 23:21:35 +09:00
Florian Gilcher 20fb7c62d4 docs: Stop using `notrust`
Now that rustdoc understands proper language tags
as the code not being Rust, we can tag everything
properly.

This change tags examples in other languages by
their language. Plain notations are marked as `text`.
Console examples are marked as `console`.

Also fix markdown.rs to not highlight non-rust code.
2014-06-02 12:37:54 +02:00
bors 46dad765f0 auto merge of #14596 : Sawyer47/rust/encodable-fix, r=alexcrichton
Closes #14021
2014-06-02 01:06:39 -07:00
Piotr Jawniak 1dc13e4ad4 Fix deriving Encodable trait for unit structs
Closes #14021
2014-06-02 07:46:32 +02:00
bors b981add9ee auto merge of #14569 : skade/rust/rustdoc-robust-langstring-parsing, r=alexcrichton
This changes the parsing of the language string
in code examples so that unrecognized examples
are not considered Rust code. This was, for example,
the case when a code example was marked `sh` for shell
code.

This relieves authors of having to mark those samples
as `notrust`.

Also adds recognition of the positive marker `rust`.

By default, unmarked examples are still considered rust.
2014-06-01 22:01:36 -07:00
Alex Crichton e1e8db7e4a rustdoc: Ensure external impls are inlined once
If the type associated with the impl is `pub use`'d or referenced twice in a
downstream crate, the impl will attempt to be inlined twice.

Closes #14584
2014-06-01 21:53:43 -07:00
Alex Crichton f71f97b7c2 rustdoc: Filter private methods from inlined impls
Closes #14583
2014-06-01 21:53:43 -07:00
Alex Crichton 0dbfa5f611 rustdoc: Fix some more broken links 2014-06-01 21:53:43 -07:00
klutzy 42e4464198 test: Enable #9205-related tests on windows
Fixes #9205.
2014-06-02 12:08:19 +09:00
Florian Gilcher 3fef7a74ca rustdoc: make langstring parsing more robust
This changes the parsing of the language string
in code examples so that unrecognized examples
are not considered Rust code. This was, for example,
the case when a code example was marked `sh` for shell
code.

This relieves authors of having to mark those samples
as `notrust`.

Also adds recognition of the positive marker `rust`.

By default, unmarked examples are still considered rust.

If any rust-specific tags are seen, code is considered
rust unless marked as "notrust".

Adds test cases for the detection logic.
2014-06-02 00:16:48 +02:00
Alex Crichton bba701c59d std: Drop Total from Total{Eq,Ord}
This completes the last stage of the renaming of the comparison hierarchy of
traits. This change renames TotalEq to Eq and TotalOrd to Ord.

In the future the new Eq/Ord will be filled out with their appropriate methods,
but for now this change is purely a renaming change.

[breaking-change]
2014-06-01 10:31:27 -07:00
bors c605c2b57b auto merge of #14580 : utkarshkukreti/rust/fix-docs-for-result-map, r=alexcrichton
`reader.read_line()` includes trailing newline char, which makes
`from_str` always return `None`.
2014-06-01 04:36:38 -07:00
bors dfaea70963 auto merge of #14578 : huonw/rust/as_slice-cheatsheet, r=sfackler
doc: add an `.as_slice` example to the cheatsheet.

A lot of questions about this on IRC and stackoverflow.
2014-06-01 02:36:39 -07:00
bors 064dbb9200 auto merge of #14571 : bnoordhuis/rust/libtest-check-isatty, r=alexcrichton
Fixes #14570.
2014-06-01 00:56:42 -07:00
Utkarsh Kukreti cf4864a7a5 Fix docs for `core::result::Result::map`.
`reader.read_line()` includes trailing newline char, which makes
`from_str` always return `None`.
2014-06-01 12:18:39 +05:30
bors 4e0b936900 auto merge of #14513 : alexcrichton/rust/rustdoc-primitives, r=huonw
This is currently rebased on top of #14478, but that's just to preemptively avoid rebase conflicts and to provide a better preview. This can land independently of that PR.

This change crates a dedicated page in rustdoc for primitive types to outline everything you can do with them (at least in a basic way).

* Preview - http://people.mozilla.org/~acrichton/doc/
* Exhibit A - http://people.mozilla.org/~acrichton/doc/std/#primitives
* Exhibit B - http://people.mozilla.org/~acrichton/doc/std/primitive.str.html
* Exhibit C - http://people.mozilla.org/~acrichton/doc/std/primitive.slice.html

Please don't hesitate to be nitpickity, it's easy to overlook a thing here or there!
2014-05-31 23:16:42 -07:00
Alex Crichton d58f27a82f syntax: Fix an accidental hyperlink in a comment 2014-05-31 22:00:26 -07:00
Alex Crichton 31f5de610f rustdoc: Don't inline tuple struct constructors
These don't actually point to anything, so there's no need to inline them.
2014-05-31 21:59:50 -07:00
Alex Crichton 7ec6df5f45 rustdoc: Fix cross-crate links to reexported items
Cross crate links can target items which are not rendered in the documentation.
If the item is reexported at a higher level, the destination of the link (a
concatenation of the fully qualified name) may actually lead to nowhere. This
fixes this problem by altering rustdoc to emit pages which redirect to the local
copy of the reexported structure.

cc #14515
Closes #14137
2014-05-31 21:59:50 -07:00
Alex Crichton c5830a954e doc: Fix a number of broken links
cc #14515
2014-05-31 21:59:50 -07:00
Alex Crichton 8c669d7f74 rustdoc: Suck in all impls from external crates
There is currently no way to query all impls for a type from an external crate,
and with primitive types in play this is also quite difficult. Instead of
filtering, just suck in all impls from upstream crates into the local AST, and
have them get stripped later.

This will allow population of all implementations of traits for primitive types,
as well as filling in some corner cases with inlining documentation in other
cases.
2014-05-31 21:59:50 -07:00
Alex Crichton c2564b8fd4 rustdoc: Filter inlining private external items
This prevents structures like RcBox from showing up in the documentation
2014-05-31 21:59:50 -07:00
Alex Crichton c2e3aa37da rustdoc: Create anchor pages for primitive types
This commit adds support in rustdoc to recognize the `#[doc(primitive = "foo")]`
attribute. This attribute indicates that the current module is the "owner" of
the primitive type `foo`. For rustdoc, this means that the doc-comment for the
module is the doc-comment for the primitive type, plus a signal to all
downstream crates that hyperlinks for primitive types will be directed at the
crate containing the `#[doc]` directive.

Additionally, rustdoc will favor crates closest to the one being documented
which "implements the primitive type". For example, documentation of libcore
links to libcore for primitive types, but documentation for libstd and beyond
all links to libstd for primitive types.

This change involves no compiler modifications, it is purely a rustdoc change.
The landing pages for the primitive types primarily serve to show a list of
implemented traits for the primitive type itself.

The primitive types documented includes both strings and slices in a semi-ad-hoc
way, but in a way that should provide at least somewhat meaningful
documentation.

Closes #14474
2014-05-31 21:59:50 -07:00
Alex Crichton ba9be0a72b rustdoc: Fill in external type parameters correctly
Type parameters were filled in for some areas, but not all. This commit unifies
the two code paths to fill in type parameters everywhere.

Closes #14508
2014-05-31 21:59:50 -07:00
Alex Crichton 19fe4aad68 rustdoc: Stringify more named lifetimes
cc #14462
2014-05-31 21:59:50 -07:00
Alex Crichton 658924068e rustdoc: Show all implementors of traits
When inlining documentation across crates, primitive implementors of traits were
not shown. This commit tweaks the infrastructure to treat primitive and
Path-like impls the same way, displaying all implementors everywhere.

cc #14462
2014-05-31 21:59:50 -07:00
Alex Crichton 0777ce86e1 rustdoc: Freeze the cache ASAP
The cache is going to be used earlier in the HTML generation process, which
means that it needs to get into TLS as soon as possible.
2014-05-31 21:59:50 -07:00
Alex Crichton 356423d8f1 rustdoc: Refactor structure of html::run
Instead of one giant function, this breaks it up into several smaller functions
which have explicit dependencies among one another.

There are no code changes as a result of this commit.
2014-05-31 21:59:50 -07:00
bors 5527c5dc06 auto merge of #14561 : jakub-/rust/issue-11319, r=alexcrichton
Fixes #11319
2014-05-31 21:41:46 -07:00
Huon Wilson aec7f46902 doc: add an `.as_slice` example to the cheatsheet.
A lot of questions about this on IRC and stackoverflow.
2014-06-01 14:13:10 +10:00
bors ee97698f85 auto merge of #14567 : cburgdorf/rust/patch-2, r=brson
This rewrites the example to also be more aligned with
the same example given in the main tutorial.
2014-05-31 20:01:45 -07:00
Christoph Burgdorf ade5a9d2fe Fix example in lifetime guide
This rewrites the example to also be more aligned with
the same example given in the main tutorial.
2014-05-31 23:41:50 +02:00
Christoph Burgdorf b657af8946 Rename variable in tutorial
Renamed `owned_box` to `on_the_heap` to use a consistent
naming across the tutorial and the life time guide.
Also it makes the example easier to grasp.
2014-05-31 23:33:03 +02:00
Ben Noordhuis 87ecd4f75b libtest: Only colorize output if stdout is a tty
Fixes #14570.
2014-05-31 21:55:18 +02:00
Jakub Wieczorek b64046a5b0 Make the match arm type mismatch message point to the arm's span
Fixes #11319
2014-05-31 21:10:02 +02:00
bors 60b4a97de7 auto merge of #14562 : jakub-/rust/issue-14541, r=alexcrichton
Fixes #14541
2014-05-31 11:21:38 -07:00
bors b38712071e auto merge of #14565 : fhartwig/rust/master, r=sfackler 2014-05-31 09:36:39 -07:00
Florian Hartwig 096f80e770 Fix broken markup in query_to_str documentation 2014-05-31 17:46:35 +02:00
bors 2f221c766b auto merge of #14563 : dotdash/rust/clone_kill, r=huonw
By dropping the intermediate vector that holds the relevant candidates
including duplicates and directly building the vector that has the
duplicates removed we can eliminate quite a few allocations. This
reduces the times for type checking by 5-10% (measured with libstd,
libsyntax and librustc).
2014-05-31 07:56:39 -07:00
bors 0839e940a5 auto merge of #14557 : zwarich/rust/missing-comment, r=alexcrichton
For some reason, I had this comment in my local tree but not in the
branch I sent with the PR.
2014-05-31 06:16:40 -07:00
Björn Steinbrink cd844c5fb5 Remove unnecessary allocations / clones during method lookup
By dropping the intermediate vector that holds the relevant candidates
including duplicates and directly building the vector that has the
duplicates removed we can eliminate quite a few allocations. This
reduces the times for type checking by 5-10% (measured with libstd,
libsyntax and librustc).
2014-05-31 14:58:12 +02:00
bors bcf3464827 auto merge of #14556 : sfackler/rust/kill-workcache, r=alexcrichton
This was only ever used by rustpkg and is very unmaintained.

[breaking-change]
2014-05-31 04:26:40 -07:00
Jakub Wieczorek 80e84e0001 Use RHS's struct def ID for error messages in pattern matching
Fixes #14541
2014-05-31 12:50:14 +02:00
bors 2652ba1505 auto merge of #14555 : tomjakubowski/rust/fix-snappy-link, r=alexcrichton
Google have migrated snappy to GitHub.
2014-05-31 02:46:38 -07:00
bors faa7ba75a7 auto merge of #14553 : reem/rust/nuke-owned-vectors, r=alexcrichton
I removed all remaining deprecated owned vectors from the docs. All example tests pass.
2014-05-31 01:06:40 -07:00
Steven Fackler c56c286b10 Remove libworkcache
This was only ever used by rustpkg and is very unmaintained.

[breaking-change]
2014-05-30 23:44:05 -07:00
bors 92c43dba50 auto merge of #14544 : aturon/rust/issue-14352, r=alexcrichton
Adds a platform-specific function, `split_paths` to the `os` module. This
function can be used to parse PATH-like environment variables according to
local platform conventions.

Closes #14352.
2014-05-30 23:01:43 -07:00
Cameron Zwarich 3bc76d27ae Add a comment missing from 5aff0e7
For some reason, I had this comment in my local tree but not in the
branch I sent with the PR.
2014-05-30 22:31:05 -07:00
Jonathan Reem 1959925e51 Remove deprecated owned vector from tutorial. 2014-05-30 21:30:21 -07:00
Jonathan Reem 66ee71a517 Remove deprecated owned vector from rust.md 2014-05-30 21:30:21 -07:00
Jonathan Reem f740e8dde1 Remove deprecated owned vector from macro guide. 2014-05-30 21:30:20 -07:00
Jonathan Reem c3825cbb9d Remove deprecated owned vector from intro. 2014-05-30 21:30:20 -07:00
Jonathan Reem 0033a8b269 Remove deprecated owned vector from complement cheatsheet. 2014-05-30 21:30:18 -07:00
Tom Jakubowski 7cd4879126 Fix outgoing link to snappy in the FFI guide
Google have migrated snappy to GitHub.
2014-05-30 21:27:47 -07:00
bors 60a43f9bc5 auto merge of #14534 : alexcrichton/rust/snapshots, r=sfackler
This is part 2 of the saga of renaming the Partial/Total equality and comparison traits.
2014-05-30 21:21:39 -07:00
Aaron Turon b1fbbf3e48 Add os::split_paths
Adds a platform-specific function, `split_paths` to the `os` module. This
function can be used to parse PATH-like environment variables according to
local platform conventions.

Closes #14352.
2014-05-30 21:10:48 -07:00
Alex Crichton bb96ee6123 syntax: Prepare for Total{Eq,Ord} => {Eq,Ord}
This commit adds the groundwork for the renaming of the Total{Eq,Ord} traits.
After this commit hits a snapshot, the traits can be renamed.
2014-05-30 16:03:25 -07:00
bors cc4513202d auto merge of #14547 : reem/rust/remove-owned-vec-docs, r=alexcrichton
The last example in the containers and iterators guide had a superfluous owned vector in it. Everything works fine without it, so I removed it to avoid confusion.
2014-05-30 16:01:35 -07:00
Alex Crichton 748bc3ca49 std: Rename {Eq,Ord} to Partial{Eq,Ord}
This is part of the ongoing renaming of the equality traits. See #12517 for more
details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord}
or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}.

cc #12517

[breaking-change]
2014-05-30 15:52:24 -07:00
Alex Crichton f4fa7c8a07 Register new snapshots 2014-05-30 15:52:23 -07:00
bors e5e865b804 auto merge of #14536 : zwarich/rust/issue-14498, r=luqmana
Make check_for_assignment_to_restricted_or_frozen_location treat
mutation through an owning pointer the same way it treats mutation
through an &mut pointer, where mutability must be inherited from the
base path.

I also included GC pointers in this check, as that is what the
corresponding code in gather_loans/restrictions.rs does, but I don't
think there is a way to test this with the current language.

Fixes #14498.
2014-05-30 12:41:39 -07:00
Jonathan Reem 3dace35044 Remove deprecated owned vector from iterator example. 2014-05-30 12:18:52 -07:00
bors 24e489f1e1 auto merge of #14520 : Ryman/rust/SnakeCaseLint, r=alexcrichton
This enforces `snake_case` for functions and methods only. Might be worth extending it to fields and locals too at some point in the future.

A number of breaking changes each detailed in the attached commits.
2014-05-30 11:01:37 -07:00
Kevin Butler 030b3a2499 windows: Allow snake_case errors for now. 2014-05-30 17:59:41 +01:00
Kevin Butler 09fc34066b librustc: Fix snake case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

rustc:🔙🔗:WriteOutputFile => write_output_file
rustc::middle::ty::EmptyBuiltinBounds => empty_builtin_bounds
rustc::middle::ty::AllBuiltinBounds => all_builtin_bounds
rustc::middle::liveness::IrMaps => IrMaps::new
rustc::middle::liveness::Liveness => Liveness::new
rustc::middle::resolve::NameBindings => NameBindings::new
rustc::middle::resolve::PrimitiveTypeTable => PrimitiveTypeTable::new
rustc::middle::resolve::Resolver => Resolver::new
rustc::middle::trans::datum::Datum => Datum::new
rustc::middle::trans::datum::DatumBlock => DatumBlock::new
rustc::middle::trans::datum::Rvalue => Rvalue::new
rustc::middle::typeck::infer::new_ValsAndBindings => ::infer::unify::ValsAndBindings::new
rustc::middle::typeck::infer::region_inference::RegionVarBindings => RegionVarBindings::new

[breaking-change]
2014-05-30 17:55:42 +01:00
Kevin Butler ed5bf6621e lib{serialize, uuid}: Fix snake case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

serialize::ebml::reader::Doc => seriaize::ebml::Doc::new
serialize::ebml::reader::Decoder => Decoder::new
serialize::ebml::writer::Encoder => Encoder::new

[breaking-change]
2014-05-30 17:55:41 +01:00
Kevin Butler 3faa6762c1 lib{std,core,debug,rustuv,collections,native,regex}: Fix snake_case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

std::reflect::MovePtrAdaptor => MovePtrAdaptor::new
debug::reflect::MovePtrAdaptor => MovePtrAdaptor::new
std::repr::ReprVisitor => ReprVisitor::new
debug::repr::ReprVisitor => ReprVisitor::new
rustuv::homing::HomingIO.go_to_IO_home => go_to_io_home

[breaking-change]
2014-05-30 17:55:41 +01:00
Kevin Butler 190d8bdbc6 libsyntax: Fix snake_case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

syntax::ext::mtwt::xorPush => xor_push
syntax::parse::parser::Parser => Parser::new

[breaking-change]
2014-05-30 17:55:41 +01:00
Kevin Butler 16f15ce391 rustc: Add lint for snake_case functions & methods. 2014-05-30 17:55:41 +01:00
bors 36c2c56277 auto merge of #14535 : sfackler/rust/bitv-show, r=alexcrichton
Closes #14531
2014-05-30 08:26:36 -07:00
bors 874b56d337 auto merge of #14524 : ahmedcharles/rust/to_string, r=alexcrichton 2014-05-30 06:01:41 -07:00
bors 32b6fc1eff auto merge of #14522 : aturon/rust/make_unique, r=alexcrichton,alexcrichton,me
This patch makes `Arc::make_unique` examine the number of weak
references as well as strong references, which is required for safety.

It also adds a `make_unique` method to the `Rc` type for consistency.

Closes #14521.
2014-05-30 04:21:41 -07:00
bors 3a105464fb auto merge of #14517 : lucy/rust/issue-14499, r=alexcrichton
Fixes #8537
Fixes #14499 (duplicate of #8537)

Old:
```rust
test.rs:2 	pub extern "xxxxx" fn add(x: int, y: int) -> int {
          	                   ^~
```

New:
```rust
test.rs:2 	pub extern "xxxxx" fn add(x: int, y: int) -> int {
          	           ^~~~~~~
```
2014-05-30 02:11:45 -07:00
bors 25951b2242 auto merge of #14514 : Randati/rust/patch-1, r=huonw 2014-05-30 00:31:44 -07:00
Cameron Zwarich 5aff0e7cec Fix the handling of assignments to owning pointer paths in check_loans
Make check_for_assignment_to_restricted_or_frozen_location treat
mutation through an owning pointer the same way it treats mutation
through an &mut pointer, where mutability must be inherited from the
base path.

I also included GC pointers in this check, as that is what the
corresponding code in gather_loans/restrictions.rs does, but I don't
think there is a way to test this with the current language.

Fixes #14498.
2014-05-29 22:02:57 -07:00
Piotr Jawniak aa7b215f04 Rename OSRng to OsRng
According to Rust's style guide acronyms in type names should be
CamelCase.

[breaking-change]
2014-05-30 06:37:31 +02:00
Steven Fackler 8e8f6a0372 Implement Show for Bitv{,Set}
Closes #14531
2014-05-29 21:29:06 -07:00
bors 6510527e15 auto merge of #14510 : kballard/rust/rename_strallocating_into_owned, r=alexcrichton
We already have into_string(), but it was implemented in terms of
into_owned(). Flip it around and deprecate into_owned().

Remove a few spurious calls to .into_owned() that existed in libregex
and librustdoc.
2014-05-29 19:31:42 -07:00
bors 81c022317a auto merge of #14427 : alexcrichton/rust/librand, r=huonw
This commit shuffles around some of the `rand` code, along with some
reorganization. The new state of the world is as follows:

* The librand crate now only depends on libcore. This interface is experimental.
* The standard library has a new module, `std::rand`. This interface will
  eventually become stable.

Unfortunately, this entailed more of a breaking change than just shuffling some
names around. The following breaking changes were made to the rand library:

* Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which
  will return an infinite stream of random values. Previous behavior can be
  regained with `rng.gen_iter().take(n).collect()`

* Rng::gen_ascii_str() was removed. This has been replaced with
  Rng::gen_ascii_chars() which will return an infinite stream of random ascii
  characters. Similarly to gen_iter(), previous behavior can be emulated with
  `rng.gen_ascii_chars().take(n).collect()`

* {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
  relied on being able to use an OSRng for seeding, but this is no longer
  available in librand (where these types are defined). To retain the same
  functionality, these types now implement the `Rand` trait so they can be
  generated with a random seed from another random number generator. This allows
  the stdlib to use an OSRng to create seeded instances of these RNGs.

* Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
  pretty rare in the codebase, and it allows for libcore to not depend on
  liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
  supported.  If this is undesirable, librand can depend on liballoc and regain
  these implementations.

* The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
   but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
   structure now has a lifetime associated with it.

cc #13851

[breaking-change]
2014-05-29 16:41:42 -07:00
Alex Crichton 925ff65118 std: Recreate a `rand` module
This commit shuffles around some of the `rand` code, along with some
reorganization. The new state of the world is as follows:

* The librand crate now only depends on libcore. This interface is experimental.
* The standard library has a new module, `std::rand`. This interface will
  eventually become stable.

Unfortunately, this entailed more of a breaking change than just shuffling some
names around. The following breaking changes were made to the rand library:

* Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which
  will return an infinite stream of random values. Previous behavior can be
  regained with `rng.gen_iter().take(n).collect()`

* Rng::gen_ascii_str() was removed. This has been replaced with
  Rng::gen_ascii_chars() which will return an infinite stream of random ascii
  characters. Similarly to gen_iter(), previous behavior can be emulated with
  `rng.gen_ascii_chars().take(n).collect()`

* {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
  relied on being able to use an OSRng for seeding, but this is no longer
  available in librand (where these types are defined). To retain the same
  functionality, these types now implement the `Rand` trait so they can be
  generated with a random seed from another random number generator. This allows
  the stdlib to use an OSRng to create seeded instances of these RNGs.

* Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
  pretty rare in the codebase, and it allows for librand to not depend on
  liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
  supported.  If this is undesirable, librand can depend on liballoc and regain
  these implementations.

* The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
  but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
  structure now has a lifetime associated with it.

* The `sample` method on `Rng` has been moved to a top-level function in the
  `rand` module due to its dependence on `Vec`.

cc #13851

[breaking-change]
2014-05-29 16:18:26 -07:00
bors 0935beba71 auto merge of #14486 : michaelwoerister/rust/unified_enum_rep, r=luqmana
So far the DWARF information for enums was different for regular enums, univariant enums, Option-like enums, etc. Regular enums were encoded as unions of structs, while the other variants were encoded as bare structs. With the changes in this PR all enums are encoded as unions so that debuggers can reconstruct if something originally was a struct, a univariant enum, or an Option-like enum.  For the latter case, information about the *Null* variant is encoded into the union field name. This information can then be used by the debugger to print a `None` value actually as `None` instead of `Some(0x0)`.

The changes in this PR should also fix the regression reported in #14385 and #14411, but I want to close these only after I have confirmation from the original reporters that the issues are actually fixed for them.
2014-05-29 14:41:42 -07:00
Aaron Turon 7889c95124 Make Arc::make_unique check weak refs; add make_unique to Rc
This patch makes `Arc::make_unique` examine the number of weak
references as well as strong references, which is required for safety.

It also adds a `make_unique` method to the `Rc` type for consistency.

Closes #14521.
2014-05-29 13:26:23 -07:00
Ahmed Charles 2dfad3bf52 Change to_owned() to to_string(). 2014-05-29 12:28:08 -07:00
bors 729ee20338 auto merge of #14483 : ahmedcharles/rust/patbox, r=alexcrichton 2014-05-29 12:11:40 -07:00
lucy 1b3a030092 syntax: Fix span on illegal ABI errors
Fixes #8537
Fixes #14499
2014-05-29 19:09:46 +02:00
bors 50b8528970 auto merge of #14492 : alexcrichton/rust/totaleq, r=pnkfelix
This is a transitionary step towards completing #12517. This change modifies the
compiler to accept Partial{Ord,Eq} as deriving modes which will currently expand
to implementations of PartialOrd and PartialEq (synonyms for Eq/Ord).

After a snapshot, all of deriving(Eq, Ord) will be removed, and after a snapshot
of that, TotalEq/TotalOrd will be renamed to Eq/Ord.
2014-05-29 10:01:37 -07:00
bors c631d3d804 auto merge of #14488 : SimonSapin/rust/patch-11, r=alexcrichton
According to the corresponding section, accessing a mutable static variable requires `unsafe` too, and I believe it counts as as language level feature. Add it to the relevant list in the Unsafety section.
2014-05-29 07:51:40 -07:00
bors bee4e6adac auto merge of #14487 : arielb1/rust/fix-13933, r=alexcrichton
Fix issue #13933 in a few files. A more complete fix would require core::raw::MutSlice.
2014-05-29 06:11:39 -07:00
Michael Woerister eea329b0f7 debuginfo: Make DWARF representation of enums uniform.
So far the DWARF information for enums was different
for regular enums, univariant enums, Option-like enums,
etc. Regular enums were encoded as unions of structs,
while the other variants were encoded as bare structs.

With the changes in this PR all enums are encoded as
unions so that debuggers can reconstruct if something
originally was a struct, a univariant enum, or an
Option-like enum. For the latter case, information
about the Null variant is encoded into the union field
name. This information can then be used by the
debugger to print a None value actually as None
instead of Some(0x0).
2014-05-29 14:21:03 +02:00
Michael Woerister 138089355d debuginfo: Add documentation comments to debuginfo.rs
Conflicts:
	src/librustc/middle/trans/debuginfo.rs
2014-05-29 14:19:57 +02:00
Randati 0e12934ed3 Revert erroneous fix to tutorial 2014-05-29 15:11:53 +03:00
bors ff2bf58e9e auto merge of #14481 : alexcrichton/rust/no-format-strbuf, r=sfackler
* Removes `format_strbuf!()`
2014-05-29 03:31:39 -07:00
bors cb3c4f9c82 auto merge of #14472 : huonw/rust/native-lib-warnings, r=alexcrichton
rustc: clarify warning about native deps for a staticlib.

This adjusts the "unlinked native library" warning one receives when
compiling with `crate_type="staticlib"`. The warning is just trying to
tell the user that they need to link against these libraries, but the
old text wasn't making this obvious, the new text says this explicitly.
2014-05-29 00:16:41 -07:00
bors a6a1c9071a auto merge of #14477 : alexcrichton/rust/issue-14456, r=brson
When spawning a process, stdio file descriptors can be configured to be ignored,
which basically means that they'll be closed. Currently this is done by
literally closing the file descriptors in the child, but this can have adverse
side effects if the child process then opens a new file descriptor, assigning it
to a stdio number.

To work around the problems of the child, this commit alters the process
spawning code to map stdio fds to /dev/null on unix (and a similar equivalent on
windows) when they are specified as being ignored. This should allow spawned
programs to have more expected behavior when opening new files.

Closes #14456
2014-05-28 22:41:38 -07:00