diff --git a/RELEASES.md b/RELEASES.md index 7bf0bcab64066..c3a7367a2ee54 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -92,7 +92,7 @@ Stabilized APIs Cargo ----- - [Cargo API token location moved from `~/.cargo/config` to - `~/cargo/credentials`.][cargo/3978] + `~/.cargo/credentials`.][cargo/3978] - [Cargo will now build `main.rs` binaries that are in sub-directories of `src/bin`.][cargo/4214] ie. Having `src/bin/server/main.rs` and `src/bin/client/main.rs` generates `target/debug/server` and `target/debug/client` @@ -172,7 +172,6 @@ Compatibility Notes [`slice::sort_unstable`]: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable [`ste::from_boxed_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_boxed_utf8_unchecked.html [`str::as_bytes_mut`]: https://doc.rust-lang.org/std/primitive.str.html#method.as_bytes_mut -[`str::as_bytes_mut`]: https://doc.rust-lang.org/std/primitive.str.html#method.as_bytes_mut [`str::from_utf8_mut`]: https://doc.rust-lang.org/std/str/fn.from_utf8_mut.html [`str::from_utf8_unchecked_mut`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked_mut.html [`str::get_mut`]: https://doc.rust-lang.org/std/primitive.str.html#method.get_mut @@ -898,6 +897,9 @@ Compatibility Notes * [Ctrl-Z returns from `Stdin.read()` when reading from the console on Windows][38274] * [Clean up semantics of `self` in an import list][38313] +* Reimplemented lifetime elision. This change was almost entirely compatible + with existing code, but it did close a number of small bugs and loopholes, + as well as being more accepting in some other [cases][41105]. [37057]: https://github.com/rust-lang/rust/pull/37057 [37761]: https://github.com/rust-lang/rust/pull/37761 @@ -932,6 +934,7 @@ Compatibility Notes [39048]: https://github.com/rust-lang/rust/pull/39048 [39282]: https://github.com/rust-lang/rust/pull/39282 [39379]: https://github.com/rust-lang/rust/pull/39379 +[41105]: https://github.com/rust-lang/rust/issues/41105 [`<*const T>::wrapping_offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.wrapping_offset [`<*mut T>::wrapping_offset`]: https://doc.rust-lang.org/std/primitive.pointer.html#method.wrapping_offset [`Duration::checked_add`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.checked_add diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index 65c1088f5473f..2e844ceb17831 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -73,16 +73,19 @@ The script accepts commands, flags, and arguments to determine what to do: ## Configuring rustbuild -There are currently two primary methods for configuring the rustbuild build -system. First, the `./configure` options serialized in `config.mk` will be -parsed and read. That is, if any `./configure` options are passed, they'll be -handled naturally. +There are currently two methods for configuring the rustbuild build system. -Next, rustbuild offers a TOML-based configuration system with a `config.toml` +First, rustbuild offers a TOML-based configuration system with a `config.toml` file in the same location as `config.mk`. An example of this configuration can -be found at `config.toml.example`, and the configuration file -can also be passed as `--config path/to/config.toml` if the build system is -being invoked manually (via the python script). +be found at `config.toml.example`, and the configuration file can also be passed +as `--config path/to/config.toml` if the build system is being invoked manually +(via the python script). + +Next, the `./configure` options serialized in `config.mk` will be +parsed and read. That is, if any `./configure` options are passed, they'll be +handled naturally. `./configure` should almost never be used for local +installations, and is primarily useful for CI. Prefer to customize behavior +using `config.toml`. Finally, rustbuild makes use of the [gcc-rs crate] which has [its own method][env-vars] of configuring C compilers and C flags via environment @@ -310,17 +313,18 @@ After that, each module in rustbuild should have enough documentation to keep you up and running. Some general areas that you may be interested in modifying are: -* Adding a new build tool? Take a look at `bootstrap/step.rs` for examples of +* Adding a new build tool? Take a look at `bootstrap/tool.rs` for examples of other tools. * Adding a new compiler crate? Look no further! Adding crates can be done by adding a new directory with `Cargo.toml` followed by configuring all `Cargo.toml` files accordingly. -* Adding a new dependency from crates.io? We're still working on that, so hold - off on that for now. -* Adding a new configuration option? Take a look at `bootstrap/config.rs` or - perhaps `bootstrap/flags.rs` and then modify the build elsewhere to read that - option. +* Adding a new dependency from crates.io? This should just work inside the + compiler artifacts stage (everything other than libtest and libstd). +* Adding a new configuration option? You'll want to modify `bootstrap/flags.rs` + for command line flags and then `bootstrap/config.rs` to copy the flags to the + `Config` struct. * Adding a sanity check? Take a look at `bootstrap/sanity.rs`. -If you have any questions feel free to reach out on `#rust-internals` on IRC or -open an issue in the bug tracker! +If you have any questions feel free to reach out on `#rust-infra` on IRC or ask on +internals.rust-lang.org. When you encounter bugs, please file issues on the +rust-lang/rust issue tracker. diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index 31a0312ef9699..57b92eb8f8891 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -153,20 +153,19 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, } Categorization::Interior(ref b, mc::InteriorElement(ik)) => { - match (&b.ty.sty, ik) { - (&ty::TySlice(..), _) | - (_, Kind::Index) => { - let mut err = struct_span_err!(bccx, move_from.span, E0508, - "cannot move out of type `{}`, \ - a non-copy array", - b.ty); - err.span_label(move_from.span, "cannot move out of here"); - err - } - (_, Kind::Pattern) => { + let type_name = match (&b.ty.sty, ik) { + (&ty::TyArray(_, _), Kind::Index) => "array", + (&ty::TySlice(_), _) => "slice", + _ => { span_bug!(move_from.span, "this path should not cause illegal move"); - } - } + }, + }; + let mut err = struct_span_err!(bccx, move_from.span, E0508, + "cannot move out of type `{}`, \ + a non-copy {}", + b.ty, type_name); + err.span_label(move_from.span, "cannot move out of here"); + err } Categorization::Downcast(ref b, _) | diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index f486493f98b4c..0fff833e7d83e 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -401,28 +401,29 @@ fn read_to_end(r: &mut R, buf: &mut Vec) -> Result /// /// Implementors of the `Read` trait are called 'readers'. /// -/// Readers are defined by one required method, `read()`. Each call to `read` +/// Readers are defined by one required method, [`read()`]. Each call to [`read()`] /// will attempt to pull bytes from this source into a provided buffer. A -/// number of other methods are implemented in terms of `read()`, giving +/// number of other methods are implemented in terms of [`read()`], giving /// implementors a number of ways to read bytes while only needing to implement /// a single method. /// /// Readers are intended to be composable with one another. Many implementors -/// throughout `std::io` take and provide types which implement the `Read` +/// throughout [`std::io`] take and provide types which implement the `Read` /// trait. /// -/// Please note that each call to `read` may involve a system call, and -/// therefore, using something that implements [`BufRead`][bufread], such as -/// [`BufReader`][bufreader], will be more efficient. -/// -/// [bufread]: trait.BufRead.html -/// [bufreader]: struct.BufReader.html +/// Please note that each call to [`read()`] may involve a system call, and +/// therefore, using something that implements [`BufRead`], such as +/// [`BufReader`], will be more efficient. /// /// # Examples /// -/// [`File`][file]s implement `Read`: +/// [`File`]s implement `Read`: /// -/// [file]: ../fs/struct.File.html +/// [`read()`]: trait.Read.html#tymethod.read +/// [`std::io`]: ../../std/io/index.html +/// [`File`]: ../fs/struct.File.html +/// [`BufRead`]: trait.BufRead.html +/// [`BufReader`]: struct.BufReader.html /// /// ``` /// use std::io; @@ -455,9 +456,9 @@ pub trait Read { /// /// This function does not provide any guarantees about whether it blocks /// waiting for data, but if an object needs to block for a read but cannot - /// it will typically signal this via an `Err` return value. + /// it will typically signal this via an [`Err`] return value. /// - /// If the return value of this method is `Ok(n)`, then it must be + /// If the return value of this method is [`Ok(n)`], then it must be /// guaranteed that `0 <= n <= buf.len()`. A nonzero `n` value indicates /// that the buffer `buf` has been filled in with `n` bytes of data from this /// source. If `n` is `0`, then it can indicate one of two scenarios: @@ -478,14 +479,17 @@ pub trait Read { /// variant will be returned. If an error is returned then it must be /// guaranteed that no bytes were read. /// - /// An error of the `ErrorKind::Interrupted` kind is non-fatal and the read + /// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the read /// operation should be retried if there is nothing else to do. /// /// # Examples /// - /// [`File`][file]s implement `Read`: + /// [`File`]s implement `Read`: /// - /// [file]: ../fs/struct.File.html + /// [`Err`]: ../../std/result/enum.Result.html#variant.Err + /// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok + /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted + /// [`File`]: ../fs/struct.File.html /// /// ``` /// use std::io; @@ -511,8 +515,8 @@ pub trait Read { /// buffers. /// /// If a `Read`er guarantees that it can work properly with uninitialized - /// memory, it should call `Initializer::nop()`. See the documentation for - /// `Initializer` for details. + /// memory, it should call [`Initializer::nop()`]. See the documentation for + /// [`Initializer`] for details. /// /// The behavior of this method must be independent of the state of the /// `Read`er - the method only takes `&self` so that it can be used through @@ -523,6 +527,9 @@ pub trait Read { /// This method is unsafe because a `Read`er could otherwise return a /// non-zeroing `Initializer` from another `Read` type without an `unsafe` /// block. + /// + /// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop + /// [`Initializer`]: ../../std/io/struct.Initializer.html #[unstable(feature = "read_initializer", issue = "42788")] #[inline] unsafe fn initializer(&self) -> Initializer { @@ -532,16 +539,16 @@ pub trait Read { /// Read all bytes until EOF in this source, placing them into `buf`. /// /// All bytes read from this source will be appended to the specified buffer - /// `buf`. This function will continuously call `read` to append more data to - /// `buf` until `read` returns either `Ok(0)` or an error of - /// non-`ErrorKind::Interrupted` kind. + /// `buf`. This function will continuously call [`read()`] to append more data to + /// `buf` until [`read()`] returns either [`Ok(0)`] or an error of + /// non-[`ErrorKind::Interrupted`] kind. /// /// If successful, this function will return the total number of bytes read. /// /// # Errors /// /// If this function encounters an error of the kind - /// `ErrorKind::Interrupted` then the error is ignored and the operation + /// [`ErrorKind::Interrupted`] then the error is ignored and the operation /// will continue. /// /// If any other read error is encountered then this function immediately @@ -550,9 +557,12 @@ pub trait Read { /// /// # Examples /// - /// [`File`][file]s implement `Read`: + /// [`File`]s implement `Read`: /// - /// [file]: ../fs/struct.File.html + /// [`read()`]: trait.Read.html#tymethod.read + /// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok + /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted + /// [`File`]: ../fs/struct.File.html /// /// ``` /// use std::io; @@ -633,11 +643,11 @@ pub trait Read { /// # Errors /// /// If this function encounters an error of the kind - /// `ErrorKind::Interrupted` then the error is ignored and the operation + /// [`ErrorKind::Interrupted`] then the error is ignored and the operation /// will continue. /// /// If this function encounters an "end of file" before completely filling - /// the buffer, it returns an error of the kind `ErrorKind::UnexpectedEof`. + /// the buffer, it returns an error of the kind [`ErrorKind::UnexpectedEof`]. /// The contents of `buf` are unspecified in this case. /// /// If any other read error is encountered then this function immediately @@ -649,9 +659,11 @@ pub trait Read { /// /// # Examples /// - /// [`File`][file]s implement `Read`: + /// [`File`]s implement `Read`: /// - /// [file]: ../fs/struct.File.html + /// [`File`]: ../fs/struct.File.html + /// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted + /// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof /// /// ``` /// use std::io; @@ -722,11 +734,11 @@ pub trait Read { #[stable(feature = "rust1", since = "1.0.0")] fn by_ref(&mut self) -> &mut Self where Self: Sized { self } - /// Transforms this `Read` instance to an `Iterator` over its bytes. + /// Transforms this `Read` instance to an [`Iterator`] over its bytes. /// - /// The returned type implements `Iterator` where the `Item` is `Result`. The yielded item is `Ok` if a byte was successfully read and - /// `Err` otherwise for I/O errors. EOF is mapped to returning `None` from + /// The returned type implements [`Iterator`] where the `Item` is [`Result`]`<`[`u8`]`, + /// R::Err>`. The yielded item is [`Ok`] if a byte was successfully read and + /// [`Err`] otherwise for I/O errors. EOF is mapped to returning [`None`] from /// this iterator. /// /// # Examples @@ -734,6 +746,12 @@ pub trait Read { /// [`File`][file]s implement `Read`: /// /// [file]: ../fs/struct.File.html + /// [`Iterator`]: ../../std/iter/trait.Iterator.html + /// [`Result`]: ../../std/result/enum.Result.html + /// [`u8`]: ../../std/primitive.u8.html + /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok + /// [`Err`]: ../../std/result/enum.Result.html#variant.Err + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// ``` /// use std::io; @@ -754,12 +772,12 @@ pub trait Read { Bytes { inner: self } } - /// Transforms this `Read` instance to an `Iterator` over `char`s. + /// Transforms this `Read` instance to an [`Iterator`] over [`char`]s. /// /// This adaptor will attempt to interpret this reader as a UTF-8 encoded - /// sequence of characters. The returned iterator will return `None` once + /// sequence of characters. The returned iterator will return [`None`] once /// EOF is reached for this reader. Otherwise each element yielded will be a - /// `Result` where `E` may contain information about what I/O error + /// [`Result`]`<`[`char`]`, E>` where `E` may contain information about what I/O error /// occurred or where decoding failed. /// /// Currently this adaptor will discard intermediate data read, and should @@ -767,9 +785,13 @@ pub trait Read { /// /// # Examples /// - /// [`File`][file]s implement `Read`: + /// [`File`]s implement `Read`: /// - /// [file]: ../fs/struct.File.html + /// [`File`]: ../fs/struct.File.html + /// [`Iterator`]: ../../std/iter/trait.Iterator.html + /// [`Result`]: ../../std/result/enum.Result.html + /// [`char`]: ../../std/primitive.char.html + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// ``` /// #![feature(io)] @@ -832,15 +854,17 @@ pub trait Read { /// Creates an adaptor which will read at most `limit` bytes from it. /// /// This function returns a new instance of `Read` which will read at most - /// `limit` bytes, after which it will always return EOF (`Ok(0)`). Any + /// `limit` bytes, after which it will always return EOF ([`Ok(0)`]). Any /// read errors will not count towards the number of bytes read and future - /// calls to `read` may succeed. + /// calls to [`read()`] may succeed. /// /// # Examples /// - /// [`File`][file]s implement `Read`: + /// [`File`]s implement `Read`: /// - /// [file]: ../fs/struct.File.html + /// [`File`]: ../fs/struct.File.html + /// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok + /// [`read()`]: trait.Read.html#tymethod.read /// /// ``` /// use std::io; diff --git a/src/test/compile-fail/issue-12567.rs b/src/test/compile-fail/issue-12567.rs index 15d9a318d29ca..30cdd07b39998 100644 --- a/src/test/compile-fail/issue-12567.rs +++ b/src/test/compile-fail/issue-12567.rs @@ -15,12 +15,12 @@ fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { (&[], &[]) => println!("both empty"), (&[], &[hd, ..]) | (&[hd, ..], &[]) => println!("one empty"), - //~^^ ERROR: cannot move out of type `[T]`, a non-copy array - //~^^^ ERROR: cannot move out of type `[T]`, a non-copy array + //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice + //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice (&[hd1, ..], &[hd2, ..]) => println!("both nonempty"), - //~^^ ERROR: cannot move out of type `[T]`, a non-copy array - //~^^^ ERROR: cannot move out of type `[T]`, a non-copy array + //~^^ ERROR: cannot move out of type `[T]`, a non-copy slice + //~^^^ ERROR: cannot move out of type `[T]`, a non-copy slice } } diff --git a/src/test/compile-fail/move-out-of-array-1.rs b/src/test/compile-fail/move-out-of-array-1.rs index 148dec0282331..796b13538b22a 100644 --- a/src/test/compile-fail/move-out-of-array-1.rs +++ b/src/test/compile-fail/move-out-of-array-1.rs @@ -24,5 +24,5 @@ fn main() { } fn foo(a: [D; 4], i: usize) -> D { - a[i] //~ ERROR cannot move out of type `[D; 4]` + a[i] //~ ERROR cannot move out of type `[D; 4]`, a non-copy array } diff --git a/src/test/compile-fail/move-out-of-slice-1.rs b/src/test/compile-fail/move-out-of-slice-1.rs index f3efc68701e94..9ca9e0984e476 100644 --- a/src/test/compile-fail/move-out-of-slice-1.rs +++ b/src/test/compile-fail/move-out-of-slice-1.rs @@ -15,7 +15,7 @@ struct A; fn main() { let a: Box<[A]> = Box::new([A]); match a { - box [a] => {}, //~ ERROR cannot move out of type `[A]` + box [a] => {}, //~ ERROR cannot move out of type `[A]`, a non-copy slice _ => {} } }