Commit Graph

31664 Commits

Author SHA1 Message Date
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
Brian Anderson
76d46af6d4 core: Rename ImmutableEqSlice to ImmutablePartialEqSlice
This is in the prelude and won't break much code.

[breaking-change]
2014-08-13 11:30:15 -07:00
Brian Anderson
12e851208d collections: Deprecate Vec::tailn. Same as slice_from 2014-08-13 11:30:15 -07:00
Brian Anderson
c9abc01a98 core: Rename MutableCloneableSlice::copy_from to clone_from_slice
Deprecate the previous.
2014-08-13 11:30:15 -07:00
Brian Anderson
d4c736b1f0 core: Deprecate ImmutableSlice::tailn and initn
These are equivalent to slice_from and slice_to.
2014-08-13 11:30:15 -07:00
Brian Anderson
033f28d436 core: Rename ImmutableSlice::unsafe_ref to unsafe_get
Deprecate the previous.
2014-08-13 11:30:14 -07:00
Brian Anderson
fbc93082ec std: Rename slice::Vector to Slice
This required some contortions because importing both raw::Slice
and slice::Slice makes rustc crash.

Since `Slice` is in the prelude, this renaming is unlikely to
casue breakage.

[breaking-change]
2014-08-13 11:30:14 -07:00
Brian Anderson
4f5b6927e8 std: Rename various slice traits for consistency
ImmutableVector -> ImmutableSlice
ImmutableEqVector -> ImmutableEqSlice
ImmutableOrdVector -> ImmutableOrdSlice
MutableVector -> MutableSlice
MutableVectorAllocating -> MutableSliceAllocating
MutableCloneableVector -> MutableCloneableSlice
MutableOrdVector -> MutableOrdSlice

These are all in the prelude so most code will not break.

[breaking-change]
2014-08-13 11:30:14 -07:00
Felix S. Klock II
9434920b24 rustc lexer: regression tests for embedded Idents.
I chose to make two of them because I wanted something close to an
"end-to-end" test (*), but at the same time I wanted a test that
would run on Windows (**).

(*) The run-make test serves as the end-to-end: It constructs an input
that is trying to subvert the hack and we are going to check that it
fails in the attempt).

(**) The compile-fail-fulldeps test serves as a more narrow test that
will be tested on all platforms.  It also attempts to subvert the
hack, testing that when you use `new_parser_from_tts`, the resulting
parser does not support reading embedded Idents.
2014-08-13 17:41:35 +02:00
Felix S. Klock II
c3ce245ba6 quote_expr macro: embed Ident using special encoding that preserves hygiene.
This adds support to `quote_expr!` and friends for round-trip hygienic
preservation of Ident.

Here are the pieces of the puzzle:

* adding a method for encoding Ident for re-reading into token tree.

* Support for reading such encoded Idents in the lexer.  Note that one
  must peek ahead for MOD_SEP after scan_embedded_hygienic_ident.

* To ensure that encoded Idents are only read when we are in the midst
  of expanding a `quote_expr` or similar, added a
  `read_embedded_ident` flag on `StringReader`.

* pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
2014-08-13 17:40:15 +02:00
Andreas Tolfsen
0edc55dc21 Guide: Add missing integer type to section on if expressions 2014-08-13 15:58:12 +01:00
bors
d917770792 auto merge of #16381 : pnkfelix/rust/fsk-rust.md-fixes, r=alexcrichton
rust.md: Explicitly point out how special `'static` is.

Drive-by: fix description of `&content` to point out that `&'f type` is (as of today) only for type expressions.
2014-08-13 14:16:27 +00:00
bors
9d554212de auto merge of #16421 : ipetkov/rust/cmd-fd-fix-retry, r=alexcrichton
Retry pull requesting of https://github.com/rust-lang/rust/pull/16407 after accidentally messing up rebasing of branches and making bors think the PR was merged
2014-08-13 05:56:20 +00:00
bors
6291781592 auto merge of #16460 : pcwalton/rust/borrowck-closure-issue, r=nikomatsakis
This fixes borrow checking for closures. Code like this will break:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            let p = &this.x;
            &mut this.x;
        };
        r()
    }

Change this code to not take multiple mutable references to the same value. For
example:

    struct Foo {
        x: int,
    }

    pub fn main() {
        let mut this = &mut Foo {
            x: 1,
        };
        let r = || {
            &mut this.x;
        };
        r()
    }

Closes #16361.

[breaking-change]

r? @nikomatsakis
2014-08-13 04:11:22 +00:00
Liigo Zhuang
0186246afe libcore: rename private cmp macros
eq_impl! => partial_eq_impl!
totaleq_impl! => eq_impl!
ord_impl! => partial_ord_impl!
totalord_impl! => ord_impl!
2014-08-13 11:41:29 +08:00
bors
ee87234eed auto merge of #16458 : pcwalton/rust/borrowck-for-moves, r=nikomatsakis
`for` loop heads.

This breaks code like:

    let x = Some(box 1i);
    for &a in x.iter() {
    }

Change this code to obey the borrow checking rules. For example:

    let x = Some(box 1i);
    for &ref a in x.iter() {
    }

Closes #16205.

[breaking-change]

r? @nikomatsakis
2014-08-13 02:26:23 +00:00
Ivan Petkov
3fe0ba9afc libnative: process spawning should not close inherited file descriptors
* The caller should be responsible for cleaning up file descriptors
* If a caller safely creates a file descriptor (via
  native::io::file::open) the returned structure (FileDesc) will try to
  clean up the file, failing in the process and writing error messages
  to the screen.
* This should not happen as the caller has no public interface for
  telling the FileDesc structure to NOT free the underlying fd.
* Alternatively, if another file is opened under the same fd held by
  the FileDesc structure returned by native::io::file::open, it will
  close the wrong file upon destruction.
2014-08-12 19:09:18 -07:00
bors
e189122e9a auto merge of #16452 : epdtry/rust/unreachable-item-ice, r=pcwalton
This code produces an ICE:

```rust
#![crate_type = "rlib"]
fn main() {
    if true { return }
    // remaining code is unreachable
    match () {
        () => { static MAGIC: uint = 0; }
    }
}
```
([playpen](http://is.gd/iwOISB))

The error is "encode_symbol: id not found 18", where 18 is the `NodeId` of the declaration of `MAGIC`.  The problem is that `rustc` tries to emit metadata for `MAGIC`, but some of the information is missing because `MAGIC` never gets translated by `trans_item` - the entire body of the `match` gets skipped because the `match` itself is unreachable.

This branch simplifies the handling of inner items by always processing them using the `trans_item` visitor, instead of sometimes using the visitor and sometimes waiting until `trans_stmt` encounters the item.  This fixes the ICE by making the translation of the item no longer depend on the declaration being reachable code.  This branch also reverts #16059 and #16359, since the new change to item translation fixes the same problems as those but is simpler.
2014-08-13 00:41:22 +00:00
Stuart Pernsteiner
0f847ba74d more consistent handling of inner items 2014-08-12 16:14:27 -07:00