Language ergonomic/learnability improvements #17
Description
Point of contact
@nikomatsakis @aturon @withoutboats
Overview
As part of the effort to lower Rust's learning curve, we are interested in pursuing a number of language improvements that will make Rust both nicer to use and easier to learn. The goal is to enhance productivity without sacrificing Rust's other core values. See the README for more details.
A kind of manifesto for this work was written up on the main blog.
Status
There are a lot of ideas in flight! The lang team has been focused on writing RFCs for the biggest changes; there are lots of opportunities to help either there, or with more narrow RFCs. If you are interested in the ideas listed below, please contact @aturon or others on the team to hook you up with a mentor for RFC writing!
The potential improvements are organized by broad areas of Rust:
Ownership/borrowing
RFCs
- Match ownership ergonomics (@nrc, @cramertj)
- In FCP
- Non-lexical lifetimes
- Nested method calls
Sketches
- Allow owned values where references are expected (or:
AsRef
coercions) (@aturon)- Internals thread
- Good mentored RFC!
- Auto-deref
Copy
types (@aturon)- Good mentored RFC!
- Lifetime elision improvements (@nikomatsakis, @aturon, @solson)
- Internals thread
- @aturon is currently taking point on this
Traits
RFCs
- Trait aliases (@withoutboats)
- Accepted!
-
impl Trait
stabilization and expansion (@aturon)- Accepted!
- More
impl Trait
work, e.g.impl Trait
in traits (@aturon, @cramertj, @eddyb, @withoutboats)- @cramertj is taking point
- A dedicated repo
- Delegation of impls (@withoutboats)
- Needs significant revisions; has stalled out
- Reduce repeated constraints when writing
T: SomeTrait
- Related to implied bounds
- Closed in favor of Implied bounds rfcs#2089
Sketches
- Implied bounds (@nikomatsakis)
-
dyn Trait
syntax for trait objects (@nikomatsakis, @aturon)
Module and privacy system
Landed
-
pub(restricted)
is stable!
RFCs
Sketches
- Possible module system improvements (@withoutboats, @aturon)
- Follow up post and thread with further thinking
- @withoutboats and @aturon have had a bunch of new ideas here; writeup coming soon.
Error handling
RFCs
- Extending
?
to work with more types (@nikomatsakis)- Accepted!
-
?
inmain
(@nikomatsakis)- Nearing FCP
- Coercions into
Result
when leaving a block (@scottmcm, @nikomatsakis, @aturon)- Good mentored RFC!
- Posted as Ok wrapping: Improved support for writing code from an error handling mindset rfcs#2107 -- controversial; heading to close
- Alternative RFC for just
Try<Ok=()>
: Add the()
→Result<(), _>
coercion rule, for removingOk(())
everywhere. rfcs#2120
Primitive types/core traits
Sketches
- Allow string literals to somehow be used as
String
(@aturon)- See the internals thread
- Implicit widening on integer types (@aturon)
- Potentially deprecate
PartialEq
/PartialOrd
(@aturon)- See this comment for a bit more detail and rationale.
-
#[derive(Data)]
- Possibly falls out of trait aliases
Type annotations/verbosity
RFCs
Sketches
- Eliding type name in
match
arms - Eliminate need for the
::
infoo::<u32>(blah)
, in at least the single-argument case - Make coercions more applicable
- E.g., to functions
- E.g., better behavior in generic, trait-bounded contexts (this might be easy to do with Chalk)
- capture the full path in a closure, not just local variable
- @nikomatsakis would be happy to mentor this!
FFI
Landed
- Unions
- FCP period for stabilization is complete!
Other
RFCs
- Default struct field values
- Coroutines, supporting nice async/await syntax
- RFC postponed, pending some open questions; see the summary and related internals thread
- There's now a working implementation and
async
/await
notation built on top; we are considering landing that experimentally in the compiler.
More ideas
- Improving interaction between
return
and closures - Internals thread with more ideas
- Annoyances when using Rust