The new `std::io` module has had some time to bake now, and this commit
stabilizes its functionality. There are still portions of the module which
remain unstable, and below contains a summart of the actions taken.
This commit also deprecates the entire contents of the `old_io` module in a
blanket fashion. All APIs should now have a reasonable replacement in the
new I/O modules.
Stable APIs:
* `std::io` (the name)
* `std::io::prelude` (the name)
* `Read`
* `Read::read`
* `Read::{read_to_end, read_to_string}` after being modified to return a `usize`
for the number of bytes read.
* `Write`
* `Write::write`
* `Write::{write_all, write_fmt}`
* `BufRead`
* `BufRead::{fill_buf, consume}`
* `BufRead::{read_line, read_until}` after being modified to return a `usize`
for the number of bytes read.
* `BufReader`
* `BufReader::{new, with_capacity}`
* `BufReader::{get_ref, get_mut, into_inner}`
* `{Read,BufRead} for BufReader`
* `BufWriter`
* `BufWriter::{new, with_capacity}`
* `BufWriter::{get_ref, get_mut, into_inner}`
* `Write for BufWriter`
* `IntoInnerError`
* `IntoInnerError::{error, into_inner}`
* `{Error,Display} for IntoInnerError`
* `LineWriter`
* `LineWriter::{new, with_capacity}` - `with_capacity` was added
* `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added)
* `Write for LineWriter`
* `BufStream`
* `BufStream::{new, with_capacities}`
* `BufStream::{get_ref, get_mut, into_inner}`
* `{BufRead,Read,Write} for BufStream`
* `stdin`
* `Stdin`
* `Stdin::lock`
* `Stdin::read_line` - added method
* `StdinLock`
* `Read for Stdin`
* `{Read,BufRead} for StdinLock`
* `stdout`
* `Stdout`
* `Stdout::lock`
* `StdoutLock`
* `Write for Stdout`
* `Write for StdoutLock`
* `stderr`
* `Stderr`
* `Stderr::lock`
* `StderrLock`
* `Write for Stderr`
* `Write for StderrLock`
* `io::Result`
* `io::Error`
* `io::Error::last_os_error`
* `{Display, Error} for Error`
Unstable APIs:
(reasons can be found in the commit itself)
* `Write::flush`
* `Seek`
* `ErrorKind`
* `Error::new`
* `Error::from_os_error`
* `Error::kind`
Deprecated APIs
* `Error::description` - available via the `Error` trait
* `Error::detail` - available via the `Display` implementation
* `thread::Builder::{stdout, stderr}`
Changes in functionality:
* `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing
backtraces has migrated to `std::io`.
* The `ReadExt`, `WriteExt`, and `BufReadExt` extension traits were all removed
by folding functionality into the corresponding trait.
[breaking-change]
This commit stabilizes essentially all of the new `std::path` API. The
API itself is changed in a couple of ways (which brings it in closer
alignment with the RFC):
* `.` components are now normalized away, unless they appear at the
start of a path. This in turn effects the semantics of e.g. asking for
the file name of `foo/` or `foo/.`, both of which yield `Some("foo")`
now. This semantics is what the original RFC specified, and is also
desirable given early experience rolling out the new API.
* The `parent` method is now `without_file` and succeeds if, and only
if, `file_name` is `Some(_)`. That means, in particular, that it fails
for a path like `foo/../`. This change affects `pop` as well.
In addition, the `old_path` module is now deprecated.
[breaking-change]
r? @alexcrichton
This commit stabilizes essentially all of the new `std::path` API. The
API itself is changed in a couple of ways (which brings it in closer
alignment with the RFC):
* `.` components are now normalized away, unless they appear at the
start of a path. This in turn effects the semantics of e.g. asking for
the file name of `foo/` or `foo/.`, both of which yield `Some("foo")`
now. This semantics is what the original RFC specified, and is also
desirable given early experience rolling out the new API.
* The `parent` function now succeeds if, and only if, the path has at
least one non-root/prefix component. This change affects `pop` as
well.
* The `Prefix` component now involves a separate `PrefixComponent`
struct, to better allow for keeping both parsed and unparsed prefix data.
In addition, the `old_path` module is now deprecated.
Closes#23264
[breaking-change]
The end result is that common fields (id, name, attributes, etc.) are stored in now-structures `ImplItem` and `TraitItem`.
The signature of a method is no longer duplicated between methods with a body (default/impl) and those without, they now share `MethodSig`.
This is also a [breaking-change] because of minor bugfixes and changes to syntax extensions:
* `pub fn` methods in a trait no longer parse - remove the `pub`, it has no meaning anymore
* `MacResult::make_methods` is now `make_impl_items` and the return type has changed accordingly
* `quote_method` is gone, because `P<ast::Method>` doesn't exist and it couldn't represent a full method anyways - could be replaced by `quote_impl_item`/`quote_trait_item` in the future, but I do hope we realize how silly that combinatorial macro expansion is and settle on a single `quote` macro + some type hints - or just no types at all (only token-trees)
r? @nikomatsakis This is necessary (hopefully also sufficient) for associated constants.
I've made some minor changes from the implementation attached to the RFC to try to minimize codegen. The methods now take `&Debug` trait objects rather than being parameterized and there are inlined stub methods that call to non-inlined methods to do the work.
r? @alexcrichton
cc @huonw for the `derive(Debug)` changes.
* Consumers of handle_options assume the unstable options are defined in
the getopts::Matches value if -Z unstable-options is set, but that's not
the case if there weren't any actual unstable options. Fix this by
always reparsing options when -Z unstable-options is set.
* If both argument parsing attempts fail, print the error from the second
attempt rather than the first. The error from the first is very poor
whenever unstable options are present. e.g.:
$ rustc hello.rs -Z unstable-options --show-span
error: Unrecognized option: 'show-span'.
$ rustc hello.rs -Z unstable-options --pretty --pretty
error: Unrecognized option: 'pretty'.
$ rustc hello.rs -Z unstable-options --pretty --bad-option
error: Unrecognized option: 'pretty'.
* On the second parse, add a separate pass to reject unstable options if
-Z unstable-options wasn't specified.
Fixes#21715.
r? @pnkfelix
These new APIs have had some time to bake now, and no pressing issues have come
up so they should be ok for stabilizing. Specifically, these two APIs were
stabilized:
* `slice::from_raw_parts`
* `slice::from_raw_parts_mut`
it turns out that jemalloc doesn't behave well on bitrig. with jemalloc enabled i get some kernel errors related to sbrk failures. with jemalloc disabled, the errors go away. i am investigating, but in the mean time, we should just disable jemalloc by default on bitrig.
Deleted trailing space in hello-cargo.md
Added note about build --release in hello-cargo
thanks to steven klabnik for pointing it out for me
edited out redundant wording
* Consumers of handle_options assume the unstable options are defined in
the getopts::Matches value if -Z unstable-options is set, but that's not
the case if there weren't any actual unstable options. Fix this by
always reparsing options when -Z unstable-options is set.
* If both argument parsing attempts fail, print the error from the second
attempt rather than the first. The error from the first is very poor
whenever unstable options are present. e.g.:
$ rustc hello.rs -Z unstable-options --show-span
error: Unrecognized option: 'show-span'.
$ rustc hello.rs -Z unstable-options --pretty --pretty
error: Unrecognized option: 'pretty'.
$ rustc hello.rs -Z unstable-options --pretty --bad-option
error: Unrecognized option: 'pretty'.
* On the second parse, add a separate pass to reject unstable options if
-Z unstable-options wasn't specified.
Fixes#21715.
r? @pnkfelix