Commit Graph

31631 Commits

Author SHA1 Message Date
bors
a8c8e3f80f auto merge of #16286 : pcwalton/rust/associated-items-groundwork, r=nikomatsakis
methods.

This paves the way to associated items by introducing an extra level of
abstraction ("impl-or-trait item") between traits/implementations and
methods. This new abstraction is encoded in the metadata and used
throughout the compiler where appropriate.

There are no functional changes; this is purely a refactoring.

r? @nick29581
2014-08-14 19:11:18 +00:00
Patrick Walton
9907fa4acc librustc: Stop assuming that implementations and traits only contain
methods.

This paves the way to associated items by introducing an extra level of
abstraction ("impl-or-trait item") between traits/implementations and
methods. This new abstraction is encoded in the metadata and used
throughout the compiler where appropriate.

There are no functional changes; this is purely a refactoring.
2014-08-14 11:40:22 -07:00
bors
404978ea72 auto merge of #16122 : pcwalton/rust/lifetimes-in-unboxed-closures, r=pnkfelix
This patch primarily does two things: (1) it prevents lifetimes from
leaking out of unboxed closures; (2) it allows unboxed closure type
notation, call notation, and construction notation to construct closures
matching any of the three traits.

This breaks code that looked like:

    let mut f;
    {
        let x = &5i;
        f = |&mut:| *x + 10;
    }

Change this code to avoid having a reference escape. For example:

    {
        let x = &5i;
        let mut f; // <-- move here to avoid dangling reference
        f = |&mut:| *x + 10;
    }

I believe this is enough to consider unboxed closures essentially
implemented. Further issues (for example, higher-rank lifetimes) should
be filed as followups.

Closes #14449.

[breaking-change]

r? @pnkfelix
2014-08-14 16:36:19 +00:00
Patrick Walton
8d27232141 librustc: Tie up loose ends in unboxed closures.
This patch primarily does two things: (1) it prevents lifetimes from
leaking out of unboxed closures; (2) it allows unboxed closure type
notation, call notation, and construction notation to construct closures
matching any of the three traits.

This breaks code that looked like:

    let mut f;
    {
        let x = &5i;
        f = |&mut:| *x + 10;
    }

Change this code to avoid having a reference escape. For example:

    {
        let x = &5i;
        let mut f; // <-- move here to avoid dangling reference
        f = |&mut:| *x + 10;
    }

I believe this is enough to consider unboxed closures essentially
implemented. Further issues (for example, higher-rank lifetimes) should
be filed as followups.

Closes #14449.

[breaking-change]
2014-08-14 08:53:25 -07:00
bors
56b86aaf35 auto merge of #16484 : dotdash/rust/empty_struct_wrapper_arg, r=luqmana
Fixes #16441.
2014-08-14 14:51:19 +00:00
bors
e99eeb574e auto merge of #16470 : liigo/rust/rename-private-cmp-macros, r=brson
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-14 13:01:18 +00:00
bors
320c35ee34 auto merge of #16444 : steveklabnik/rust/fix_boxes_in_manual, r=brson
Fixes #16439
2014-08-14 11:16:19 +00:00
Jonas Hietala
0f40cf1f59 Add a test for complex divide by zero. 2014-08-14 13:07:35 +02:00
Felix S. Klock II
43c326ef6b Followup to PR #16477: a run-pass regression test for Issue #15750. 2014-08-14 11:55:47 +02:00
bors
32098bbb0d auto merge of #16440 : bheesham/rust/master, r=brson
* `rust.md`: changes for consistency

  * `guide-ffi.md`: wrapped inline code

NOTE: This is a duplicate of #16375. I completely messed up that fork, so I made a new fork.
2014-08-14 09:31:19 +00:00
Vadim Chugunov
88c27e099f Make it pass the pretty-printer test. 2014-08-14 01:55:51 -07:00
bors
259e806db6 auto merge of #16428 : mdinger/rust/sort_attributes, r=cmr
Targetting at fixing most of #16414.

Sorts these alphabetically:
* [Crate-only attributes](http://doc.rust-lang.org/rust.html#crate-only-attributes)
* [Function-only attributes](http://doc.rust-lang.org/rust.html#function-only-attributes)
* [Miscellaneous attributes](http://doc.rust-lang.org/rust.html#miscellaneous-attributes)
* [Lint check attributes](http://doc.rust-lang.org/rust.html#lint-check-attributes)
* [Built-in Traits](http://doc.rust-lang.org/rust.html#built-in-traits)
* [Types](http://doc.rust-lang.org/rust.html#types)
* [Deriving](http://doc.rust-lang.org/rust.html#deriving)
* [Compiler Features](http://doc.rust-lang.org/rust.html#compiler-features)

Doesn't modify these:
* [Operators](http://doc.rust-lang.org/rust.html#operators): An alternative sorting is unclear.
* [Marker types](http://doc.rust-lang.org/rust.html#marker-types): Could be sorted but uncertain how. See below.
* [Stability](http://doc.rust-lang.org/rust.html#stability): Already sorted by stability

---

[Marker types](http://doc.rust-lang.org/rust.html#marker-types) has an extra newline above `fail_` which may throw off formatting (see #16412) or it may be for some other reason. If the newline is just a typo, I can just remove it and format this alphabetically like so:
```rust
// Sorted alphabetically
a_bread
b_bread
c_bread
fail_
fail_bounds_check
a_type
b_type
c_type
```

Marker types is listed as likely to become out of date so I don't know if this is worth doing anyway.

[EDIT] modified `Marker types` now and tried to update the language items list.
2014-08-14 07:41:20 +00:00
bors
385c39a77b auto merge of #16332 : brson/rust/slicestab, r=aturon
This implements some of the recommendations from https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md.

Explanation in commits.
2014-08-14 05:36:25 +00:00
bors
9d45d63d0d auto merge of #15929 : pcwalton/rust/by-ref-closures, r=alexcrichton
by-reference upvars.

This partially implements RFC 38. A snapshot will be needed to turn this
on, because stage0 cannot yet parse the keyword.

Part of #12831.

r? @alexcrichton
2014-08-14 03:46:22 +00:00
bors
aa98b25c4f auto merge of #16477 : pnkfelix/rust/fsk-quotstx, r=brson
quote_expr macro: embed Ident using special encoding that retains hygiene state.

Fix #15750, #15962
2014-08-14 01:56:26 +00:00
Patrick Walton
a63003fe1a librustc: Parse, but do not fully turn on, the ref keyword for
by-reference upvars.

This partially implements RFC 38. A snapshot will be needed to turn this
on, because stage0 cannot yet parse the keyword.

Part of #12381.
2014-08-13 18:09:14 -07:00
Brian Anderson
fce442e75c Fix test fallout 2014-08-13 17:11:21 -07:00
Kevin Ballard
05e45b9e36 vim: Stop setting conceallevel in the syntax file
We shouldn't be setting conceallevel in the syntax file. Besides not
being able to undo this if we switch to another syntax later, it also
interferes with embedding rust in other filetypes (such as markdown).

Instead, set it in the ftplugin, where it belongs.
2014-08-13 16:52:26 -07:00
bors
28b5e4588f auto merge of #15934 : brson/rust/dur, r=aturon
Currently, the Timer methods take an integer number of ms. This is considered a bug because a) types, b) some timers have ns precision.

This plucks the `Duration` type from [rust-chrono](https://github.com/lifthrasiir/rust-chrono), plops it into `std::time`,  and replaces the arguments to `sleep`, `oneshot`, and `periodic` timers with it. It leaves the old methods intact as `sleep_ms`, `oneshot_ms`, and `periodic_ms`, for convenience.

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

cc @lifthrasiir @aturon @kballard @alexcrichton
2014-08-13 23:11:28 +00:00
Brian Anderson
c3b9d5df62 Address some review feedback 2014-08-13 15:27:40 -07:00
Brian Anderson
bc450b17e3 core: Change the argument order on splitn and rsplitn for strs.
This makes it consistent with the same functions for slices,
and allows the search closure to be specified last.

[breaking-change]
2014-08-13 15:27:37 -07:00
Brian Anderson
4e1024f8d3 core: Put stability attributes all over the slice module
Much of this is as discussed[1]. Many things are marked

[1]: https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-06.md
2014-08-13 15:27:34 -07:00
Brian Anderson
075256a070 Fix test fallout 2014-08-13 15:26:48 -07:00
Björn Steinbrink
4df0430da0 Fix handling of ignored arguments in FFI wrappers for rust functions
Fixes #16441.
2014-08-14 00:18:38 +02:00
mdinger
c69f7a9234 Sort Marker types and add missing language items 2014-08-13 18:11:10 -04:00
bors
0f09f51c61 auto merge of #16438 : phi-gamma/rust/doc-fixes, r=brson
Fixes wording in the *runtime*, *testing* and *unsafe* guides.
2014-08-13 21:26:28 +00:00
Matej Lach
bede9ecdfe Introduce the cargo run command earlier (squashed) 2014-08-13 20:26:18 +01:00
bors
86ecfa491f auto merge of #16476 : andreastt/rust/ato/consistency_if_expr_example, r=steveklabnik 2014-08-13 18:36:27 +00:00
Brian Anderson
02e39b05c6 Add a fixme about Duration representation 2014-08-13 11:31:48 -07:00
Brian Anderson
49a40d8ad1 Update docs 2014-08-13 11:31:48 -07:00
Brian Anderson
31281b4bd1 std: Fix build errors 2014-08-13 11:31:48 -07:00
Brian Anderson
500b600362 std: Remove Duration::new/new_opt/to_tuple
These all expose the underlying data representation and are
not the most convenient way of instantiation anyway.
2014-08-13 11:31:48 -07:00
Brian Anderson
c6b02f6558 std: Improve Duration comments 2014-08-13 11:31:48 -07:00
Brian Anderson
ee10f3501c std: Make connect_timeout return Err on zero duration
[breaking-change]
2014-08-13 11:31:48 -07:00
Brian Anderson
a391934ba8 Fix various fallout from timer changes 2014-08-13 11:31:48 -07:00
Brian Anderson
80d32438d6 Fix compiletest to use Duration 2014-08-13 11:31:48 -07:00
Brian Anderson
77cdaf018c std: Refactor time module a bit
Put `Duration` in `time::duration`, where the two constants can
be called just `MAX` and `MIN`. Reexport from `time`.
This provides more room for the time module to expand.
2014-08-13 11:31:48 -07:00
Brian Anderson
4475e6a095 std: connect_timeout requires a positive Duration
This is only breaking if you were previously specifying a duration
of zero for some mysterious reason.

[breaking-change]
2014-08-13 11:31:48 -07:00
Brian Anderson
9fdcddb317 std: Make the TCP/UDP connect_timeout methods take Duration
[breaking-change]
2014-08-13 11:31:48 -07:00
Brian Anderson
63cd4acf53 std: Clarify what timers do with zero and negative durations
Add tests. Also fix a bunch of broken time tests.
2014-08-13 11:31:47 -07:00
Brian Anderson
734834c7d6 std: Restore missing timer examples 2014-08-13 11:31:47 -07:00
Brian Anderson
8a5fe8655a std: Remove the zero constructor from Duration
This is a workaround for having to write `Zero::zero` and will
be solved at the language level someday.
2014-08-13 11:31:47 -07:00
Brian Anderson
1666dabcbc std: Remove ms-taking methods from timers 2014-08-13 11:31:47 -07:00
Brian Anderson
51e9728292 std: Change time::MAX to time::MAX_DURATION, etc. 2014-08-13 11:31:47 -07:00
Brian Anderson
6cb2093f74 std: Update Duration from upstream
From rust-chrono 4f34003e03e259bd5cbda0cb4d35325861307cc6
2014-08-13 11:31:47 -07:00
Brian Anderson
18f75a9197 std: Add comments to the time module 2014-08-13 11:31:47 -07:00
Brian Anderson
dc8b23bc1f std: Add sleep, oneshot and periodic timers, taking Duration 2014-08-13 11:31:47 -07:00
Brian Anderson
657b679b15 std: Rename sleep, periodic, and oneshot timers to sleep_ms, etc.
Rename io::timer::sleep, Timer::sleep, Timer::oneshot,
Timer::periodic, to sleep_ms, oneshot_ms, periodic_ms. These functions
all take an integer and interpret it as milliseconds.

Replacement functions will be added that take Duration.

[breaking-change]
2014-08-13 11:31:47 -07:00
Brian Anderson
5778ed4c92 std: Add a Duration type
Taken from rust-chrono[1]. Needed for timers per #11189.
Experimental.

[1]: https://github.com/lifthrasiir/rust-chrono
2014-08-13 11:31:47 -07:00
Brian Anderson
a4b354ca02 core: Add binary_search and binary_search_elem methods to slices.
These are like the existing bsearch methods but if the search fails,
it returns the next insertion point.

The new `binary_search` returns a `BinarySearchResult` that is either
`Found` or `NotFound`. For convenience, the `found` and `not_found`
methods convert to `Option`, ala `Result`.

Deprecate bsearch and bsearch_elem.
2014-08-13 11:30:15 -07:00