Skip to content

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

Merged
merged 2 commits into from
Jun 22, 2018
Merged

Lifetime section edits #23

merged 2 commits into from
Jun 22, 2018

Conversation

aturon
Copy link
Member

@aturon aturon commented Jun 21, 2018

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).

@aturon aturon requested review from steveklabnik and Centril June 21, 2018 15:36
@steveklabnik
Copy link
Member

(seemed to be based on the initial RFC rather than what was actually merged/implemented)

Yup, my bad.

Removed references to particular compiler versions

👍 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
Copy link
Member

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?

Copy link
Member

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
Copy link
Contributor

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
Copy link
Contributor

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)]
Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -79,6 +84,8 @@ impl<'a, 'b: 'a> Foo<'a, 'b> {
We can rewrite this as:

```rust
// Rust 2018

#![feature(rust_2018_preview)]
Copy link
Contributor

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.

@dwijnand
Copy link
Member

Removed references to particular compiler versions

FWIW, my motivation for includes them (from #16 (comment)):

The use case I had in mind is someone without the bandwidth to follow all the changes in every 6-week release but does have the time to read the edition guide might benefit from knowing that so-and-so change is already available as of X.Y rust version.

@@ -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
Copy link
Member

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.

@aturon
Copy link
Member Author

aturon commented Jun 22, 2018

@dwijnand Yes! To clarify, the intent is to move this information to a general tracking table that is also part of the guide.

@Centril
Copy link
Contributor

Centril commented Jun 22, 2018

(working on that right now)

@aturon
Copy link
Member Author

aturon commented Jun 22, 2018

Review edits pushed! Should be good to go now.

@Centril
Copy link
Contributor

Centril commented Jun 22, 2018

CI failed. restarting build.

@Centril
Copy link
Contributor

Centril commented Jun 22, 2018

Since this worked locally, and nightly is currently borked, I'll force merge this;

... here goes nothing... ;)

@Centril Centril merged commit 17f6489 into rust-lang:master Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants