]> git.lizzy.rs Git - rust.git/log
rust.git
9 years ago/*! -> //!
Steve Klabnik [Wed, 26 Nov 2014 02:17:11 +0000 (21:17 -0500)]
/*! -> //!

Sister pull request of https://github.com/rust-lang/rust/pull/19288, but
for the other style of block doc comment.

9 years agoauto merge of #19115 : jakub-/rust/issue-19100, r=alexcrichton
bors [Wed, 26 Nov 2014 22:37:06 +0000 (22:37 +0000)]
auto merge of #19115 : jakub-/rust/issue-19100, r=alexcrichton

...of the type being matched.

This change will result in a better diagnostic for code like the following:

```rust
enum Enum {
    Foo,
    Bar
}

fn f(x: Enum) {
    match x {
        Foo => (),
        Bar => ()
    }
}
```

which would currently simply fail with an unreachable pattern error
on the 2nd arm.

The user is advised to either use a qualified path in the patterns
or import the variants explicitly into the scope.

9 years agoDo not print any warnings if '-A warnings' is specified on the command line
Jakub Bukaj [Mon, 24 Nov 2014 19:53:12 +0000 (14:53 -0500)]
Do not print any warnings if '-A warnings' is specified on the command line

9 years agoWarn on pattern bindings that have the same name as a variant
Jakub Bukaj [Thu, 20 Nov 2014 15:57:36 +0000 (16:57 +0100)]
Warn on pattern bindings that have the same name as a variant

...of the type being matched.

This change will result in a better diagnostic for code like the following:

```rust
enum Enum {
    Foo,
    Bar
}

fn f(x: Enum) {
    match x {
        Foo => (),
        Bar => ()
    }
}
```

which would currently simply fail with an unreachable pattern error
on the 2nd arm.

The user is advised to either use a qualified path in the patterns
or import the variants explicitly into the scope.

9 years agoauto merge of #19144 : michaelwoerister/rust/lldb-scripts, r=alexcrichton
bors [Wed, 26 Nov 2014 20:12:09 +0000 (20:12 +0000)]
auto merge of #19144 : michaelwoerister/rust/lldb-scripts, r=alexcrichton

This PR adds the `rust-lldb` script (feel free to bikeshed about the name).
The script will start LLDB and, before doing anything else, load [LLDB type summaries](http://lldb.llvm.org/varformats.html) that will make LLDB print values with Rust syntax. Just use the script like you would normally use LLDB:

```
rust-lldb executable-to-debug --and-any-other-commandline --args
```
The script will just add one additional commandline argument to the LLDB invocation and pass along the rest of the arguments to LLDB after that.

Given the following program...
```rust
fn main() {
let x = Some(1u);
let y = [0, 1, 2i];
let z = (x, y);

println!("{} {} {}", x, y, z);
}
```
...*without* the 'LLDB type summaries', values will be printed something like this...
```
(lldb) p x
(core::option::Option<uint>) $3 = {
   = (RUST$ENUM$DISR = Some)
   = (RUST$ENUM$DISR = Some, 1)
}
(lldb) p y
(long [3]) $4 = ([0] = 0, [1] = 1, [2] = 2)
(lldb) p z
((core::option::Option<uint>, [int, ..3])) $5 = {
   = {
     = (RUST$ENUM$DISR = Some)
     = (RUST$ENUM$DISR = Some, 1)
  }
   = ([0] = 0, [1] = 1, [2] = 2)
}
```
...*with* the 'LLDB type summaries', values will be printed like this:
```
(lldb) p x
(core::option::Option<uint>) $0 = Some(1)
(lldb) p y
(long [3]) $1 = [0, 1, 2]
(lldb) p z
((core::option::Option<uint>, [int, ..3])) $2 = (Some(1), [0, 1, 2])
```

The 'LLDB type summaries' used by the script have been in use for a while in the LLDB autotests but I still consider them to be of alpha-version quality. If you see anything weird when you use them, feel free to file an issue.

The script will use whatever Rust "installation" is in PATH, so whichever `rustc` will be called if you type `rustc` into the console, this is the one that the script will ask for the LLDB extension module location. The build system will take care of putting the script and LLDB python module in the right places, whether you want to use the stage1 or stage2 compiler or the one coming with `make install` / `rustup.sh`.

Since I don't have much experience with the build system, Makefiles and shell scripts, please look these changes over carefully.

9 years agoauto merge of #19176 : aturon/rust/stab-iter, r=alexcrichton
bors [Wed, 26 Nov 2014 17:42:07 +0000 (17:42 +0000)]
auto merge of #19176 : aturon/rust/stab-iter, r=alexcrichton

This is an initial pass at stabilizing the `iter` module. The module is
fairly large, but is also pretty polished, so most of the stabilization
leaves things as they are.

Some changes:

* Due to the new object safety rules, various traits needs to be split
  into object-safe traits and extension traits. This includes `Iterator`
  itself. While splitting up the traits adds some complexity, it will
  also increase flexbility: once we have automatic impls of `Trait` for
  trait objects over `Trait`, then things like the iterator adapters
  will all work with trait objects.

* Iterator adapters that use up the entire iterator now take it by
  value, which makes the semantics more clear and helps catch bugs. Due
  to the splitting of Iterator, this does not affect trait objects. If
  the underlying iterator is still desired for some reason, `by_ref` can
  be used. (Note: this change had no fallout in the Rust distro except
  for the useless mut lint.)

* In general, extension traits new and old are following an [in-progress
  convention](rust-lang/rfcs#445). As such, they
  are marked `unstable`.

* As usual, anything involving closures is `unstable` pending unboxed
  closures.

* A few of the more esoteric/underdeveloped iterator forms (like
  `RandomAccessIterator` and `MutableDoubleEndedIterator`, along with
  various unfolds) are left experimental for now.

* The `order` submodule is left `experimental` because it will hopefully
  be replaced by generalized comparison traits.

* "Leaf" iterators (like `Repeat` and `Counter`) are uniformly
  constructed by free fns at the module level. That's because the types
  are not otherwise of any significance (if we had `impl Trait`, you
  wouldn't want to define a type at all).

Closes #17701

Due to renamings and splitting of traits, this is a:

[breaking-change]

9 years agodebuginfo: Fix LLDB pretty printer for enum variants with zero fields.
Michael Woerister [Wed, 26 Nov 2014 16:42:32 +0000 (17:42 +0100)]
debuginfo: Fix LLDB pretty printer for enum variants with zero fields.

9 years agoauto merge of #19262 : murarth/rust/module-path-fix, r=jakub-
bors [Wed, 26 Nov 2014 15:07:23 +0000 (15:07 +0000)]
auto merge of #19262 : murarth/rust/module-path-fix, r=jakub-

Closes #18859

9 years agodebuginfo: Add script that allows to conveniently start LLDB in "rust-mode"
Michael Woerister [Thu, 13 Nov 2014 16:25:15 +0000 (17:25 +0100)]
debuginfo: Add script that allows to conveniently start LLDB in "rust-mode"

9 years agoAdd -Z print-sysroot commandline option to rustc.
Michael Woerister [Thu, 13 Nov 2014 08:39:27 +0000 (09:39 +0100)]
Add -Z print-sysroot commandline option to rustc.

9 years agoauto merge of #19252 : japaric/rust/cow, r=aturon
bors [Wed, 26 Nov 2014 12:02:16 +0000 (12:02 +0000)]
auto merge of #19252 : japaric/rust/cow, r=aturon

- Add `IntoCow` trait, and put it in the prelude
- Add `is_owned`/`is_borrowed` methods to `Cow`
- Add `CowString`/`CowVec` type aliases (to `Cow<'_, String, str>`/`Cow<'_, Vec, [T]>` respectively)
- `Cow` implements: `Show`, `Hash`, `[Partial]{Eq,Ord}`
- `impl BorrowFrom<Cow<'a, T, B>> for B`

[breaking-change]s:

- `IntoMaybeOwned` has been removed from the prelude
- libcollections: `SendStr` is now an alias to `CowString<'static>` (it was aliased to `MaybeOwned<'static>`)
- libgraphviz:
  - `LabelText` variants now wrap `CowString` instead of `MaybeOwned`
  - `Nodes` and `Edges` are now type aliases to `CowVec` (they were aliased to `MaybeOwnedVec`)
- libstd/path: `Display::as_maybe_owned` has been renamed to `Display::as_cow` and now returns a `CowString`
- These functions now accept/return `Cow` instead of `MaybeOwned[Vector]`:
  - libregex: `Replacer::reg_replace`
  - libcollections: `str::from_utf8_lossy`
  - libgraphviz: `Id::new`, `Id::name`, `LabelText::pre_escaped_content`
  - libstd: `TaskBuilder::named`

r? @aturon

9 years agoauto merge of #19169 : aturon/rust/fds, r=alexcrichton
bors [Wed, 26 Nov 2014 08:42:09 +0000 (08:42 +0000)]
auto merge of #19169 : aturon/rust/fds, r=alexcrichton

This PR adds some internal infrastructure to allow the private `std::sys` module to access internal representation details of `std::io`.

It then exposes those details in two new, platform-specific API surfaces: `std::os::unix` and `std::os::windows`.

To start with, these will provide the ability to extract file descriptors, HANDLEs, SOCKETs, and so on from `std::io` types.

More functionality, and more specific platforms (e.g. `std::os::linux`) will be added over time.

Closes #18897

9 years agoauto merge of #19212 : steveklabnik/rust/doc_format_specifiers, r=alexcrichton
bors [Wed, 26 Nov 2014 06:42:06 +0000 (06:42 +0000)]
auto merge of #19212 : steveklabnik/rust/doc_format_specifiers, r=alexcrichton

Fixes #19209

9 years agoremove deprecated stuff from std::fmt docs
Steve Klabnik [Sat, 22 Nov 2014 16:13:38 +0000 (11:13 -0500)]
remove deprecated stuff from std::fmt docs

Fixes #19209

9 years agoFallout from stabilization
Aaron Turon [Thu, 6 Nov 2014 17:32:37 +0000 (09:32 -0800)]
Fallout from stabilization

9 years agolibs: stabilize iter module
Aaron Turon [Thu, 6 Nov 2014 17:32:32 +0000 (09:32 -0800)]
libs: stabilize iter module

This is an initial pass at stabilizing the `iter` module. The module is
fairly large, but is also pretty polished, so most of the stabilization
leaves things as they are.

Some changes:

* Due to the new object safety rules, various traits needs to be split
  into object-safe traits and extension traits. This includes `Iterator`
  itself. While splitting up the traits adds some complexity, it will
  also increase flexbility: once we have automatic impls of `Trait` for
  trait objects over `Trait`, then things like the iterator adapters
  will all work with trait objects.

* Iterator adapters that use up the entire iterator now take it by
  value, which makes the semantics more clear and helps catch bugs. Due
  to the splitting of Iterator, this does not affect trait objects. If
  the underlying iterator is still desired for some reason, `by_ref` can
  be used. (Note: this change had no fallout in the Rust distro except
  for the useless mut lint.)

* In general, extension traits new and old are following an [in-progress
  convention](https://github.com/rust-lang/rfcs/pull/445). As such, they
  are marked `unstable`.

* As usual, anything involving closures is `unstable` pending unboxed
  closures.

* A few of the more esoteric/underdeveloped iterator forms (like
  `RandomAccessIterator` and `MutableDoubleEndedIterator`, along with
  various unfolds) are left experimental for now.

* The `order` submodule is left `experimental` because it will hopefully
  be replaced by generalized comparison traits.

* "Leaf" iterators (like `Repeat` and `Counter`) are uniformly
  constructed by free fns at the module level. That's because the types
  are not otherwise of any significance (if we had `impl Trait`, you
  wouldn't want to define a type at all).

Closes #17701

Due to renamings and splitting of traits, this is a:

[breaking-change]

9 years agoauto merge of #19011 : ricky26/rust/trait_supertraits, r=nikomatsakis
bors [Tue, 25 Nov 2014 22:36:59 +0000 (22:36 +0000)]
auto merge of #19011 : ricky26/rust/trait_supertraits, r=nikomatsakis

It looks like currently kinds required by traits are not propagated when they are wrapped in a TyTrait. Additionally, in SelectionContext::builtin_bound, no attempt is made to check whether the target trait or its supertraits require the kind specified.

This PR alters SelectionContext::builtin_bound to examine all supertraits in the target trait's bounds recursively for required kinds.

Alternatively, the kinds could be added to the TyTrait upon creation (by just setting its builtin_bounds to the union of the bounds requested in this instance and the bounds required by the trait), this option may have less overhead during compilation but information is lost about which kinds were explicitly requested for this instance (vs those specified by traits/supertraits) would be lost.

9 years agoauto merge of #19255 : aturon/rust/merge-sync, r=alexcrichton,alexcrichton
bors [Tue, 25 Nov 2014 20:32:20 +0000 (20:32 +0000)]
auto merge of #19255 : aturon/rust/merge-sync, r=alexcrichton,alexcrichton

This patch merges the `libsync` crate into `libstd`, undoing part of the
facade. This is in preparation for ultimately merging `librustrt`, as
well as the upcoming rewrite of `sync`.

Because this removes the `libsync` crate, it is a:

[breaking-change]

However, all uses of `libsync` should be able to reroute through
`std::sync` and `std::comm` instead.

r? @alexcrichton

9 years agoDeprecate MaybeOwned[Vector] in favor of Cow
Jorge Aparicio [Fri, 21 Nov 2014 22:10:42 +0000 (17:10 -0500)]
Deprecate MaybeOwned[Vector] in favor of Cow

9 years agoauto merge of #18234 : pnkfelix/rust/fsk-type-fragments-for-needsdrop-2, r=nikomatsakis
bors [Tue, 25 Nov 2014 15:48:05 +0000 (15:48 +0000)]
auto merge of #18234 : pnkfelix/rust/fsk-type-fragments-for-needsdrop-2, r=nikomatsakis

Code to fragment paths into pieces based on subparts being moved around, e.g. moving `x.1` out of a tuple `(A,B,C)` leaves behind the fragments `x.0: A` and `x.2: C`.  Further discussion in borrowck/doc.rs.

Includes differentiation between assigned_fragments and moved_fragments, support for all-but-one array fragments, and instrumentation to print out the moved/assigned/unmmoved/parents for each function, factored out into a separate submodule.

These fragments can then be used by `trans` to inject stack-local dynamic drop flags.  (They also can be hooked up with dataflow to reduce the expected number of injected flags.)

9 years agoFirst tests making use of the new fn move-fragments instrumentation.
Felix S. Klock II [Wed, 1 Oct 2014 16:53:10 +0000 (18:53 +0200)]
First tests making use of the new fn move-fragments instrumentation.

The tests use new "//~| ERROR" follow syntax.

Includes a test for moves involving array elements.  It was easier
than i realized to get something naive off the ground here.

9 years agoAdded fragments.rs: compute drop obligations remaining post moves.
Felix S. Klock II [Thu, 18 Sep 2014 13:33:36 +0000 (15:33 +0200)]
Added fragments.rs: compute drop obligations remaining post moves.

Includes differentiation between assigned_fragments and
moved_fragments, support for all-but-one array fragments, and
instrumentation to print out the moved/assigned/unmmoved/parents for
each function, factored out into separate submodule.

9 years agoCheck other fields are consistent in `LoanPath::common`.
Felix S. Klock II [Wed, 8 Oct 2014 14:15:28 +0000 (16:15 +0200)]
Check other fields are consistent in `LoanPath::common`.

9 years agoTrack what drop obligations are established on match arms.
Felix S. Klock II [Tue, 16 Sep 2014 13:24:56 +0000 (15:24 +0200)]
Track what drop obligations are established on match arms.

This is accomplished by:

1. Add `MatchMode` enum to `expr_use_visitor`.

2. Computing the match mode for each pattern via a pre-pass, and then
   passing the mode along when visiting the pattern in
   expr_use_visitor.

3. Adding a `fn matched_pat` callback to expr_use_visitor, which is
   called on interior struct and enum nodes of the pattern (as opposed
   to `fn consume_pat`, which is only invoked for identifiers at the
   leaves of the pattern), and invoking it accordingly.

Of particular interest are the `cat_downcast` instances established
when matching enum variants.

9 years agoOverride `LoanPath` Eq impl to enforce invariant: eq lp's always have eq types.
Felix S. Klock II [Tue, 14 Oct 2014 01:23:34 +0000 (03:23 +0200)]
Override `LoanPath` Eq impl to enforce invariant: eq lp's always have eq types.

9 years ago`MemCategorizationContext::pat_ty(BindByRef)` yields type of borrowed val now.
Felix S. Klock II [Tue, 14 Oct 2014 01:21:54 +0000 (03:21 +0200)]
`MemCategorizationContext::pat_ty(BindByRef)` yields type of borrowed val now.

This is to fix a problem where I could not reliably map attach the
type for each loan-path to the loan-path itself because the same
loan-path was ending up associated with two different types, because
the cmt's had diverged in their interpretation of the path.

9 years agoAdd `ty` to `LoanPath`.
Felix S. Klock II [Thu, 18 Sep 2014 05:58:26 +0000 (07:58 +0200)]
Add `ty` to `LoanPath`.

To make this clean, refactored old `LoanPath` enum into a
`LoanPath` struct with a `ty::t` and a newly-added `LoanPathVariant` enum.

This enabled me to get rid of the ugly and fragile `LoanPath::to_type`
method, and I can probably also get rid of other stuff that was
supporting it, maybe.

9 years agoAdd `LpDowncast`, `LoanPath` variant tracking downcasts in match arms.
Felix S. Klock II [Tue, 16 Sep 2014 12:14:59 +0000 (14:14 +0200)]
Add `LpDowncast`, `LoanPath` variant tracking downcasts in match arms.

`LpDowncast` carries the `DefId` of the variant itself.  To support
this, added the enum variant `DefId` to the `cat_downcast` variant in
`mem_categorization::categorization`.

(updated to fix mem_categorization to handle downcast of enum
struct-variants properly.)

9 years agoauto merge of #19174 : tomjakubowski/rust/rustdoc-assoc-types, r=alexcrichton
bors [Tue, 25 Nov 2014 13:46:45 +0000 (13:46 +0000)]
auto merge of #19174 : tomjakubowski/rust/rustdoc-assoc-types, r=alexcrichton

Render associated types on traits and impls, and qualified paths in types.

r? @alexcrichton

9 years agoauto merge of #19172 : alfie/rust/impl-traitless, r=steveklabnik
bors [Tue, 25 Nov 2014 11:46:39 +0000 (11:46 +0000)]
auto merge of #19172 : alfie/rust/impl-traitless, r=steveklabnik

An example of how implementations work without traits would be handy

9 years agoauto merge of #19149 : alexcrichton/rust/issue-19091, r=aturon
bors [Tue, 25 Nov 2014 09:21:45 +0000 (09:21 +0000)]
auto merge of #19149 : alexcrichton/rust/issue-19091, r=aturon

This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename
non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all
`unwrap` methods are retained as `#[deprecated]` for the near future. To update
code rename `unwrap` method calls to `into_inner`.

[rfc]: https://github.com/rust-lang/rfcs/pull/430
[breaking-change]

cc #19091

9 years agoauto merge of #18966 : huonw/rust/iter2slice, r=aturon
bors [Tue, 25 Nov 2014 06:51:38 +0000 (06:51 +0000)]
auto merge of #18966 : huonw/rust/iter2slice, r=aturon

A slice iterator is isomorphic to a slice, just with a slightly
different form: storing start and end pointers rather than start pointer
and length. This patch reflects this by making converting between them
as easy as `iter.as_slice()` (or even `iter[]` if the shorter lifetime
is ok). That is, `slice.iter().as_slice() == slice`.

r? @aturon

9 years agoAdd methods to go from a slice iterators to a slice.
Huon Wilson [Sat, 15 Nov 2014 03:44:55 +0000 (14:44 +1100)]
Add methods to go from a slice iterators to a slice.

A slice iterator is isomorphic to a slice, just with a slightly
different form: storing start and end pointers rather than start pointer
and length. This patch reflects this by making converting between them
as easy as `iter.as_slice()` (or even `iter[]` if the shorter lifetime
is ok). That is, `slice.iter().as_slice() == slice`.

9 years agoauto merge of #19285 : alexcrichton/rust/issue-19280, r=aturon
bors [Tue, 25 Nov 2014 01:06:41 +0000 (01:06 +0000)]
auto merge of #19285 : alexcrichton/rust/issue-19280, r=aturon

It turns out that rustrt::at_exit() doesn't actually occur after all pthread
threads have exited (nor does atexit()), so there's not actually a known point
at which we can deallocate these keys. It's not super critical that we do so,
however, because we're about to exit anyway!

Closes #19280

9 years agostd: Leak all statically allocated TLS keys
Alex Crichton [Mon, 24 Nov 2014 23:24:29 +0000 (15:24 -0800)]
std: Leak all statically allocated TLS keys

It turns out that rustrt::at_exit() doesn't actually occur after all pthread
threads have exited (nor does atexit()), so there's not actually a known point
at which we can deallocate these keys. It's not super critical that we do so,
however, because we're about to exit anyway!

Closes #19280

9 years agoauto merge of #19021 : roysc/rust/emacs-pr, r=brson
bors [Mon, 24 Nov 2014 23:06:45 +0000 (23:06 +0000)]
auto merge of #19021 : roysc/rust/emacs-pr, r=brson

"_" should keep the default syntax class (symbol, not word). This
allows, e.g., `forward-word' to behave in the familiar way, jumping to
underscores within a function or variable name.

9 years agoauto merge of #18818 : steveklabnik/rust/tcp_doc, r=alexcrichton
bors [Mon, 24 Nov 2014 21:02:33 +0000 (21:02 +0000)]
auto merge of #18818 : steveklabnik/rust/tcp_doc, r=alexcrichton

This suggests that you must call it, which is normally not what you want to do.

See here: http://www.reddit.com/r/rust/comments/2lpw9k/rust_irc_example_looking_for_feedback/clxnxxc?context=4

9 years agoDon't call drop in tcpstream docs
Steve Klabnik [Sun, 9 Nov 2014 20:23:56 +0000 (15:23 -0500)]
Don't call drop in tcpstream docs

This suggests that you must call it, which is normally not what you want to do.

9 years agoMerge libsync into libstd
Aaron Turon [Sun, 23 Nov 2014 20:52:37 +0000 (12:52 -0800)]
Merge libsync into libstd

This patch merges the `libsync` crate into `libstd`, undoing part of the
facade. This is in preparation for ultimately merging `librustrt`, as
well as the upcoming rewrite of `sync`.

Because this removes the `libsync` crate, it is a:

[breaking-change]

However, all uses of `libsync` should be able to reroute through
`std::sync` and `std::comm` instead.

9 years agoAdded test for module_path! fix
Murarth [Mon, 24 Nov 2014 05:24:38 +0000 (22:24 -0700)]
Added test for module_path! fix

9 years agoFixed "::::" appearing in module_path!()
Murarth [Mon, 24 Nov 2014 05:22:07 +0000 (22:22 -0700)]
Fixed "::::" appearing in module_path!()

9 years agoauto merge of #19258 : nick29581/rust/dxr-minor, r=brson
bors [Mon, 24 Nov 2014 16:07:00 +0000 (16:07 +0000)]
auto merge of #19258 : nick29581/rust/dxr-minor, r=brson

r?

9 years agoauto merge of #19250 : kmcallister/rust/atomicoption, r=alexcrichton
bors [Mon, 24 Nov 2014 13:56:36 +0000 (13:56 +0000)]
auto merge of #19250 : kmcallister/rust/atomicoption, r=alexcrichton

Fixes #19247.

9 years agorustdoc: render ast::QPath
Tom Jakubowski [Fri, 21 Nov 2014 05:45:05 +0000 (21:45 -0800)]
rustdoc: render ast::QPath

Fix #18594

9 years agorustdoc: Render associated types on traits and impls
Tom Jakubowski [Thu, 20 Nov 2014 19:22:09 +0000 (11:22 -0800)]
rustdoc: Render associated types on traits and impls

9 years agoAdd `node_to_user_string`, `node_to_string` variant that drops id from output.
Felix S. Klock II [Fri, 19 Sep 2014 13:38:53 +0000 (15:38 +0200)]
Add `node_to_user_string`, `node_to_string` variant that drops id from output.

9 years agocompiletest: extend syntax with support for choosing same line as previous line.
Felix S. Klock II [Tue, 7 Oct 2014 16:30:35 +0000 (18:30 +0200)]
compiletest: extend syntax with support for choosing same line as previous line.

9 years agoauto merge of #19248 : japaric/rust/str, r=alexcrichton
bors [Mon, 24 Nov 2014 11:56:34 +0000 (11:56 +0000)]
auto merge of #19248 : japaric/rust/str, r=alexcrichton

Just like we do with AsSlice

This comes in handy when dealing with iterator-centric APIs (`IntoIterator`!) and you want to receive an `Iterator<S> where S: Str` argument. Without this PR, e.g. you can't receive `&["a", "b"].iter()` instead you'll have to type `&["a", "b"].iter().map(|&x| x)` (A similar thing happens with `&[String]`).

r? @aturon

Full disclaimer: I haven't run `make`/`make check` yet (All my cores are busy)

9 years agoauto merge of #19094 : alexcrichton/rust/rm-std-local-data, r=aturon
bors [Mon, 24 Nov 2014 09:56:34 +0000 (09:56 +0000)]
auto merge of #19094 : alexcrichton/rust/rm-std-local-data, r=aturon

This commit removes the `std::local_data` module in favor of a new `std::thread_local`
module providing thread local storage. The module provides two variants of TLS:
one which owns its contents and one which is based on scoped references. Each
implementation has pros and cons listed in the documentation.

Both flavors have accessors through a function called `with` which yield a
reference to a closure provided. Both flavors also panic if a reference cannot
be yielded and provide a function to test whether an access would panic or not.
This is an implementation of [RFC 461][rfc] and full details can be found in
that RFC.

This is a breaking change due to the removal of the `std::local_data` module.
All users can migrate to the new tls system like so:

    thread_local!(static FOO: Rc<RefCell<Option<T>>> = Rc::new(RefCell::new(None)))

The old `local_data` module inherently contained the `Rc<RefCell<Option<T>>>` as
an implementation detail which must now be explicitly stated by users.

[rfc]: https://github.com/rust-lang/rfcs/pull/461
[breaking-change]

9 years agoauto merge of #19236 : csouth3/rust/master, r=Gankro
bors [Mon, 24 Nov 2014 07:51:32 +0000 (07:51 +0000)]
auto merge of #19236 : csouth3/rust/master, r=Gankro

Whilst browsing the source for BinaryHeap, I saw a FIXME for implementing into_iter.  I think, since the BinaryHeap is represented internally using just a Vec, just calling into_iter() on the BinaryHeap's data should be sufficient to do what we want here.  If this actually isn't the right approach (e.g., I should write a struct MoveItems and appropriate implementation for BinaryHeap instead), let me know and I'll happily rework this.

Both of the tests that I have added pass.  This is my first contribution to Rust, so please let me know any ways I can improve this PR!

9 years agostd: Add a new top-level thread_local module
Alex Crichton [Fri, 14 Nov 2014 22:20:57 +0000 (14:20 -0800)]
std: Add a new top-level thread_local module

This commit removes the `std::local_data` module in favor of a new
`std::thread_local` module providing thread local storage. The module provides
two variants of TLS: one which owns its contents and one which is based on
scoped references. Each implementation has pros and cons listed in the
documentation.

Both flavors have accessors through a function called `with` which yield a
reference to a closure provided. Both flavors also panic if a reference cannot
be yielded and provide a function to test whether an access would panic or not.
This is an implementation of [RFC 461][rfc] and full details can be found in
that RFC.

This is a breaking change due to the removal of the `std::local_data` module.
All users can migrate to the new thread local system like so:

    thread_local!(static FOO: Rc<RefCell<Option<T>>> = Rc::new(RefCell::new(None)))

The old `local_data` module inherently contained the `Rc<RefCell<Option<T>>>` as
an implementation detail which must now be explicitly stated by users.

[rfc]: https://github.com/rust-lang/rfcs/pull/461
[breaking-change]

9 years agoauto merge of #19223 : reem/rust/any-typeid-unstable, r=aturon
bors [Mon, 24 Nov 2014 02:56:35 +0000 (02:56 +0000)]
auto merge of #19223 : reem/rust/any-typeid-unstable, r=aturon

It is likely going to be removed and replaced
with an associated static.

9 years agosave-analysis: two minor bugs
Nick Cameron [Mon, 24 Nov 2014 01:10:16 +0000 (14:10 +1300)]
save-analysis: two minor bugs

9 years agoauto merge of #19192 : nodakai/rust/generalize-strvector, r=alexcrichton
bors [Mon, 24 Nov 2014 00:46:30 +0000 (00:46 +0000)]
auto merge of #19192 : nodakai/rust/generalize-strvector, r=alexcrichton

A single impl supports all of `[T]`, `Vec<T>` and `CVec<T>`.

Once `Iterable` is implemented, we will prefer it to `SlicePrelude`.
But the `with_capacity()` part might become tricky.

9 years agoImplement into_iter() for BinaryHeap.
Chase Southwood [Sun, 23 Nov 2014 06:31:40 +0000 (00:31 -0600)]
Implement into_iter() for BinaryHeap.

9 years agoRename unwrap functions to into_inner
Alex Crichton [Thu, 20 Nov 2014 17:23:43 +0000 (09:23 -0800)]
Rename unwrap functions to into_inner

This change applies the conventions to unwrap listed in [RFC 430][rfc] to rename
non-failing `unwrap` methods to `into_inner`. This is a breaking change, but all
`unwrap` methods are retained as `#[deprecated]` for the near future. To update
code rename `unwrap` method calls to `into_inner`.

[rfc]: https://github.com/rust-lang/rfcs/pull/430
[breaking-change]

Closes #13159
cc #19091

9 years agoauto merge of #19246 : frewsxcv/rust/json-cleanup, r=jakub-
bors [Sun, 23 Nov 2014 22:36:33 +0000 (22:36 +0000)]
auto merge of #19246 : frewsxcv/rust/json-cleanup, r=jakub-

Was looking through the JSON code and cleaned parts of it up

9 years agoauto merge of #19242 : jakub-/rust/roll-up, r=jakub-
bors [Sun, 23 Nov 2014 20:26:58 +0000 (20:26 +0000)]
auto merge of #19242 : jakub-/rust/roll-up, r=jakub-

9 years agoFixes to the roll-up
Jakub Bukaj [Sun, 23 Nov 2014 15:47:25 +0000 (10:47 -0500)]
Fixes to the roll-up

9 years agorollup merge of #19239: jauhien/fix-libdir
Jakub Bukaj [Sun, 23 Nov 2014 19:12:03 +0000 (14:12 -0500)]
rollup merge of #19239: jauhien/fix-libdir

A fix for a windows problem pointed by @retep998 in the PR #16552.

9 years agorollup merge of #19234: P1start/rustdoc-misc
Jakub Bukaj [Sun, 23 Nov 2014 19:12:01 +0000 (14:12 -0500)]
rollup merge of #19234: P1start/rustdoc-misc

This PR:

- makes rustdoc colour trait methods like other functions in search results;
- makes rustdoc display `extern crate` statements with the new `as` syntax instead of the old `=` syntax;
- changes rustdoc to list constants and statics in a way that is more similar to functions and modules and show their full definition and documentation on their own page, fixing #19046:

  ![Constant listing](https://i.imgur.com/L4ZTOCN.png)

  ![Constant page](https://i.imgur.com/RcjZfCv.png)

9 years agorollup merge of #19232: nicholasbishop/bishop_fix_result_typo
Jakub Bukaj [Sun, 23 Nov 2014 19:12:00 +0000 (14:12 -0500)]
rollup merge of #19232: nicholasbishop/bishop_fix_result_typo

9 years agorollup merge of #19230: nick29581/dxr-values
Jakub Bukaj [Sun, 23 Nov 2014 19:11:59 +0000 (14:11 -0500)]
rollup merge of #19230: nick29581/dxr-values

r?

9 years agorollup merge of #19225: reem/any-unnecessary-transmute-copy
Jakub Bukaj [Sun, 23 Nov 2014 19:11:58 +0000 (14:11 -0500)]
rollup merge of #19225: reem/any-unnecessary-transmute-copy

transmute_copy is no longer needed and is just slow.

9 years agorollup merge of #19215: aochagavia/pretty
Jakub Bukaj [Sun, 23 Nov 2014 19:11:57 +0000 (14:11 -0500)]
rollup merge of #19215: aochagavia/pretty

Closes https://github.com/rust-lang/rust/issues/19077

I would appreciate any guidance on how to write a test for this. I saw some examples in `test/pretty`, but there are different ways to test... With or without `.pp` files, with a `pp-exact` comment, etc.

9 years agorollup merge of #19211: aochagavia/tuple-index
Jakub Bukaj [Sun, 23 Nov 2014 19:11:56 +0000 (14:11 -0500)]
rollup merge of #19211: aochagavia/tuple-index

This breaks code like

```
let t = (42i, 42i);
... t.0::<int> ...;
```

Change this code to not contain an unused type parameter. For example:

```
let t = (42i, 42i);
... t.0 ...;
```

Closes https://github.com/rust-lang/rust/issues/19096

[breaking-change]

r? @aturon

9 years agorollup merge of #19210: petrochenkov/master
Jakub Bukaj [Sun, 23 Nov 2014 19:11:55 +0000 (14:11 -0500)]
rollup merge of #19210: petrochenkov/master

Now `std::hash::hash("abcd")` works.

9 years agorollup merge of #19205: jashank/docs-fix
Jakub Bukaj [Sun, 23 Nov 2014 19:11:54 +0000 (14:11 -0500)]
rollup merge of #19205: jashank/docs-fix

Catch a missed triple-slash in the docs for `std::os::args()`. Passes `make check`. (I've also eyeballed the rest of `libstd` with the aid of some funky regexes and haven't found anything similar.)

9 years agorollup merge of #19204: mcpherrinm/master
Jakub Bukaj [Sun, 23 Nov 2014 19:11:53 +0000 (14:11 -0500)]
rollup merge of #19204: mcpherrinm/master

The old name was sensible when this module was PriorityQueue but isn't
anymore.

9 years agorollup merge of #19198: alexcrichton/snapshots
Jakub Bukaj [Sun, 23 Nov 2014 19:11:52 +0000 (14:11 -0500)]
rollup merge of #19198: alexcrichton/snapshots

Primarily including the libnative removal

9 years agorollup merge of #19194: aturon/stab-ascii
Jakub Bukaj [Sun, 23 Nov 2014 19:11:51 +0000 (14:11 -0500)]
rollup merge of #19194: aturon/stab-ascii

This is an initial API stabilization pass for `std::ascii`. Aside from
some renaming to match conversion conventions, and deprecations in favor
of using iterators directly, almost nothing is changed here. However,
the static case conversion tables that were previously public are now private.

The stabilization of the (rather large!) set of extension traits is left
to a follow-up pass, because we hope to land some more general machinery
that will provide the same functionality without custom traits.

[breaking-change]

9 years agorollup merge of #19193: scialex/rc-counts
Jakub Bukaj [Sun, 23 Nov 2014 19:11:50 +0000 (14:11 -0500)]
rollup merge of #19193: scialex/rc-counts

These functions allow you to see how many weak and strong references
there are to an `Arc`, `Rc`, or an `rc::Weak`. Due to the design of
`Arc` it is not possible to get the number of weak references of an
arbitrary `arc::Weak`. Look in `arc.rs` for a more in-depth explanation.

On `arc::Arc` and `arc::Weak` these operations are wait-free and atomic.

This sort of information is useful for creating dynamically cleared caches for use in OS development, for example holding pages of files in memory until the address space is needed for something else.

9 years agorollup merge of #19184: Gekkio/fix-binary-format-char
Jakub Bukaj [Sun, 23 Nov 2014 19:11:49 +0000 (14:11 -0500)]
rollup merge of #19184: Gekkio/fix-binary-format-char

This small piece of documentation was missed in the format character change
in 4af3494bb02e80badc978faa65e59625ade0c675.

9 years agorollup merge of #19166: richo/lldb-cleanups
Jakub Bukaj [Sun, 23 Nov 2014 19:11:48 +0000 (14:11 -0500)]
rollup merge of #19166: richo/lldb-cleanups

While poking at rust in lldb I found a few nits to clean up.

9 years agorollup merge of #19161: jmesmon/mk-fixes
Jakub Bukaj [Sun, 23 Nov 2014 19:11:47 +0000 (14:11 -0500)]
rollup merge of #19161: jmesmon/mk-fixes

This is a collection of misc issues I've run into while adding bindir & libdir support that aren't really bindir & libdir specific.

While I continue to fiddle with bindir and libdir bugs, I figured these might be useful for others to have merged.

9 years agoRequire <T: Send> for AtomicOption
Keegan McAllister [Sun, 23 Nov 2014 18:21:47 +0000 (10:21 -0800)]
Require <T: Send> for AtomicOption

Fixes #19247.

9 years agoDSTify Str + impl Str for &S where S: Str
Jorge Aparicio [Sun, 23 Nov 2014 18:13:17 +0000 (13:13 -0500)]
DSTify Str + impl Str for &S where S: Str

9 years agoClean up some logic/formatting in JSON module
Corey Farwell [Sun, 23 Nov 2014 17:08:11 +0000 (12:08 -0500)]
Clean up some logic/formatting in JSON module

9 years agoauto merge of #19150 : Manishearth/rust/find-doc, r=Gankro
bors [Sun, 23 Nov 2014 15:46:56 +0000 (15:46 +0000)]
auto merge of #19150 : Manishearth/rust/find-doc, r=Gankro

It's useful to know this (opens up a bunch of other opportunities especially whilst parsing)

9 years agofix for PR#16552 implementation on windows: CFG_LIBDIR should be always set in config...
Jauhien Piatlicki [Sun, 23 Nov 2014 14:36:36 +0000 (15:36 +0100)]
fix for PR#16552 implementation on windows: CFG_LIBDIR should be always set in configure variables

9 years agoauto merge of #18140 : JelteF/rust-1/guide-fix, r=cmr
bors [Sun, 23 Nov 2014 13:51:47 +0000 (13:51 +0000)]
auto merge of #18140 : JelteF/rust-1/guide-fix, r=cmr

The reason given didn't make any sense when I read it when reading through the docs. I think this is more clear. Please let me know it is also more correct.

9 years agoFix the reason for calling a file lib.rs
Jelte Fennema [Sun, 23 Nov 2014 13:43:22 +0000 (14:43 +0100)]
Fix the reason for calling a file lib.rs

9 years agoSearch for implemented kinds recursively on Trait types. Fixes #15155 and #13155.
Ricky Taylor [Sun, 16 Nov 2014 18:20:19 +0000 (18:20 +0000)]
Search for implemented kinds recursively on Trait types. Fixes #15155 and #13155.

9 years agolibcollection: generalize StrVector to AsSlice<Str>.
NODA, Kai [Sun, 23 Nov 2014 11:37:33 +0000 (19:37 +0800)]
libcollection: generalize StrVector to AsSlice<Str>.

The impl for [T] also works as impl for slices in general.
By generalizing the impl of StrVector for Vec<Str> to that for
AsSlice<Str>, it becomes much more generic.

Once Iterable is implemented, we will prefer it to AsSlice.
But the with_capacity() part might become tricky.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
9 years agoAdd test
Adolfo Ochagavía [Sun, 23 Nov 2014 11:27:10 +0000 (12:27 +0100)]
Add test

9 years agoauto merge of #19158 : jakub-/rust/issue-14091, r=alexcrichton
bors [Sun, 23 Nov 2014 11:51:50 +0000 (11:51 +0000)]
auto merge of #19158 : jakub-/rust/issue-14091, r=alexcrichton

Closes #14091.
Closes #19195.

9 years agoRemove type parameters from ExprField and ExprTupField
Adolfo Ochagavía [Sun, 23 Nov 2014 11:14:35 +0000 (12:14 +0100)]
Remove type parameters from ExprField and ExprTupField

9 years agolibsyntax: Forbid type parameters in tuple indices
Adolfo Ochagavía [Sat, 22 Nov 2014 15:02:49 +0000 (16:02 +0100)]
libsyntax: Forbid type parameters in tuple indices

This breaks code like

```
let t = (42i, 42i);
... t.0::<int> ...;
```

Change this code to not contain an unused type parameter. For example:

```
let t = (42i, 42i);
... t.0 ...;
```

Closes https://github.com/rust-lang/rust/issues/19096

[breaking-change]

9 years agoauto merge of #19157 : aturon/rust/cow-doc, r=alexcrichton
bors [Sun, 23 Nov 2014 09:51:49 +0000 (09:51 +0000)]
auto merge of #19157 : aturon/rust/cow-doc, r=alexcrichton

This commit makes `Cow` more usable by allowing it to be applied to
unsized types (as was intended) and providing some basic `ToOwned`
implementations on slice types. It also corrects the documentation for
`Cow` to no longer mention `DerefMut`, and adds an example.

Closes #19123

9 years agoauto merge of #18856 : ruud-v-a/rust/fatptrs, r=cmr
bors [Sun, 23 Nov 2014 07:51:51 +0000 (07:51 +0000)]
auto merge of #18856 : ruud-v-a/rust/fatptrs, r=cmr

This merges the `trt_field_*`, `fn_field_*` and `slice_elt_*` constants into two `fat_ptr_*` constants. This resolves the first part of #18590.

9 years agoauto merge of #19152 : alexcrichton/rust/issue-17863, r=aturon
bors [Sun, 23 Nov 2014 05:46:52 +0000 (05:46 +0000)]
auto merge of #19152 : alexcrichton/rust/issue-17863, r=aturon

This commit is an implementation of [RFC 240][rfc] when applied to the standard
library. It primarily deprecates the entirety of `string::raw`, `vec::raw`,
`slice::raw`, and `str::raw` in favor of associated functions, methods, and
other free functions. The detailed renaming is:

* slice::raw::buf_as_slice => slice::from_raw_buf
* slice::raw::mut_buf_as_slice => slice::from_raw_mut_buf
* slice::shift_ptr => deprecated with no replacement
* slice::pop_ptr => deprecated with no replacement
* str::raw::from_utf8 => str::from_utf8_unchecked
* str::raw::c_str_to_static_slice => str::from_c_str
* str::raw::slice_bytes => deprecated for slice_unchecked (slight semantic diff)
* str::raw::slice_unchecked => str.slice_unchecked
* string::raw::from_parts => String::from_raw_parts
* string::raw::from_buf_len => String::from_raw_buf_len
* string::raw::from_buf => String::from_raw_buf
* string::raw::from_utf8 => String::from_utf8_unchecked
* vec::raw::from_buf => Vec::from_raw_buf

All previous functions exist in their `#[deprecated]` form, and the deprecation
messages indicate how to migrate to the newer variants.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0240-unsafe-api-location.md
[breaking-change]

Closes #17863

9 years agoChange how rustdoc shows constants and statics to be more similar to other items
P1start [Sat, 22 Nov 2014 07:48:55 +0000 (20:48 +1300)]
Change how rustdoc shows constants and statics to be more similar to other items

Fixes #19046.

9 years agoMake rustdoc display `extern crate` statements correctly
P1start [Sat, 22 Nov 2014 06:07:54 +0000 (19:07 +1300)]
Make rustdoc display `extern crate` statements correctly

9 years agoHighlight trait methods in rustdoc’s search results
P1start [Sat, 22 Nov 2014 05:36:02 +0000 (18:36 +1300)]
Highlight trait methods in rustdoc’s search results

9 years agoFix typo in Result documentation
Nicholas Bishop [Sun, 23 Nov 2014 03:13:00 +0000 (22:13 -0500)]
Fix typo in Result documentation

9 years agoauto merge of #19146 : gereeter/rust/reference-borrow, r=aturon
bors [Sun, 23 Nov 2014 02:36:46 +0000 (02:36 +0000)]
auto merge of #19146 : gereeter/rust/reference-borrow, r=aturon

This should be a more general version of #19131.

9 years agosave-analysis: add values for types
Nick Cameron [Sun, 23 Nov 2014 01:57:26 +0000 (14:57 +1300)]
save-analysis: add values for types

9 years agosave-analysis: emit a type for enum variants
Nick Cameron [Sun, 23 Nov 2014 01:39:59 +0000 (14:39 +1300)]
save-analysis: emit a type for enum variants

9 years agoauto merge of #19137 : tbu-/rust/pr_refcell_unsafety, r=huonw
bors [Sun, 23 Nov 2014 00:36:43 +0000 (00:36 +0000)]
auto merge of #19137 : tbu-/rust/pr_refcell_unsafety, r=huonw

9 years agoAny: use plain transmute instead of transmute_copy for downcasting.
Jonathan Reem [Sun, 23 Nov 2014 00:06:21 +0000 (16:06 -0800)]
Any: use plain transmute instead of transmute_copy for downcasting.

transmute_copy is no longer needed and is just slow.