Comments (6)
- Feature mostly works and is avaiable under
#![feature(capture_disjoint_fields)]
- We have handled all edge cases we are aware of including patterns, FRU syntax, references in move closures, handling unsafe
- Migration lint for drop reordering is supported under
#[deny(disjoint_capture_drop_reorder)]
and is supported using rust fix. - On going work to support migration for auto-traits, and diagnostics
from lang-team.
There are some more relaxations to closures that can be made as side effects of work being done for 2229, proposed details can be found here: rust-lang/project-rfc-2229#16
from lang-team.
Update 2020-10-26:
Uncovered a few interesting things this far. For example, this changes behavior:
let c = || {
let _ = x; // today: borrows `x`
};
In the new edition, using the new RFC, x
would not be captured.
from lang-team.
The workgroup's focus over the last month has been diagnostics, migrations and getting closer to the edition 21 release.
1. Diangostics
- Overall improvement to closure diagnostics: we now point to part of the source code responsible for the capture kind associated with the error message.
- eg:
let mut p = Point { x: 1, y: 2 };
let y = &p.y;
let mut c = || {
println!("{:?}", p);
let x = &mut p.x;
};
c();
println!("{}", y);
Output ater change (available on rust nightly):
2. Migrations
- We can now detect if the closure after enabling RFC 2229 will not meet Clone or any of the auto trait bounds and can provide migrations for it. These migrations are supported via rustfix as well.
- We can annote drop implementations with
#[rustc_insignificant_dtor]
to avoid migrating in scenarios where drop order doesn't affect semantics of the program. We intend to use this attribute to annotate the stdlib to mark certain type as safe to be Drop reorded. eg: when a string gets dropped it would not affect the behavior of rest of the program.
3. Closure Size
- We wrote an initial implementation for printing out the closure size before and after the feature. The implementation is somewhat incomplete, but was good enough for us to get some data on cargo and stdlib.
Cargo and all depensices size data: https://docs.google.com/spreadsheets/d/1Irsj5O7HPPfomWat2jPTPdx_KPlsyYo5kRuQpNNuwsQ/edit?usp=sharing
from lang-team.
- Lots of progress squelching small bugs in the implementation
- It's now enabled by default in edition 2021
- We are working to add material to the reference and to create a concise, formal definition of what gets captured and what doesn't (separate from the code)
- We tested the size of closures and discovered one critical optimization. (Data that was collected is linked here: rust-lang/rust#86701 (comment))
- After optimization closures appear largely unchanged, but we added a useful flag (
-Zprofile-closures
) to measure and are going to ask people to do so
from lang-team.
Stabilized!
from lang-team.
Related Issues (20)
- RPITIT stabilization schedule, refine HOT 2
- Return type notation and the Send bound problem HOT 1
- Rust 2024 survey HOT 12
- Does T-lang have opinion on floating-point guarantees? HOT 4
- Extern types V2 RFC
- Experiment: Generic const items HOT 2
- Capturing lifetimes in `impl Trait`
- RFC review Inherent Trait Impls -- RFC#2375 HOT 1
- RFC review: Add f16 and f128 float types -- RFC#3453 HOT 3
- RFC review: MaybeDangling -- RFCS#3336 HOT 1
- Design meeting: Decide about the future for consts in patterns
- mdbook build and deploy is failing HOT 1
- We need to settle the behaviour of floating-point in `const` HOT 2
- Meeting proposal: Unsafe extern blocks HOT 3
- Design meeting: Implementable trait aliases
- weak alias types for Rust 2024 HOT 5
- Design meeting: Rust issues encountered by new Rust users in the Bevy project HOT 3
- Nail down cargo-script syntax proposal HOT 2
- T-types proposal for stabilizing type alias impl Trait (TAIT)
- 2024 Edition Review HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lang-team.