diff options
| author | bors <bors@rust-lang.org> | 2020-05-14 19:35:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-05-14 19:35:24 +0000 |
| commit | a74d1862d4d87a56244958416fd05976c58ca1a8 (patch) | |
| tree | b64230280cd4a445e65ae665e0097b548e9c3989 /src/librustc_error_codes/error_codes | |
| parent | af6d8865fe0e1f6338c32cb3370802f2ebca0dc4 (diff) | |
| parent | 7b5bc61e99ea77ff87233295fc3e789e43dd66f0 (diff) | |
| download | rust-a74d1862d4d87a56244958416fd05976c58ca1a8.tar.gz rust-a74d1862d4d87a56244958416fd05976c58ca1a8.zip | |
Auto merge of #72202 - Dylan-DPC:rollup-6lbxh1s, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - #71910 (Fix unused_parens false positive when using binary operations) - #72087 (Fix hang in lexical_region_resolve) - #72126 (Change `WorkProduct::saved_files` to an `Option`.) - #72127 (add long error explanation for E0228) - #72141 (Warn against thread::sleep in async fn) - #72170 (use `require_lang_item` over `unwrap`.) - #72191 (Clean up E0589 explanation) - #72194 (Don't ICE on missing `Unsize` impl) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_error_codes/error_codes')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0228.md | 40 | ||||
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0589.md | 2 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/librustc_error_codes/error_codes/E0228.md b/src/librustc_error_codes/error_codes/E0228.md new file mode 100644 index 00000000000..3443a5ae863 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0228.md @@ -0,0 +1,40 @@ +The lifetime bound for this object type cannot be deduced from context and must +be specified. + +Erroneous code example: + +```compile_fail,E0228 +trait Trait { } + +struct TwoBounds<'a, 'b, T: Sized + 'a + 'b> { + x: &'a i32, + y: &'b i32, + z: T, +} + +type Foo<'a, 'b> = TwoBounds<'a, 'b, dyn Trait>; +``` + +When a trait object is used as a type argument of a generic type, Rust will try +to infer its lifetime if unspecified. However, this isn't possible when the +containing type has more than one lifetime bound. + +The above example can be resolved by either reducing the number of lifetime +bounds to one or by making the trait object lifetime explicit, like so: + +``` +trait Trait { } + +struct TwoBounds<'a, 'b, T: Sized + 'a + 'b> { + x: &'a i32, + y: &'b i32, + z: T, +} + +type Foo<'a, 'b> = TwoBounds<'a, 'b, dyn Trait + 'b>; +``` + +For more information, see [RFC 599] and its amendment [RFC 1156]. + +[RFC 599]: https://github.com/rust-lang/rfcs/blob/master/text/0599-default-object-bound.md +[RFC 1156]: https://github.com/rust-lang/rfcs/blob/master/text/1156-adjust-default-object-bounds.md diff --git a/src/librustc_error_codes/error_codes/E0589.md b/src/librustc_error_codes/error_codes/E0589.md index 5e15a875b0b..8a4f8d21725 100644 --- a/src/librustc_error_codes/error_codes/E0589.md +++ b/src/librustc_error_codes/error_codes/E0589.md @@ -1,6 +1,8 @@ The value of `N` that was specified for `repr(align(N))` was not a power of two, or was greater than 2^29. +Erroneous code example: + ```compile_fail,E0589 #[repr(align(15))] // error: invalid `repr(align)` attribute: not a power of two enum Foo { |
