mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-10 08:57:36 +00:00
Auto merge of #26696 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #26373, #26506, #26580, #26622, #26627, #26651, #26678, #26692 - Failed merges:
This commit is contained in:
commit
bf3c979ec3
@ -4,7 +4,7 @@ Rust is a fast systems programming language that guarantees
|
||||
memory safety and offers painless concurrency ([no data races]).
|
||||
It does not employ a garbage collector and has minimal runtime overhead.
|
||||
|
||||
This repo contains the code for `rustc`, the Rust compiler, as well
|
||||
This repo contains the code for the compiler (`rustc`), as well
|
||||
as standard libraries, tools and documentation for Rust.
|
||||
|
||||
[no data races]: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html
|
||||
|
@ -33,8 +33,10 @@ pub fn new(value: T) -> Rc<T> {
|
||||
```
|
||||
|
||||
This code generates documentation that looks [like this][rc-new]. I've left the
|
||||
implementation out, with a regular comment in its place. That's the first thing
|
||||
to notice about this annotation: it uses `///`, instead of `//`. The triple slash
|
||||
implementation out, with a regular comment in its place.
|
||||
|
||||
The first thing to notice about this annotation is that it uses
|
||||
`///` instead of `//`. The triple slash
|
||||
indicates a documentation comment.
|
||||
|
||||
Documentation comments are written in Markdown.
|
||||
@ -375,7 +377,7 @@ $ rustdoc --test path/to/my/crate/root.rs
|
||||
$ cargo test
|
||||
```
|
||||
|
||||
That's right, `cargo test` tests embedded documentation too. However,
|
||||
That's right, `cargo test` tests embedded documentation too. However,
|
||||
`cargo test` will not test binary crates, only library ones. This is
|
||||
due to the way `rustdoc` works: it links against the library to be tested,
|
||||
but with a binary, there’s nothing to link to.
|
||||
|
@ -17,7 +17,7 @@ Note that this feature is currently hidden behind the `feature(link_args)` gate
|
||||
because this is not a sanctioned way of performing linking. Right now rustc
|
||||
shells out to the system linker, so it makes sense to provide extra command line
|
||||
arguments, but this will not always be the case. In the future rustc may use
|
||||
LLVM directly to link native libraries in which case `link_args` will have no
|
||||
LLVM directly to link native libraries, in which case `link_args` will have no
|
||||
meaning.
|
||||
|
||||
It is highly recommended to *not* use this attribute, and rather use the more
|
||||
|
@ -128,15 +128,15 @@
|
||||
//! This allows multiple actual types to be formatted via `{:x}` (like `i8` as
|
||||
//! well as `isize`). The current mapping of types to traits is:
|
||||
//!
|
||||
//! * *nothing* ⇒ `Display`
|
||||
//! * `?` ⇒ `Debug`
|
||||
//! * `o` ⇒ `Octal`
|
||||
//! * `x` ⇒ `LowerHex`
|
||||
//! * `X` ⇒ `UpperHex`
|
||||
//! * `p` ⇒ `Pointer`
|
||||
//! * `b` ⇒ `Binary`
|
||||
//! * `e` ⇒ `LowerExp`
|
||||
//! * `E` ⇒ `UpperExp`
|
||||
//! * *nothing* ⇒ [`Display`](trait.Display.html)
|
||||
//! * `?` ⇒ [`Debug`](trait.Debug.html)
|
||||
//! * `o` ⇒ [`Octal`](trait.Octal.html)
|
||||
//! * `x` ⇒ [`LowerHex`](trait.LowerHex.html)
|
||||
//! * `X` ⇒ [`UpperHex`](trait.UpperHex.html)
|
||||
//! * `p` ⇒ [`Pointer`](trait.Pointer.html)
|
||||
//! * `b` ⇒ [`Binary`](trait.Binary.html)
|
||||
//! * `e` ⇒ [`LowerExp`](trait.LowerExp.html)
|
||||
//! * `E` ⇒ [`UpperExp`](trait.UpperExp.html)
|
||||
//!
|
||||
//! What this means is that any type of argument which implements the
|
||||
//! `fmt::Binary` trait can then be formatted with `{:b}`. Implementations
|
||||
@ -367,11 +367,11 @@
|
||||
//! should always be printed.
|
||||
//! * '-' - Currently not used
|
||||
//! * '#' - This flag is indicates that the "alternate" form of printing should
|
||||
//! be used. For array slices, the alternate form omits the brackets.
|
||||
//! For the integer formatting traits, the alternate forms are:
|
||||
//! be used. The alternate forms are:
|
||||
//! * `#?` - pretty-print the `Debug` formatting
|
||||
//! * `#x` - precedes the argument with a "0x"
|
||||
//! * `#X` - precedes the argument with a "0x"
|
||||
//! * `#t` - precedes the argument with a "0b"
|
||||
//! * `#b` - precedes the argument with a "0b"
|
||||
//! * `#o` - precedes the argument with a "0o"
|
||||
//! * '0' - This is used to indicate for integer formats that the padding should
|
||||
//! both be done with a `0` character as well as be sign-aware. A format
|
||||
@ -408,19 +408,20 @@
|
||||
//!
|
||||
//! There are three possible ways to specify the desired `precision`:
|
||||
//!
|
||||
//! There are three possible ways to specify the desired `precision`:
|
||||
//! 1. An integer `.N`,
|
||||
//! 2. an integer followed by dollar sign `.N$`, or
|
||||
//! 3. an asterisk `.*`.
|
||||
//! 1. An integer `.N`:
|
||||
//!
|
||||
//! The first specification, `.N`, means the integer `N` itself is the precision.
|
||||
//! the integer `N` itself is the precision.
|
||||
//!
|
||||
//! The second, `.N$`, means use format *argument* `N` (which must be a `usize`) as the precision.
|
||||
//! 2. An integer followed by dollar sign `.N$`:
|
||||
//!
|
||||
//! Finally, `.*` means that this `{...}` is associated with *two* format inputs rather than one:
|
||||
//! the first input holds the `usize` precision, and the second holds the value to print. Note
|
||||
//! that in this case, if one uses the format string `{<arg>:<spec>.*}`, then the `<arg>` part
|
||||
//! refers to the *value* to print, and the `precision` must come in the input preceding `<arg>`.
|
||||
//! use format *argument* `N` (which must be a `usize`) as the precision.
|
||||
//!
|
||||
//! 3. An asterisk `.*`:
|
||||
//!
|
||||
//! `.*` means that this `{...}` is associated with *two* format inputs rather than one: the
|
||||
//! first input holds the `usize` precision, and the second holds the value to print. Note that
|
||||
//! in this case, if one uses the format string `{<arg>:<spec>.*}`, then the `<arg>` part refers
|
||||
//! to the *value* to print, and the `precision` must come in the input preceding `<arg>`.
|
||||
//!
|
||||
//! For example, these:
|
||||
//!
|
||||
|
@ -166,6 +166,8 @@ impl Ordering {
|
||||
///
|
||||
/// - total and antisymmetric: exactly one of `a < b`, `a == b` or `a > b` is true; and
|
||||
/// - transitive, `a < b` and `b < c` implies `a < c`. The same must hold for both `==` and `>`.
|
||||
///
|
||||
/// When this trait is `derive`d, it produces a lexicographic ordering.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait Ord: Eq + PartialOrd<Self> {
|
||||
/// This method returns an `Ordering` between `self` and `other`.
|
||||
|
@ -267,7 +267,7 @@ impl<'a> Display for Arguments<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Format trait for the `:?` format. Useful for debugging, all types
|
||||
/// Format trait for the `?` character. Useful for debugging, all types
|
||||
/// should implement this.
|
||||
///
|
||||
/// Generally speaking, you should just `derive` a `Debug` implementation.
|
||||
@ -312,6 +312,9 @@ impl<'a> Display for Arguments<'a> {
|
||||
/// There are a number of `debug_*` methods on `Formatter` to help you with manual
|
||||
/// implementations, such as [`debug_struct`][debug_struct].
|
||||
///
|
||||
/// `Debug` implementations using either `derive` or the debug builder API
|
||||
/// on `Formatter` support pretty printing using the alternate flag: `{:#?}`.
|
||||
///
|
||||
/// [debug_struct]: ../std/fmt/struct.Formatter.html#method.debug_struct
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \
|
||||
|
@ -1022,6 +1022,120 @@ type Foo<A> = Box<A>; // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0092: r##"
|
||||
You tried to declare an undefined atomic operation function.
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_foo(); // error: unrecognized atomic operation
|
||||
// function
|
||||
}
|
||||
```
|
||||
|
||||
Please check you didn't make a mistake in the function's name. All intrinsic
|
||||
functions are defined in librustc_trans/trans/intrinsic.rs and in
|
||||
libcore/intrinsics.rs in the Rust source code. Example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_fence(); // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0093: r##"
|
||||
You declared an unknown intrinsic function. Erroneous code example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn foo(); // error: unrecognized intrinsic function: `foo`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please check you didn't make a mistake in the function's name. All intrinsic
|
||||
functions are defined in librustc_trans/trans/intrinsic.rs and in
|
||||
libcore/intrinsics.rs in the Rust source code. Example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_fence(); // ok!
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
atomic_fence();
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0094: r##"
|
||||
You gave an invalid number of type parameters to an intrinsic function.
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn size_of<T, U>() -> usize; // error: intrinsic has wrong number
|
||||
// of type parameters
|
||||
}
|
||||
```
|
||||
|
||||
Please check that you provided the right number of lifetime parameters
|
||||
and verify with the function declaration in the Rust source code.
|
||||
Example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn size_of<T>() -> usize; // ok!
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0101: r##"
|
||||
You hit this error because the compiler the compiler lacks information
|
||||
to determine a type for this expression. Erroneous code example:
|
||||
|
||||
```
|
||||
fn main() {
|
||||
let x = |_| {}; // error: cannot determine a type for this expression
|
||||
}
|
||||
```
|
||||
|
||||
You have two possibilities to solve this situation:
|
||||
* Give an explicit definition of the expression
|
||||
* Infer the expression
|
||||
|
||||
Examples:
|
||||
|
||||
```
|
||||
fn main() {
|
||||
let x = |_ : u32| {}; // ok!
|
||||
// or:
|
||||
let x = |_| {};
|
||||
x(0u32);
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0106: r##"
|
||||
This error indicates that a lifetime is missing from a type. If it is an error
|
||||
inside a function signature, the problem may be with failing to adhere to the
|
||||
@ -1130,6 +1244,96 @@ impl Bytes { ... } // error, same as above
|
||||
```
|
||||
"##,
|
||||
|
||||
E0117: r##"
|
||||
You got this error because because you tried to implement a foreign
|
||||
trait for a foreign type (with maybe a foreign type parameter). Erroneous
|
||||
code example:
|
||||
|
||||
```
|
||||
impl Drop for u32 {}
|
||||
```
|
||||
|
||||
The type, trait or the type parameter (or all of them) has to be defined
|
||||
in your crate. Example:
|
||||
|
||||
```
|
||||
pub struct Foo; // you define your type in your crate
|
||||
|
||||
impl Drop for Foo { // and you can implement the trait on it!
|
||||
// code of trait implementation here
|
||||
}
|
||||
|
||||
trait Bar { // or define your trait in your crate
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
impl Bar for u32 { // and then you implement it on a foreign type
|
||||
fn get(&self) -> usize { 0 }
|
||||
}
|
||||
|
||||
impl From<Foo> for i32 { // or you use a type from your crate as
|
||||
// a type parameter
|
||||
fn from(i: Foo) -> i32 {
|
||||
0
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0119: r##"
|
||||
There are conflicting trait implementations for the same type.
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
trait MyTrait {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
impl<T> MyTrait for T {
|
||||
fn get(&self) -> usize { 0 }
|
||||
}
|
||||
|
||||
struct Foo {
|
||||
value: usize
|
||||
}
|
||||
|
||||
impl MyTrait for Foo { // error: conflicting implementations for trait
|
||||
// `MyTrait`
|
||||
fn get(&self) -> usize { self.value }
|
||||
}
|
||||
```
|
||||
|
||||
When you write:
|
||||
|
||||
```
|
||||
impl<T> MyTrait for T {
|
||||
fn get(&self) -> usize { 0 }
|
||||
}
|
||||
```
|
||||
|
||||
This makes the trait implemented on all types in the scope. So if you
|
||||
try to implement it on another one after that, the implementations will
|
||||
conflict. Example:
|
||||
|
||||
```
|
||||
trait MyTrait {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
impl<T> MyTrait for T {
|
||||
fn get(&self) -> usize { 0 }
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
fn main() {
|
||||
let f = Foo;
|
||||
|
||||
f.get(); // the trait is implemented so we can use it
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0121: r##"
|
||||
In order to be consistent with Rust's lack of global type inference, type
|
||||
placeholders are disallowed by design in item signatures.
|
||||
@ -1250,6 +1454,43 @@ information see the [opt-in builtin traits RFC](https://github.com/rust-lang/
|
||||
rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
|
||||
"##,
|
||||
|
||||
E0195: r##"
|
||||
Your method's lifetime parameters do not match the trait declaration.
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
trait Trait {
|
||||
fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Trait for Foo {
|
||||
fn bar<'a,'b>(x: &'a str, y: &'b str) {
|
||||
// error: lifetime parameters or bounds on method `bar`
|
||||
// do not match the trait declaration
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The lifetime constraint `'b` for bar() implementation does not match the
|
||||
trait declaration. Ensure lifetime declarations match exactly in both trait
|
||||
declaration and implementation. Example:
|
||||
|
||||
```
|
||||
trait Trait {
|
||||
fn t<'a,'b:'a>(x: &'a str, y: &'b str);
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Trait for Foo {
|
||||
fn t<'a,'b:'a>(x: &'a str, y: &'b str) { // ok!
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0197: r##"
|
||||
Inherent implementations (one that do not implement a trait but provide
|
||||
methods associated with a type) are always safe because they are not
|
||||
@ -1429,6 +1670,65 @@ impl Copy for &'static Bar { } // error
|
||||
```
|
||||
"##,
|
||||
|
||||
E0207: r##"
|
||||
You declared an unused type parameter when implementing a trait on an object.
|
||||
Erroneous code example:
|
||||
|
||||
```
|
||||
trait MyTrait {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl<T> MyTrait for Foo {
|
||||
fn get(&self) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please check your object definition and remove unused type
|
||||
parameter(s). Example:
|
||||
|
||||
```
|
||||
trait MyTrait {
|
||||
fn get(&self) -> usize;
|
||||
}
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl MyTrait for Foo {
|
||||
fn get(&self) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0211: r##"
|
||||
You used an intrinsic function which doesn't correspond to its
|
||||
definition. Erroneous code example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn size_of<T>(); // error: intrinsic has wrong type
|
||||
}
|
||||
```
|
||||
|
||||
Please check the function definition. Example:
|
||||
|
||||
```
|
||||
#![feature(intrinsics)]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn size_of<T>() -> usize;
|
||||
}
|
||||
```
|
||||
"##,
|
||||
|
||||
E0243: r##"
|
||||
This error indicates that not enough type parameters were found in a type or
|
||||
trait.
|
||||
@ -1649,16 +1949,10 @@ register_diagnostics! {
|
||||
E0085,
|
||||
E0086,
|
||||
E0090,
|
||||
E0092,
|
||||
E0093,
|
||||
E0094,
|
||||
E0101,
|
||||
E0102,
|
||||
E0103,
|
||||
E0104,
|
||||
E0117,
|
||||
E0118,
|
||||
E0119,
|
||||
E0120,
|
||||
E0122,
|
||||
E0123,
|
||||
@ -1686,15 +1980,12 @@ register_diagnostics! {
|
||||
E0193, // cannot bound type where clause bounds may only be attached to types
|
||||
// involving type parameters
|
||||
E0194,
|
||||
E0195, // lifetime parameters or bounds on method do not match the trait declaration
|
||||
E0196, // cannot determine a type for this closure
|
||||
E0203, // type parameter has more than one relaxed default bound,
|
||||
// and only one is supported
|
||||
E0207, // type parameter is not constrained by the impl trait, self type, or predicate
|
||||
E0208,
|
||||
E0209, // builtin traits can only be implemented on structs or enums
|
||||
E0210, // type parameter is not constrained by any local type
|
||||
E0211,
|
||||
E0212, // cannot extract an associated type from a higher-ranked trait bound
|
||||
E0213, // associated types are not accepted in this context
|
||||
E0214, // parenthesized parameters may only be used with a trait
|
||||
|
@ -204,6 +204,28 @@ impl Stdin {
|
||||
///
|
||||
/// For detailed semantics of this method, see the documentation on
|
||||
/// `BufRead::read_line`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
///
|
||||
/// let mut input = String::new();
|
||||
/// match io::stdin().read_line(&mut input) {
|
||||
/// Ok(n) => {
|
||||
/// println!("{} bytes read", n);
|
||||
/// println!("{}", input);
|
||||
/// }
|
||||
/// Err(error) => println!("error: {}", error),
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// You can run the example one of two ways:
|
||||
///
|
||||
/// - Pipe some text to it, e.g. `printf foo | path/to/executable`
|
||||
/// - Give it text interactively by running the executable directly,
|
||||
// in which case it will wait for the Enter key to be pressed before
|
||||
/// continuing
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
|
||||
self.lock().read_line(buf)
|
||||
|
@ -20,7 +20,7 @@ fn main() {
|
||||
_x: Port<()>,
|
||||
}
|
||||
|
||||
impl Drop for foo {
|
||||
impl Drop for foo {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ pub mod pipes {
|
||||
p: Option<*const packet<T>>,
|
||||
}
|
||||
|
||||
impl<T:Send> Drop for send_packet<T> {
|
||||
impl<T:Send> Drop for send_packet<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if self.p != None {
|
||||
@ -194,7 +194,7 @@ pub mod pipes {
|
||||
p: Option<*const packet<T>>,
|
||||
}
|
||||
|
||||
impl<T:Send> Drop for recv_packet<T> {
|
||||
impl<T:Send> Drop for recv_packet<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if self.p != None {
|
||||
|
Loading…
Reference in New Issue
Block a user