-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Epoch.Next Tracking Issue #46889
Comments
the tracking issue link for "Clarify and streamline paths" links to the issue for NLLs. |
Fixed, thanks! |
Looking forward to those ownership improvements :) |
@glyn Fixed, thanks! |
Should specialization and macros 2.0 be tracked here? |
@nikomatsakis - Not sure if anyone else mentioned it, but NLL says "This feature is blocked on #46862 landing." which has now landed. |
@jonathandturner updated, though nightly still does seem to have the changes. |
I don't think either of those are on track to be part of the next epoch. Specialization no, because it is not on track -- design is still very much in flux. I feel similarly about Macros 2.0 -- for example, there is no RFC or description of the hygiene system. Note though that not being "part of the epoch" won't necessarily delay features from being available. The epoch is more of an end-point: basically a way to say "hey, a coherent set of features and associated tooling and documentation has landed -- you should give Rust another look!". |
Awesome to see so much great work in this! Where does the work on const items, and constants in types land in respect to the Epoch system? |
The description of the
|
What about const generics? Currently for me it's the most expected feature and I think it will be good for marketing to include it into the new epoch features list. |
@newpavlov New features should only be part of an epoch if they require a change which is not backwards compatible. Otherwise the feature should land normally so that people aren't forced to update their code for the new epoch just to gain access to that feature. Shoving something into an epoch just for the sake of marketing is a bad idea. |
@retep998 |
I wouldn't consider |
#46479 ( |
Can we change the legend/keys to be colorblind friendly (different shapes for each key)? I can't tell the difference between the two hearts. |
I've updated the previous green heart (💚 — "Available in Nightly in “code complete” form") to a checkbox (✅), which appears as a green square for me. |
Sorry about that -- I was actually trying to be colorblind friendly by having at least have the red/green keys have a distinct shape, but I guess I should have further. =) |
@nikomatsakis - any guidance on what makes the epoch.next list? I know some folks are going to ask about features like const generics and no doubt others. |
Const generics seems like a pretty big feature to try to finish this year and get it to stable... |
Should async/await be added to this list, given the recent design breakthroughs (described in the @withoutboats blog posts) and the inclusion in the 2018 Roadmap? |
We have to figure out just how to manage this issue -- I wouldn't take this as an exhaustive list just now. |
Closing this, seems out of date |
What is this issue?
Have you noticed that there is a lot going on with Rust these days? Over the last year, there’s been a large push to design a number of tweaks to the Rust language, all with the goal of improving ergonomics and productivity for new and experienced users alike. This issue will help you see what changes are in the works and give you tips for trying them out, giving feedback, or helping to get them implemented.
Legend
✅ Available in Nightly in “code complete” form
💛 Available in Nightly but design not fully realized
🔴 Not yet available in Nightly
Ownership
✅ Simplifying how `match` and borrowing interact
#![feature(match_default_bindings)]
Matching over borrowed data today in Rust requires a combination of
*
operators,&
patterns, andref
bindings. Thematch_default_bindings
feature replaces them with a simpler system; when matching against a value of type&T
, you can simply ignore the&
and give a pattern that matches the underlying typeT
. Any bindings in that pattern will be made into references themselves.Example
Simple example matching an
&Option<String>
::What’s left to be done?
Not much. There are a few corner cases that we might want to fine-tune: see the tracking issue for the full details.
✅ Easier borrowing (a.k.a. NLL)
#![feature(nll)]
The compiler is now able to understand control flow much more deeply when deciding what paths are borrowed at any particular point in the program. These changes eliminate a large number of confusing borrowing errors, particularly those errors that are due more to imprecision in the analysis.
Examples
Borrow lifetimes are no longer tied to lexical scopes.
Invoking
&mut self
methods no longer requires “unnesting”:What’s left to be done?
There is still some engineering effort remaining. For example, some of the error messages are not yet particularly user friendly. In addition, we need to tighten some of the corner cases described in the various RFCs (these are not soundness issues per se, but rather cases where we fear that the analysis may not be forwards compatible with future changes we have in mind).
We will be transitioning to the new borrow system, but slowly. We plan to run a “trial period” where we gather feedback and try to find bugs. We also need to do a “warning period” before enabling the new borrowing system by default, as the new system fixes a number of bugs where the compiler incorrectly accepted illegal code (the new implementation is believed to be significantly more robust).
💛 In-band lifetimes
#![feature(underscore_lifetimes, in_band_lifetimes)]
#![warn(single_use_lifetime, elided_lifetime_in_path)]
The current rules that govern explicit lifetime names have some confusing edge cases. These can lead to surprising errors that are hard to diagnose. In addition, the existing annotations can be tedious to supply and get right. The in-band lifetimes RFC aims to adjust the rules to make for a smoother experience overall.
Warning: while the major features of this RFC are in place, some of the lints are not yet fully implemented. This
The highlights:
'_
to indicate an “anonymous lifetime” that you do not care to give a name. This is primarily intended for use with lifetime-parameterized structs; for example, one can now writeFoo<'_>
, whereas before it was common to either writeFoo
(which obscured the fact that a lifetime was present) or to introduce a one-off name likeFoo<'a>
(where'a
is never used anywhere else).Foo
isFoo
has a lifetime parameter — but you can useFoo<'_>
if the specific value is not important.<'a>
inimpl<'a>
. Instead, the intention is that simply annotate the lifetimes that must be the same by giving them explicit names, and use'_
for lifetimes that are not required to match against other lifetimes.Examples
TBD
What is left to do?
Some pieces of this design are not yet implemented:
'_
or elide lifetimes in impls (issue #15872)'_
) (issue #44752)Foo
instead ofFoo<'_>
) (issue #45992)🔴 Infer `T: 'a` outlives requirements on type definitions
Explicit
T: 'x
annotations will no longer be needed on type definitions. We will infer their presence based on the fields of the struct or enum. In short, if the struct contains a reference (directly or indirectly) toT
with lifetime'x
, then we will infer thatT: 'x
is a requirement:Explicit annotations remain as an option used to control trait object lifetime defaults, and simply for backwards compatibility.
Examples
Coming soon =)
What’s left to be done
Everything
The Trait System
✅ `impl Trait` and `dyn Trait`
#![feature(universal_impl_trait, conservative_impl_trait, dyn_trait)]
impl Trait
is a long awaited feature that allows one to describe types by the traits that they implement. For example, a function likefn foo(args: impl Iterator<Item = u32>)
declares a functionfoo
that takes an iterator ofu32
of argument;impl Trait
can also be used in return position. Currently,impl Trait
is limited to function signatures and cannot be used in traits or trait impls. In the future, we aim to support the notation in more places.dyn Trait
is a simple syntactic change: whereas a trait object type used to be written as something like&Write
(whereWrite
is a trait), it is now preferred to write&dyn Write
, which helps to make clear that (a)Write
is a trait and (b) that method calls onWrite
will employ dynamic dispatch.Together, these two features help to both grow expressiveness, and to address a common point of user confusion about the role of traits and types. In particular, when using these keywords, a trait is never used directly as a type; rather one uses the
impl
ordyn
keyword to select how to useExamples
Using
impl Trait
in argument position:Using
impl Trait
in return position:Using
dyn Trait
:What’s left to be done?
There are still a few outstanding questions about the syntax, notably the precedence of
impl Trait
. You can get the full details at the tracking issues:✅ Closures implementing `Clone` or `Copy`
#![feature(copy_closures, clone_closures)]
Closures are now copyable / cloneable if the variables that they capture are copyable / cloneable. Note that non-move closures often borrow captured variables instead of taking ownership of them, and hence a closure may be
Copy
even if some of the variable that it uses are not (because it only requires a shared reference to them).Examples
(Try it on play.)
What’s left to be done?
Gain experience.
🔴 Trait aliases
#![feature(trait_alias)]
Trait aliases allow you to make aliases for common used combinations of trait bounds and where-clauses, much like a type alias lets you have an alternate name for a commonly used type.
Example
(Since this feature is not fully implemented yet, example will not actually work.)
What’s left to be done?
Quite a bit. Some of the parsing and infrastructure work landed in nightly, but the semantics are not yet implemented.
🔴 Generic associated types
#![feature(generic_associated_types)]
Generic associated types allow associated types defined in traits to take lifetime or type parameters. This allows for common patterns like an
Iterable
trait which are currently quite difficult to do.Example
(Since this feature is not fully implemented yet, example will not actually work.)
What’s left to be done
The parsing and various bits of the semantics are implemented, but there is still more to come. See the tracking issue.
Error Handling
✅ `?` applied to `Option` and other types
#![feature(try_trait)]
, but not needed to use?
withOption
You can now use the
?
operator in functions that returnOption
, not justResult
. Furthermore, through the (as yet unstable)Try
trait, you can extend?
to operate on types of your own.Example
What’s left to be done?
Gain more experience with the
Try
trait.✅ `?` in `main()`
#![feature(termination_trait)]
You can now give
main()
alternative return types, notably includingResult
types. This enables the use of the?
operator withinmain()
. The goal is to support?
also in unit tests, but this is not yet implemented.Note: Implemented in PR #46479, which has not yet landed.
Example
What’s left to be done?
Once PR #46479 lands, you should be able to use examples involving
main
. But the full design also allows for writing unit tests (#[test]
fns) withResult
return types as well.The Module System
✅ Nested groups in imports
#![feature(use_nested_groups)]
You can now nest “import groups”, making it easier to import many names from a single crate without breaking things into multiple
use
statements.Example
(Try it on play)
What’s left to be done?
Gain experience, find bugs in the implementation.
💛 Clarify and streamline paths
#![feature(crate_in_paths, crate_visibility_modifier, non_modrs_mods)]
#![warn(unreachable_pub)]
These changes seek to clarify and streamline Rust's story around paths and visibility for modules and crates. That story will look as follows:
crate
refers to the current crate (other forms are linted, see below)extern crate is no longer necessary, and is linted (see below); dependencies are available at the root unless shadowed.
crate
keyword also acts as a visibility modifier, equivalent to today'spub(crate)
. Consequently, uses of barepub
on items that are not actually publicly exported are linted, suggestingcrate
visibility instead.foo.rs
andfoo/
subdirectory may coexist;mod.rs
is no longer needed when placing submodules in a subdirectory.Example
What’s left to be done?
The text was updated successfully, but these errors were encountered: