-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
35 changed files
with
246 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.