Uh oh!
There was an error while loading. Please reload this page.
Document RFC 1623: static lifetime elision. - #37928
Conversation
rust-highfive
commented
Nov 22, 2016
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Can you wrap this line to match the indentation of the surrounding lines?
There was a problem hiding this comment.
Agh, yes. I've updated it; I meant to fix that before I pushed it!
steveklabnik
commented
Nov 22, 2016
So, @rust-lang/docs , this raises a question. How do we make the distinction between stable and unstable stuff here? |
chriskrycho
commented
Nov 22, 2016
via email
I think at some point, we are going to need to build infrastructure for versioning. That is going to be some work, but I do not see how we can handle these kinds of cases long-term without it. I can open an issue to that effect if you like. And maybe ping some of the Ember people who worked on their infrastructure that way. |
GuillaumeGomez
commented
Nov 22, 2016
It should have an unstable version. I don't have much better idea. :-/ |
chriskrycho
commented
Nov 23, 2016
I just noted that all the code samples in reference.md get tested. Neat! I'll update the sample accordingly in the morning. |
I don't have any great ideas either, other than explicitly mentioning that it's unstable in the paragraph above and adding in the |
steveklabnik
commented
Dec 12, 2016
Putting this on this week's doc team agenda. |
llogiq
commented
Dec 14, 2016
We could change the feature implementation to my first commit, thus stabilizing the feature and removing the extra code adding the feature gate that makes it unstable in the first place. I presume this should make the doc tests pass. |
steveklabnik
commented
Dec 14, 2016
So, we talked about this at the docs meeting today. What it really boils down to is this: it'd be a shame to block this based on figuring out the broader story here. However, once we know that the rest of the feature will be stable, we can just land this, then land the stabilization of the feature. @aturonjust put the feature into FCP, so let's see how that goes before we merge. And in the meantime, let's figure out the broader docs story. I'm going to open an issue on the RFCs repo about this. |
chriskrycho
commented
Dec 14, 2016
Related: I'll have time Friday or Saturday to update the not-the-feature-gate bits of the test that are broken here—there's one piece that needs to be tweaked independent of the stabilization/feature flag issue. |
chriskrycho
commented
Dec 30, 2016
Kept spacing this; came back to it via other issues. I'll update the non-feature-gate related parts tonight or tomorrow! |
llogiq
commented
Jan 3, 2017
@chriskrycho do you need any help? |
chriskrycho
commented
Jan 3, 2017
@llogiq gah. Slipped my mind. The only thing that needs tweaking is setting |
chriskrycho
commented
Jan 3, 2017
I just pushed a fixed version of the commit which just includes all the required pieces. We'll see what Travis says… |
chriskrycho
commented
Jan 4, 2017
UGH. I pushed the rebase, but not the fix. This is how my whole first day back at work has been. 🤦♂️ |
steveklabnik
commented
Jan 23, 2017
@chriskrycho travis is still failing: https://travis-ci.org/rust-lang/rust/jobs/188704796#L1662 |
chriskrycho
commented
Jan 23, 2017
via email
🤔 Grr. I will follow up Wednesday evening. Family commitments till then. |
steveklabnik
commented
Jan 23, 2017
No worries! |
llogiq
left a comment
There was a problem hiding this comment.
Actually this is full elision with a 'static default. This means that if the types contains fns, the usual elision rules will apply, only choosing 'static if no elision rule applies.
chriskrycho
commented
Jan 30, 2017
@llogiq can you elaborate? @steveklabnik I seem to have failed in pacifying Travis and the feature gate. Can you take a gander and indicate what I did wrong? |
llogiq
commented
Jan 31, 2017
This means if you have a |
est31
commented
Jan 31, 2017
I think you can fix it by adding |
chriskrycho
commented
Jan 31, 2017
| without the lifetimes. Returning to our previous example: | ||
| ```rust | ||
| #[feature(static_in_const)] |
There was a problem hiding this comment.
this should be #![feature(static_in_const)]; you forgot the exclamation point.
llogiq
commented
Jan 31, 2017
I think I could improve it, but I need to find the time first. |
llogiq
left a comment
There was a problem hiding this comment.
Also after the example, add a paragraph to explain the elision:
In case the static or constant items contain function references or closures, and those work with references, the compiler will try the usual elision rules (link to elision). Failing that, it will default the lifetimes to 'static. This is best explained by an example:
constFUN:fn(&str) -> &str = ..
// per rule #1, this is fn<'a>(&'a str) -> &'a strconstFUNNY:Fn(&Foo,&Bar,&Baz) -> usize = ..
// per rule #2, this is Fn<'a, 'b, 'c>(&'a Foo, &'b Bar, &'c Baz) -> usizeconstUNFUNNY:Fn(&Foo,&Bar) -> &Baz = ..
// neither rule applies, so all `&`s are `'static`| Constant values must not have destructors, and otherwise permit most forms of | ||
| data. Constants may refer to the address of other constants, in which case the | ||
| address will have the `static` lifetime. The compiler is, however, still at | ||
| address will have the `static` lifetime. (See below on [static lifetime |
There was a problem hiding this comment.
How about "will have elided lifetimes where applicable, otherwise – in most cases – defaulting to the 'static lifetime.
est31
commented
Feb 5, 2017
Now that beta branched, I would like to ask for beta backport nomination, so that already 1.16 would have it stabilized. |
llogiq
commented
Feb 5, 2017
Good idea. |
steveklabnik
commented
Feb 7, 2017
@chriskrycho ping! any interest in keeping this going? this is still blocking stabilization. @est31 I would be strongly against this; stabilization backports are incredibly rare. |
chriskrycho
commented
Feb 8, 2017
@steveklabnik yeah, should be able to allocate an hour to it tomorrow. I'll pull in @llogiq's comments, as well as fix the build issue, then. |
llogiq
commented
Feb 8, 2017
We may also want to show embedded lifetimes, e.g. |
chriskrycho
commented
Feb 8, 2017
@llogiq regarding your last comment: did that change with this RFC/implementation? If not, I'd prefer to note it as something to add in a separate commit/PR. I think we actually need a dedicated section for lifetime elision in general; right now it appears to be documented in detail only in the nomicon. |
chriskrycho
commented
Feb 8, 2017
Updated with everything other than the embedded lifetimes scenario, and it passed |
steveklabnik
commented
Feb 8, 2017
Travis passed! @bors: r+ rollup thanks a ton @chriskrycho |
bors
commented
Feb 8, 2017
📌 Commit 4096dd6 has been approved by |
chriskrycho
commented
Feb 8, 2017
YESSSSSSSSSSS. FINALLLYYYYYYYY. Sorry for the many delays on this, everyone! Glad it's finally in. So it'll land in, what, 1.17? |
…eveklabnik Document RFC 1623: static lifetime elision. This should be the last item required for stabilizing RFC 1623 (rust-lang#35897).
est31
commented
Feb 9, 2017
yes. |
…eveklabnik Document RFC 1623: static lifetime elision. This should be the last item required for stabilizing RFC 1623 (rust-lang#35897).
Stabilize static lifetime in statics Stabilize the "static_in_const" feature. Blockers before this PR can be merged: * [x] The [FCP with inclination to stabilize](#35897 (comment)) needs to be over. FCP lasts roughly three weeks, so will be over at Jan 25, aka this thursday. * [x] Documentation needs to be added (#37928) Closes#35897.
alexcrichton
commented
Feb 21, 2017
Removing beta nomination as sentiment seems to be to not backport (also see #35897) |
This should be the last item required for stabilizing RFC 1623 (#35897).