Commit Graph

34499 Commits

Author SHA1 Message Date
Ulysse Carion
6cb03baffa Fix formatting of the pointers guide. 2014-11-25 16:32:53 -08:00
bors
0e06f71747 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.)
2014-11-25 15:48:05 +00:00
Felix S. Klock II
5fbe0cac7c 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.
2014-11-25 15:26:16 +01:00
Felix S. Klock II
c9a1c376fc 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.
2014-11-25 15:26:16 +01:00
Felix S. Klock II
21fe017ab0 Check other fields are consistent in LoanPath::common. 2014-11-25 15:26:16 +01:00
Felix S. Klock II
09d67fd777 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.
2014-11-25 15:26:16 +01:00
Felix S. Klock II
6f7cb8c618 Override LoanPath Eq impl to enforce invariant: eq lp's always have eq types. 2014-11-25 15:26:16 +01:00
Felix S. Klock II
1217b829e8 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.
2014-11-25 15:26:16 +01:00
Felix S. Klock II
91b88c54c2 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.
2014-11-25 15:26:15 +01:00
Felix S. Klock II
d6c8f3b726 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.)
2014-11-25 15:25:55 +01:00
bors
48ca6d1840 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
2014-11-25 13:46:45 +00:00
bors
2264049577 auto merge of #19172 : alfie/rust/impl-traitless, r=steveklabnik
An example of how implementations work without traits would be handy
2014-11-25 11:46:39 +00:00
bors
f6cb58caee 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
2014-11-25 09:21:45 +00:00
bors
0c1d853fba 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
2014-11-25 06:51:38 +00:00
Huon Wilson
b86a7808c7 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`.
2014-11-25 17:10:32 +11:00
bors
5f9741e62d 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
2014-11-25 01:06:41 +00:00
Alex Crichton
a4b1ac5447 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
2014-11-24 15:24:29 -08:00
bors
5acb97ae76 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.
2014-11-24 23:06:45 +00:00
bors
7222ba9650 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
2014-11-24 21:02:33 +00:00
Steve Klabnik
534fd3a983 Don't call drop in tcpstream docs
This suggests that you must call it, which is normally not what you want to do.
2014-11-24 15:22:55 -05:00
bors
54c628cb84 auto merge of #19258 : nick29581/rust/dxr-minor, r=brson
r?
2014-11-24 16:07:00 +00:00
bors
377d7524a8 auto merge of #19250 : kmcallister/rust/atomicoption, r=alexcrichton
Fixes #19247.
2014-11-24 13:56:36 +00:00
Tom Jakubowski
de94f0affb rustdoc: render ast::QPath
Fix #18594
2014-11-24 05:23:10 -08:00
Tom Jakubowski
dd4c7c00d8 rustdoc: Render associated types on traits and impls 2014-11-24 05:23:10 -08:00
Felix S. Klock II
e31fc9dd4f Add node_to_user_string, node_to_string variant that drops id from output. 2014-11-24 13:19:26 +01:00
Felix S. Klock II
f5b795dc82 compiletest: extend syntax with support for choosing same line as previous line. 2014-11-24 13:19:26 +01:00
bors
4334d3c196 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)
2014-11-24 11:56:34 +00:00
bors
bad1062caa 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]
2014-11-24 09:56:34 +00:00
bors
f5b92b4b7a 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!
2014-11-24 07:51:32 +00:00
Alex Crichton
a9c1152c4b 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]
2014-11-23 23:37:16 -08:00
bors
c637cab853 auto merge of #19223 : reem/rust/any-typeid-unstable, r=aturon
It is likely going to be removed and replaced
with an associated static.
2014-11-24 02:56:35 +00:00
Nick Cameron
bbe1a9b9c1 save-analysis: two minor bugs 2014-11-24 14:10:16 +13:00
bors
395901393c 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.
2014-11-24 00:46:30 +00:00
Chase Southwood
3f8e2690be Implement into_iter() for BinaryHeap. 2014-11-23 18:05:41 -06:00
Alex Crichton
f1f6c1286f 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
2014-11-23 15:26:53 -08:00
bors
2eed1ddbea auto merge of #19246 : frewsxcv/rust/json-cleanup, r=jakub-
Was looking through the JSON code and cleaned parts of it up
2014-11-23 22:36:33 +00:00
bors
4e5259503c auto merge of #19242 : jakub-/rust/roll-up, r=jakub- 2014-11-23 20:26:58 +00:00
Jakub Bukaj
d6b023a467 Fixes to the roll-up 2014-11-23 15:23:39 -05:00
Jakub Bukaj
69a217f37c rollup merge of #19239: jauhien/fix-libdir
A fix for a windows problem pointed by @retep998 in the PR #16552.
2014-11-23 14:12:03 -05:00
Jakub Bukaj
593af6213f 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)
2014-11-23 14:12:01 -05:00
Jakub Bukaj
e9fcfe6a91 rollup merge of #19232: nicholasbishop/bishop_fix_result_typo 2014-11-23 14:12:00 -05:00
Jakub Bukaj
34ab1544e2 rollup merge of #19230: nick29581/dxr-values
r?
2014-11-23 14:11:59 -05:00
Jakub Bukaj
11700cb1d4 rollup merge of #19225: reem/any-unnecessary-transmute-copy
transmute_copy is no longer needed and is just slow.
2014-11-23 14:11:58 -05:00
Jakub Bukaj
4dbd6574b0 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.
2014-11-23 14:11:57 -05:00
Jakub Bukaj
3594c588bb 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
2014-11-23 14:11:56 -05:00
Jakub Bukaj
5ad1512850 rollup merge of #19210: petrochenkov/master
Now `std:#️⃣:hash("abcd")` works.
2014-11-23 14:11:55 -05:00
Jakub Bukaj
072015ee3d 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.)
2014-11-23 14:11:54 -05:00
Jakub Bukaj
9d721180f2 rollup merge of #19204: mcpherrinm/master
The old name was sensible when this module was PriorityQueue but isn't
anymore.
2014-11-23 14:11:53 -05:00
Jakub Bukaj
7b2122b966 rollup merge of #19198: alexcrichton/snapshots
Primarily including the libnative removal
2014-11-23 14:11:52 -05:00
Jakub Bukaj
b21b48062f 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]
2014-11-23 14:11:51 -05:00