-
Notifications
You must be signed in to change notification settings - Fork 135
Lifetime section edits #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Yup, my bad.
👍 x1000 |
@@ -13,40 +13,8 @@ fn two_args<'b>(arg1: &Foo, arg2: &'b Bar) -> &'b Baz | |||
In Rust 2018, you'd write: | |||
|
|||
```rust,ignore | |||
fn two_args(arg1: &Foo, arg2: &Bar) -> &'arg2 Baz | |||
fn two_args(arg1: &Foo, arg2: &'b Bar) -> &'b Baz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason to choose b
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and we're no longer recommending real names, but instead still a/b/c/?
`'_` much like you can explicitly mark that a type is inferred with the syntax | ||
`let x: _ = ..;`. | ||
Rust 2018 allows you to explicitly mark where a lifetime is elided, for types | ||
where this elision might otherwise be unclar. To do this, you can use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: unclar -> unclear.
Rust 2018 allows you to explicitly mark where a lifetime is elided, for types | ||
where this elision might otherwise be unclar. To do this, you can use the | ||
special lifetime `'_` much like you can explicitly mark that a type is inferred | ||
with the syntax `let x: _ = ..;`. | ||
|
||
[1.26]: https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1260-2018-05-10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant link.
|
||
```rust | ||
// Rust 2018 | ||
|
||
#![feature(rust_2018_preview)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment and the feature gate need to be swapped lexically to make this pass the test, at least for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rust-lang/rust#51685
@@ -79,6 +84,8 @@ impl<'a, 'b: 'a> Foo<'a, 'b> { | |||
We can rewrite this as: | |||
|
|||
```rust | |||
// Rust 2018 | |||
|
|||
#![feature(rust_2018_preview)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment and the feature gate need to be swapped lexically to make this pass the test, at least for now.
FWIW, my motivation for includes them (from #16 (comment)):
|
@@ -23,19 +25,31 @@ match s { | |||
}; | |||
``` | |||
|
|||
As of [1.26](nicer-match-bindings), Rust will infer the `&`s and `ref`s, and your original code will Just Work. | |||
Rust 2018, by contrast, will infer the `&`s and `ref`s, and your original code will Just Work. | |||
|
|||
[nicer-match-bindings]: https://blog.rust-lang.org/2018/05/10/Rust-1.26.html#nicer-match-bindings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the link is to be dropped, this reference is also redundant.
@dwijnand Yes! To clarify, the intent is to move this information to a general tracking table that is also part of the guide. |
(working on that right now) |
Review edits pushed! Should be good to go now. |
CI failed. restarting build. |
Since this worked locally, and nightly is currently borked, I'll force merge this; ... here goes nothing... ;) |
A few changes here:
Rewrote the in-band lifetime section, which was incorrect (seemed to be based on the initial RFC rather than what was actually merged/implemented)
Removed references to particular compiler versions. I intend to send a separate PR introducing a table of all the 2018 features, their stabilization status, and links to tracking issues where appropriate.
Assorted minor tweaks/consistency issues.
I didn't touch slice patterns yet, because I think it should be moved to a separate section (it's not particularly connected to ownership or lifetimes).