diff options
| author | bors <bors@rust-lang.org> | 2019-11-27 21:30:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-11-27 21:30:14 +0000 |
| commit | 6b604a91b7667106495a60291a74ce66923c9a8a (patch) | |
| tree | 919997783180d1d8b671b27453a5f6489be28810 /src/librustc_error_codes/error_codes | |
| parent | e87a205c2e117d9fb57f6cdeac0a7f6e95c88316 (diff) | |
| parent | a40494bc504d665257dc89b1144803a3bff803a9 (diff) | |
| download | rust-6b604a91b7667106495a60291a74ce66923c9a8a.tar.gz rust-6b604a91b7667106495a60291a74ce66923c9a8a.zip | |
Auto merge of #66824 - tmandry:rollup-kk56bte, r=tmandry
Rollup of 17 pull requests
Successful merges:
- #64325 (Stabilize nested self receivers in 1.41.0)
- #66222 (Use `eq_opaque_type_and_type` when type-checking closure signatures)
- #66305 (Add by-value arrays to `improper_ctypes` lint)
- #66399 (rustc_metadata: simplify the interactions between Lazy and Table.)
- #66534 (Allow global references via ForeignItem and Item for the same symbol name during LLVM codegen)
- #66700 (Fix pointing at arg for fulfillment errors in function calls)
- #66704 (Intra doc enum variant field)
- #66718 (Refactor `parse_enum_item` to use `parse_delim_comma_seq`)
- #66722 (Handle non_exhaustive in borrow checking)
- #66744 (Fix shrink_to panic documentation)
- #66761 (Use LLVMDisposePassManager instead of raw delete in rustllvm)
- #66769 (Add core::{f32,f64}::consts::TAU.)
- #66774 (Clean up error codes)
- #66777 (Put back tidy check on error codes)
- #66797 (Fixes small typo in array docs r? @steveklabnik)
- #66798 (Fix spelling typos)
- #66800 (Combine similar tests for const match)
Failed merges:
r? @ghost
Diffstat (limited to 'src/librustc_error_codes/error_codes')
18 files changed, 60 insertions, 54 deletions
diff --git a/src/librustc_error_codes/error_codes/E0015.md b/src/librustc_error_codes/error_codes/E0015.md index 361cb425809..021a0219d13 100644 --- a/src/librustc_error_codes/error_codes/E0015.md +++ b/src/librustc_error_codes/error_codes/E0015.md @@ -1,4 +1,5 @@ -A constant item was initialized with something that is not a constant expression. +A constant item was initialized with something that is not a constant +expression. Erroneous code example: diff --git a/src/librustc_error_codes/error_codes/E0071.md b/src/librustc_error_codes/error_codes/E0071.md index 768dd0c7a48..bc2c03a0220 100644 --- a/src/librustc_error_codes/error_codes/E0071.md +++ b/src/librustc_error_codes/error_codes/E0071.md @@ -1,5 +1,5 @@ -You tried to use structure-literal syntax to create an item that is -not a structure or enum variant. +A structure-literal syntax was used to create an item that is not a structure +or enum variant. Example of erroneous code: @@ -9,8 +9,8 @@ let t = U32 { value: 4 }; // error: expected struct, variant or union type, // found builtin type `u32` ``` -To fix this, ensure that the name was correctly spelled, and that -the correct form of initializer was used. +To fix this, ensure that the name was correctly spelled, and that the correct +form of initializer was used. For example, the code above can be fixed to: diff --git a/src/librustc_error_codes/error_codes/E0072.md b/src/librustc_error_codes/error_codes/E0072.md index e461d45f30c..8f7749abab1 100644 --- a/src/librustc_error_codes/error_codes/E0072.md +++ b/src/librustc_error_codes/error_codes/E0072.md @@ -1,20 +1,23 @@ -When defining a recursive struct or enum, any use of the type being defined -from inside the definition must occur behind a pointer (like `Box` or `&`). -This is because structs and enums must have a well-defined size, and without -the pointer, the size of the type would need to be unbounded. +A recursive type has infinite size because it doesn't have an indirection. -Consider the following erroneous definition of a type for a list of bytes: +Erroneous code example: ```compile_fail,E0072 -// error, invalid recursive struct type struct ListNode { head: u8, - tail: Option<ListNode>, + tail: Option<ListNode>, // error: no indirection here so impossible to + // compute the type's size } ``` -This type cannot have a well-defined size, because it needs to be arbitrarily -large (since we would be able to nest `ListNode`s to any depth). Specifically, +When defining a recursive struct or enum, any use of the type being defined +from inside the definition must occur behind a pointer (like `Box`, `&` or +`Rc`). This is because structs and enums must have a well-defined size, and +without the pointer, the size of the type would need to be unbounded. + +In the example, the type cannot have a well-defined size, because it needs to be +arbitrarily large (since we would be able to nest `ListNode`s to any depth). +Specifically, ```plain size of `ListNode` = 1 byte for `head` diff --git a/src/librustc_error_codes/error_codes/E0075.md b/src/librustc_error_codes/error_codes/E0075.md index f15af8150ba..969c1ee7131 100644 --- a/src/librustc_error_codes/error_codes/E0075.md +++ b/src/librustc_error_codes/error_codes/E0075.md @@ -1,21 +1,23 @@ -The `#[simd]` attribute can only be applied to non empty tuple structs, because -it doesn't make sense to try to use SIMD operations when there are no values to -operate on. +A `#[simd]` attribute was applied to an empty tuple struct. -This will cause an error: +Erroneous code example: ```compile_fail,E0075 #![feature(repr_simd)] #[repr(simd)] -struct Bad; +struct Bad; // error! ``` -This will not: +The `#[simd]` attribute can only be applied to non empty tuple structs, because +it doesn't make sense to try to use SIMD operations when there are no values to +operate on. + +Fixed example: ``` #![feature(repr_simd)] #[repr(simd)] -struct Good(u32); +struct Good(u32); // ok! ``` diff --git a/src/librustc_error_codes/error_codes/E0076.md b/src/librustc_error_codes/error_codes/E0076.md index 466e0a96e6b..f293a2a5772 100644 --- a/src/librustc_error_codes/error_codes/E0076.md +++ b/src/librustc_error_codes/error_codes/E0076.md @@ -1,21 +1,24 @@ -When using the `#[simd]` attribute to automatically use SIMD operations in tuple -struct, the types in the struct must all be of the same type, or the compiler -will trigger this error. +All types in a tuple struct aren't the same when using the `#[simd]` +attribute. -This will cause an error: +Erroneous code example: ```compile_fail,E0076 #![feature(repr_simd)] #[repr(simd)] -struct Bad(u16, u32, u32); +struct Bad(u16, u32, u32); // error! ``` -This will not: +When using the `#[simd]` attribute to automatically use SIMD operations in tuple +struct, the types in the struct must all be of the same type, or the compiler +will trigger this error. + +Fixed example: ``` #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32); +struct Good(u32, u32, u32); // ok! ``` diff --git a/src/librustc_error_codes/error_codes/E0077.md b/src/librustc_error_codes/error_codes/E0077.md index 6ae35a6aa17..b14513c6ccf 100644 --- a/src/librustc_error_codes/error_codes/E0077.md +++ b/src/librustc_error_codes/error_codes/E0077.md @@ -1,20 +1,23 @@ -When using the `#[simd]` attribute on a tuple struct, the elements in the tuple -must be machine types so SIMD operations can be applied to them. +A tuple struct's element isn't a machine type when using the `#[simd]` +attribute. -This will cause an error: +Erroneous code example: ```compile_fail,E0077 #![feature(repr_simd)] #[repr(simd)] -struct Bad(String); +struct Bad(String); // error! ``` -This will not: +When using the `#[simd]` attribute on a tuple struct, the elements in the tuple +must be machine types so SIMD operations can be applied to them. + +Fixed example: ``` #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32); +struct Good(u32, u32, u32); // ok! ``` diff --git a/src/librustc_error_codes/error_codes/E0107.md b/src/librustc_error_codes/error_codes/E0107.md index 3a8acba061c..bfe0d21f312 100644 --- a/src/librustc_error_codes/error_codes/E0107.md +++ b/src/librustc_error_codes/error_codes/E0107.md @@ -25,4 +25,3 @@ fn main() { // expected 0, found 1 } ``` - diff --git a/src/librustc_error_codes/error_codes/E0307.md b/src/librustc_error_codes/error_codes/E0307.md index c382f406e4b..1779e5dbb30 100644 --- a/src/librustc_error_codes/error_codes/E0307.md +++ b/src/librustc_error_codes/error_codes/E0307.md @@ -1,5 +1,5 @@ This error indicates that the `self` parameter in a method has an invalid -"reciever type". +"receiver type". Methods take a special first parameter, of which there are three variants: `self`, `&self`, and `&mut self`. These are syntactic sugar for diff --git a/src/librustc_error_codes/error_codes/E0369.md b/src/librustc_error_codes/error_codes/E0369.md index 08db342428c..397979e5641 100644 --- a/src/librustc_error_codes/error_codes/E0369.md +++ b/src/librustc_error_codes/error_codes/E0369.md @@ -26,4 +26,3 @@ left and may require reallocation. This requires ownership of the string on the left. If something should be added to a string literal, move the literal to the heap by allocating it with `to_owned()` like in `"Your text".to_owned()`. - diff --git a/src/librustc_error_codes/error_codes/E0404.md b/src/librustc_error_codes/error_codes/E0404.md index 861a50bfd8c..201107c05a0 100644 --- a/src/librustc_error_codes/error_codes/E0404.md +++ b/src/librustc_error_codes/error_codes/E0404.md @@ -41,4 +41,3 @@ trait Foo { fn bar<T: Foo>(t: T) {} // ok! ``` - diff --git a/src/librustc_error_codes/error_codes/E0458.md b/src/librustc_error_codes/error_codes/E0458.md index e6baeb8f692..385079d403d 100644 --- a/src/librustc_error_codes/error_codes/E0458.md +++ b/src/librustc_error_codes/error_codes/E0458.md @@ -10,4 +10,3 @@ Please specify a valid "kind" value, from one of the following: * static * dylib * framework - diff --git a/src/librustc_error_codes/error_codes/E0633.md b/src/librustc_error_codes/error_codes/E0633.md index a68da1188b5..65cdf90036a 100644 --- a/src/librustc_error_codes/error_codes/E0633.md +++ b/src/librustc_error_codes/error_codes/E0633.md @@ -21,4 +21,3 @@ The `#[unwind]` attribute should be used as follows: NB. The default behavior here is "allowed", but this is unspecified and likely to change in the future. - diff --git a/src/librustc_error_codes/error_codes/E0635.md b/src/librustc_error_codes/error_codes/E0635.md index 2382ce0d3ff..a39d2be4f8f 100644 --- a/src/librustc_error_codes/error_codes/E0635.md +++ b/src/librustc_error_codes/error_codes/E0635.md @@ -5,4 +5,3 @@ Erroneous code example: ```compile_fail,E0635 #![feature(nonexistent_rust_feature)] // error: unknown feature ``` - diff --git a/src/librustc_error_codes/error_codes/E0636.md b/src/librustc_error_codes/error_codes/E0636.md index dabf9b64123..57cf72db556 100644 --- a/src/librustc_error_codes/error_codes/E0636.md +++ b/src/librustc_error_codes/error_codes/E0636.md @@ -7,4 +7,3 @@ Erroneous code example: #![feature(rust1)] #![feature(rust1)] // error: the feature `rust1` has already been declared ``` - diff --git a/src/librustc_error_codes/error_codes/E0641.md b/src/librustc_error_codes/error_codes/E0641.md index e39bebce1fe..e2110042c7e 100644 --- a/src/librustc_error_codes/error_codes/E0641.md +++ b/src/librustc_error_codes/error_codes/E0641.md @@ -16,4 +16,4 @@ let a = &(String::from("Hello world!")) as *const _; // Ok let b = 0 as *const i32; // Ok let c: *const i32 = 0 as *const _; // Ok -``` \ No newline at end of file +``` diff --git a/src/librustc_error_codes/error_codes/E0644.md b/src/librustc_error_codes/error_codes/E0644.md index 61acb084a45..7a653bd2264 100644 --- a/src/librustc_error_codes/error_codes/E0644.md +++ b/src/librustc_error_codes/error_codes/E0644.md @@ -27,4 +27,3 @@ closure call itself by capturing a `&Fn()` object or `fn()` pointer that refers to itself. That is permitting, since the closure would be invoking itself via a virtual call, and hence does not directly reference its own *type*. - diff --git a/src/librustc_error_codes/error_codes/E0706.md b/src/librustc_error_codes/error_codes/E0706.md index bee9219af7c..d379b8a2384 100644 --- a/src/librustc_error_codes/error_codes/E0706.md +++ b/src/librustc_error_codes/error_codes/E0706.md @@ -1,4 +1,4 @@ - `async fn`s are not yet supported in traits in Rust. +`async fn`s are not yet supported in traits in Rust. Erroneous code example: @@ -10,7 +10,8 @@ trait T { } ``` -`async fn`s return an `impl Future`, making the following two examples equivalent: +`async fn`s return an `impl Future`, making the following two examples +equivalent: ```edition2018,ignore (example-of-desugaring-equivalence) async fn foo() -> User { @@ -23,8 +24,8 @@ fn foo(&self) -> impl Future<Output = User> + '_ { ``` But when it comes to supporting this in traits, there are [a few implementation -issues][async-is-hard]. One of them is returning `impl Trait` in traits is not supported, -as it would require [Generic Associated Types] to be supported: +issues][async-is-hard]. One of them is returning `impl Trait` in traits is not +supported, as it would require [Generic Associated Types] to be supported: ```edition2018,ignore (example-of-desugaring-equivalence) impl MyDatabase { @@ -40,13 +41,14 @@ impl MyDatabase { } ``` -Until these issues are resolved, you can use the [`async-trait` crate], allowing you to use -`async fn` in traits by desugaring to "boxed futures" +Until these issues are resolved, you can use the [`async-trait` crate], allowing +you to use `async fn` in traits by desugaring to "boxed futures" (`Pin<Box<dyn Future + Send + 'async>>`). -Note that using these trait methods will result in a heap allocation per-function-call. This is not -a significant cost for the vast majority of applications, but should be considered when deciding -whether to use this functionality in the public API of a low-level function that is expected to be +Note that using these trait methods will result in a heap allocation +per-function-call. This is not a significant cost for the vast majority of +applications, but should be considered when deciding whether to use this +functionality in the public API of a low-level function that is expected to be called millions of times a second. You might be interested in visiting the [async book] for further information. diff --git a/src/librustc_error_codes/error_codes/E0745.md b/src/librustc_error_codes/error_codes/E0745.md index 7c478a1e0c8..39bebdcd375 100644 --- a/src/librustc_error_codes/error_codes/E0745.md +++ b/src/librustc_error_codes/error_codes/E0745.md @@ -11,7 +11,7 @@ fn temp_address() { To avoid the error, first bind the temporary to a named local variable. -```ignore +```ignore (not yet implemented) # #![feature(raw_ref_op)] fn temp_address() { let val = 2; |
