summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2015-05-13Update docs to stop referencing `BufReadExt`Corey Farwell-2/+2
2015-05-13std: Add example for HashMap::entry()Ulrik Sverdrup-0/+18
2015-05-13doc: Address feedbackBrian Anderson-10/+11
2015-05-13std: Update crate docsBrian Anderson-53/+49
Attempted to organize them in a way more relevant to what newbies would be interested in hearing.
2015-05-11Fix broken doc testBrian Anderson-0/+2
2015-05-11Fallout from fixing Issue 25199.Felix S. Klock II-1/+1
There are two interesting kinds of breakage illustrated here: 1. `Box<Trait>` in many contexts is treated as `Box<Trait + 'static>`, due to [RFC 599]. However, in a type like `&'a Box<Trait>`, the `Box<Trait>` type will be expanded to `Box<Trait + 'a>`, again due to [RFC 599]. This, combined with the fix to Issue 25199, leads to a borrowck problem due the combination of this function signature (in src/libstd/net/parser.rs): ```rust fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T>>]) -> Option<T>; ``` with this call site (again in src/libstd/net/parser.rs): ```rust fn read_ip_addr(&mut self) -> Option<IpAddr> { let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(|v4| IpAddr::V4(v4)); let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(|v6| IpAddr::V6(v6)); self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) } ``` yielding borrowck errors like: ``` parser.rs:265:27: 265:69 error: borrowed value does not live long enough parser.rs:265 self.read_or(&mut [Box::new(ipv4_addr), Box::new(ipv6_addr)]) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` (full log at: https://gist.github.com/pnkfelix/e2e80f1a71580f5d3103 ) The issue here is perhaps subtle: the `parsers` argument is inferred to be taking a slice of boxed objects with the implicit lifetime bound attached to the `self` parameter to `read_or`. Meanwhile, the fix to Issue 25199 (added in a forth-coming commit) is forcing us to assume that each boxed object may have a destructor that could refer to state of that lifetime, and *therefore* that inferred lifetime is required to outlive the boxed object itself. In this case, the relevant boxed object here is not going to make any such references; I believe it is just an artifact of how the expression was built that it is not assigned type: `Box<FnMut(&mut Parser) -> Option<T> + 'static>`. (i.e., mucking with the expression is probably one way to fix this problem). But the other way to fix it, adopted here, is to change the `read_or` method type to force make the (presumably-intended) `'static` bound explicit on the boxed `FnMut` object. (Note: this is still just the *first* example of breakage.) 2. In `macro_rules.rs`, the `TTMacroExpander` trait defines a method with signature: ```rust fn expand<'cx>(&self, cx: &'cx mut ExtCtxt, ...) -> Box<MacResult+'cx>; ``` taking a `&'cx mut ExtCtxt` as an argument and returning a `Box<MacResult'cx>`. The fix to Issue 25199 (added in aforementioned forth-coming commit) assumes that a value of type `Box<MacResult+'cx>` may, in its destructor, refer to a reference of lifetime `'cx`; thus the `'cx` lifetime is forced to outlive the returned value. Meanwhile, within `expand.rs`, the old code was doing: ```rust match expander.expand(fld.cx, ...).make_pat() { ... => immutable borrow of fld.cx ... } ``` The problem is that the `'cx` lifetime, inferred for the `expander.expand` call, has now been extended so that it has to outlive the temporary R-value returned by `expanded.expand`. But call is also reborrowing `fld.cx` *mutably*, which means that this reborrow must end before any immutable borrow of `fld.cx`; but there is one of those within the match body. (Note that the temporary R-values for the input expression to `match` all live as long as the whole `match` expression itself (see Issue #3511 and PR #11585). To address this, I moved the construction of the pat value into its own `let`-statement, so that the `Box<MacResult>` will only live for as long as the initializing expression for the `let`-statement, and thus allow the subsequent immutable borrow within the `match`. [RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md
2015-05-11Merge pull request #25299 from alexcrichton/beta-backportBrian Anderson-2/+2
Backport mem::forget to beta
2015-05-12Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-86/+86
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-05-10std: Mark `mem::forget` as a safe functionAlex Crichton-2/+2
This commit is an implementation of [RFC 1066][rfc] where the conclusion was that leaking a value is a safe operation in Rust code, so updating the signature of this function follows suit. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1066-safe-mem-forget.md Closes #25186
2015-05-10Merge pull request #25276 from steveklabnik/third_doc_backportSteve Klabnik-21/+24
Third doc backport
2015-05-10Update process.rstynopex-8/+8
Make whitespace consistent
2015-05-10std: Fixup docs for std::processtynopex-13/+16
2015-05-10Fix punctuation placement in doc-commentCorey Farwell-1/+1
2015-05-10Clarify Once::call_once memory ordering guarantees in docsinrustwetrust-1/+5
2015-05-10remove stability note from std::netSteve Klabnik-4/+1
This is served by stability markers.
2015-05-10thread: right now you can't actually set those printersRicho Healey-2/+1
2015-05-10Improve libstd/net/addr.rs documentation.Nick Hamann-9/+9
This adds some missing punctuation and converts uses of "Gets" to "Returns". This sounds better to my ear, but more importantly is more consistent with the documentation from other files.
2015-05-10Add some missing punctuation in the libstd/net/tcp.rs docs.Nick Hamann-1/+1
2015-05-10Add some missing punctuation in the libstd/net/ip.rs docs.Nick Hamann-19/+19
2015-05-10Improve libstd/net/udp.rs documentation.Nick Hamann-10/+10
This adds some missing punctuation, adds a missing word, and corrects a bug in the description of `send_to`, which actually returns the number of bytes written on success. Fixes #24925.
2015-05-10Explain how to create a Stdin or StdoutMatt Brubeck-0/+4
2015-05-10Separate code into two code blocksNick Hamann-3/+4
2015-05-10Address some nitsNick Hamann-2/+2
2015-05-10Add two examples for Path::newNick Hamann-0/+7
2015-05-07Merge pull request #25192 from alexcrichton/beta-backportBrian Anderson-29/+61
Backport of PRs to Beta
2015-05-07Make RwLock::try_write try to obtain a write lockJohn Gallagher-2/+19
Conflicts: src/libstd/sync/rwlock.rs
2015-05-07std: Destabilize io::BufStreamAlex Crichton-10/+18
As pointed out in #17136 the semantics of a `BufStream` aren't always what one expects, and it looks like other [languages like C#][c-sharp] implement a buffered stream with only one underlying buffer. For now this commit destabilizes the primitive in the `std::io` module to give us some more time in figuring out what to do with it. [c-sharp]: https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx [breaking-change]
2015-05-07std: Remove index notation on slice iteratorsAlex Crichton-6/+5
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791 Conflicts: src/libcoretest/slice.rs src/librustc_driver/lib.rs
2015-05-07std: update select internals to not use mutable transmutingSean McArthur-11/+19
2015-05-05Add downcasting to std::error::ErrorAaron Turon-12/+134
This commit brings the `Error` trait in line with the [Error interoperation RFC](https://github.com/rust-lang/rfcs/pull/201) by adding downcasting, which has long been intended. This change means that for any `Error` trait objects that are `'static`, you can downcast to concrete error types. To make this work, it is necessary for `Error` to inherit from `Reflect` (which is currently used to mark concrete types as "permitted for reflection, aka downcasting"). This is a breaking change: it means that impls like ```rust impl<T> Error for MyErrorType<T> { ... } ``` must change to something like ```rust impl<T: Reflect> Error for MyErrorType<T> { ... } ``` except that `Reflect` is currently unstable (and should remain so for the time being). For now, code can instead bound by `Any`: ```rust impl<T: Any> Error for MyErrorType<T> { ... } ``` which *is* stable and has `Reflect` as a super trait. The downside is that this imposes a `'static` constraint, but that only constrains *when* `Error` is implemented -- it does not actually constrain the types that can implement `Error`. [breaking-change] Conflicts: src/libcore/marker.rs
2015-04-30Test fixes and rebase conflictsAlex Crichton-1/+0
2015-04-30std: Fix inheriting standard handles on windowsAlex Crichton-177/+138
Currently if a standard I/O handle is set to inherited on Windows, no action is taken and the slot in the process information description is set to `INVALID_HANDLE_VALUE`. Due to our passing of `STARTF_USESTDHANDLES`, however, this means that the handle is actually set to nothing and if a child tries to print it will generate an error. This commit fixes this behavior by explicitly creating stdio handles to be placed in these slots by duplicating the current process's I/O handles. This is presumably what previously happened silently by using a file-descriptor-based implementation instead of a `HANDLE`-centric implementation. Along the way this cleans up a lot of code in `Process::spawn` for Windows by ensuring destructors are always run, using more RAII, and limiting the scope of `unsafe` wherever possible.
2015-04-25Remove an unused import on windowsAlex Crichton-1/+0
2015-04-25Fixed typo in hash_map::Entry documentationAram Visser-1/+0
2015-04-25Utilize if..let for get_mut doc-comment examplesCorey Farwell-3/+2
2015-04-25Fix typos in code commentsCorey Farwell-2/+2
2015-04-25Remove doc-comment default::Default importsCorey Farwell-2/+0
In 8f5b5f94dcdb9884737dfbc8efd893d1d70f0b14, `default::Default` was added to the prelude, so these imports are no longer necessary.
2015-04-23Add `Sync` to the bounds in `io::Error`Kevin Ballard-10/+15
This allows `io::Error` values to be stored in `Arc` properly. Because this requires `Sync` of any value passed to `io::Error::new()` and modifies the relevant `convert::From` impls, this is a [breaking-change] Fixes #24049.
2015-04-23Test fixes and rebase conflicts, round 1Alex Crichton-8/+2
Conflicts: src/test/run-pass/task-stderr.rs
2015-04-23std: Bring back f32::from_str_radix as an unstable APIAlex Crichton-789/+310
This API was exercised in a few tests and mirrors the `from_str_radix` functionality of the integer types. Conflicts: src/doc/trpl/traits.md src/libstd/sys/windows/fs2.rs
2015-04-23std: Remove deprecated/unstable num functionalityAlex Crichton-3531/+47
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change] Conflicts: src/libstd/num/strconv.rs
2015-04-23std: Remove deprecated AsPath traitAlex Crichton-32/+0
2015-04-23std: Remove deprecated AsOsStr/Str/AsSlice traitsAlex Crichton-57/+0
Cleaning out more deprecated items Conflicts: src/libcore/result.rs
2015-04-23std: Add Default/IntoIterator/ToOwned to the preludeAlex Crichton-64/+55
This is an implementation of [RFC 1030][rfc] which adds these traits to the prelude and additionally removes all inherent `into_iter` methods on collections in favor of the trait implementation (which is now accessible by default). [rfc]: https://github.com/rust-lang/rfcs/pull/1030 This is technically a breaking change due to the prelude additions and removal of inherent methods, but it is expected that essentially no code breaks in practice. [breaking-change] Closes #24538
2015-04-16Auto merge of #24448 - alexcrichton:issue-24445, r=huonwbors-1/+1
One of the parameters to the magical "register a thread-local destructor" function is called `__dso_handle` and largely just passed along (this seems to be what other implementations do). Currently we pass the *value* of this symbol, but apparently the correct piece of information to pass is the *address* of the symbol. In a PIE binary the symbol actually contains an address to itself which is why we've gotten away with what we're doing as long as we have. In a non-PIE binary the symbol contains the address `NULL`, causing a segfault in the runtime library if it keeps going. Closes #24445
2015-04-16Auto merge of #23682 - tamird:DRY-is-empty, r=alexcrichtonbors-11/+11
r? @alexcrichton
2015-04-15Rollup merge of #24480 - achanda:move_test, r=alexcrichtonSteve Klabnik-259/+270
- Also move common functions to test.rs - Leaves out Socket address related tests in addr.rs
2015-04-15Move IP related tests to ip.rsAbhishek Chanda-259/+270
- Also move common functions to test.rs - Leaves out Socket address related tests in addr.rs
2015-04-15std: Fix thread_local! in non-PIE binariesAlex Crichton-1/+1
One of the parameters to the magical "register a thread-local destructor" function is called `__dso_handle` and largely just passed along (this seems to be what other implementations do). Currently we pass the *value* of this symbol, but apparently the correct piece of information to pass is the *address* of the symbol. In a PIE binary the symbol actually contains an address to itself which is why we've gotten away with what we're doing as long as we have. In a non-PIE binary the symbol contains the address `NULL`, causing a segfault in the runtime library if it keeps going. Closes #24445
2015-04-15Fix some typos.Ms2ger-5/+5