about summary refs log tree commit diff
path: root/library/core/src/future
AgeCommit message (Collapse)AuthorLines
2025-06-07Address documentation issues identified with FutureDiggory Blake-7/+16
2025-05-12update cfg(bootstrap)Pietro Albini-3/+0
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-273/+41
async_drop_in_place::{closure}, scoped async drop added.
2025-02-15tidying up tidyprogressive-galib-4/+4
2025-02-15replaced the four occurrences of issue ="50547" inprogressive.galib-4/+4
library/core/src/future/mod.rs with issue = "none"
2025-01-08update cfg(bootstrap)Pietro Albini-3/+2
2024-12-20split up `#[rustc_deny_explicit_impl]` attributeLukas Markeffsky-1/+3
This commit splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute into two attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]`. This allows us to have special traits that can have user-defined impls but do not have the automatic trait impl for trait objects (`impl Trait for dyn Trait`).
2024-11-27update cfgsBoxy-1/+1
2024-10-30rustdoc-search: simplify rules for generics and type paramsMichael Howell-0/+1
This commit is a response to feedback on the displayed type signatures results, by making generics act stricter. Generics are tightened by making order significant. This means `Vec<Allocator>` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result<A, B>` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected. Find the discussion on: * <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149> * <https://github.com/rust-lang/rust/pull/124544#issuecomment-2204272265> * <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search/near/476841363>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-7/+7
2024-09-03replace placeholder versionBoxy-1/+1
2024-08-31Fixed more typos in library/coreranger-ross-2/+2
2024-08-08Stabilize `Ready::into_inner()`daxpedda-2/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-12/+8
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-6/+6
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-06-17Add tracking issue to async_drop APIDaria Sukhonina-13/+13
2024-06-11remove cfg(bootstrap)Pietro Albini-2/+1
2024-05-31Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obkbors-0/+13
Implement `needs_async_drop` in rustc and optimize async drop glue This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948. Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](https://github.com/zetanumbers/rust/blob/67980dd6fb11917d23d01a19c2cf4cfc3978aac8/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-29Add lang item for Future::OutputMichael Goulet-1/+1
2024-05-29Add safety comment to fix tidyDaria Sukhonina-0/+2
2024-05-29Optimize async drop glue for some old typesDaria Sukhonina-0/+11
2024-05-01Step bootstrap cfgsMark Rousskov-2/+0
2024-04-16Add simple async drop glue generationzetanumbers-0/+277
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-09Fix typo in `Future::poll()` docsJules Bertholet-1/+1
2024-03-03Use root obligation on E0277 for some casesEsteban Küber-2/+6
When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change).
2024-01-05Replace some usage of `#[rustc_on_unimplemented]` withGeorg Semmler-1/+1
`#[diagnostic::on_unimplemented]` This commit replaces those `#[rustc_on_unimplemented]` attributes with their equivalent `#[diagnostic::on_unimplemented]` where this is supported (So no filter or any extended option)
2023-12-10remove redundant importssurechen-1/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-10-20s/Generator/Coroutine/Oli Scherer-1/+1
2023-06-19Rollup merge of #109970 - ↵Matthias Krüger-0/+87
danielhenrymantilla:add-poll-fn-pin-clarifications, r=thomcc [doc] `poll_fn`: explain how to `pin` captured state safely Usage of `Pin::new_unchecked(&mut …)` is dangerous with `poll_fn`, even though the `!Unpin`-infectiousness has made things smoother. Nonetheless, there are easy ways to avoid the need for any `unsafe` altogether, be it through `Box::pin`ning, or the `pin!` macro. Since the latter only works within an `async` context, showing an example artificially introducing one ought to help people navigate this subtlety with safety and confidence. ## Preview https://user-images.githubusercontent.com/9920355/230092494-da22fdcb-0b8f-4ff4-a2ac-aa7d9ead077a.mov ```@rustbot``` label +A-docs
2023-06-18[doc] poll_fn: explain how to pin captured state safelyDaniel Henry-Mantilla-0/+87
Usage of `Pin::new_unchecked(&mut …)` is dangerous with `poll_fn`, even though the `!Unpin`-infectiousness has made things smoother. Nonetheless, there are easy ways to avoid the need for any `unsafe` altogether, be it through `Box::pin`ning, or the `pin!` macro. Since the latter only works within an `async` context, showing an example artifically introducing one ought to help people navigate this subtlety with safety and confidence.
2023-05-19tidyIbraheem Ahmed-1/+1
2023-05-19remove unstable `Poll::ready`Ibraheem Ahmed-3/+3
2023-05-07Remove `identity_future` from stdlibArpad Borsos-7/+0
This function/lang_item was introduced in #104321 as a temporary workaround of future lowering. The usage and need for it went away in #104833. After a bootstrap update, the function itself can be removed from `std`.
2023-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-0/+1
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-28handle cfg(bootstrap)Pietro Albini-1/+0
2023-04-27Don't call await a methodMichael Goulet-0/+1
2023-03-08Remove `identity_future` indirectionArpad Borsos-5/+1
This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]` annotation.
2023-01-29Remove `GenFuture` from coreArpad Borsos-45/+0
The handling of async constructs in the compiler does not rely on `GenFuture` anymore since `1.67`, so this code can now be removed from `core`.
2023-01-19Transform async ResumeTy in generator transformArpad Borsos-0/+4
- Eliminates all the `get_context` calls that async lowering created. - Replace all `Local` `ResumeTy` types with `&mut Context<'_>`. The `Local`s that have their types replaced are: - The `resume` argument itself. - The argument to `get_context`. - The yielded value of a `yield`. The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`. Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors. See <https://github.com/rust-lang/rust/issues/105501>. The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-03Suggest more impl Trait on `-> _`Michael Goulet-0/+1
2022-12-28Update bootstrap cfgPietro Albini-3/+2
2022-12-19Revert "Replace usage of `ResumeTy` in async lowering with `Context`"Andrew Pollack-8/+2
2022-12-06Replace usage of `ResumeTy` in async lowering with `Context`Arpad Borsos-2/+8
Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air.
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-8/+19
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-17Auto merge of #104219 - bryangarza:async-track-caller-dup, r=eholkbors-0/+1
Support `#[track_caller]` on async fns Adds `#[track_caller]` to the generator that is created when we desugar the async fn. Fixes #78840 Open questions: - What is the performance impact of adding `#[track_caller]` to every `GenFuture`'s `poll(...)` function, even if it's unused (i.e., the parent span does not set `#[track_caller]`)? We might need to set it only conditionally, if the indirection causes overhead we don't want.
2022-11-09Allow and add `track_caller` to generatorsBryan Garza-0/+1
This patch allows the usage of the `track_caller` annotation on generators, as well as sets them conditionally if the parent also has `track_caller` set. Also add this annotation on the `GenFuture`'s `poll()` function.
2022-10-06poll_fn and Unpin: fix pinningRalf Jung-4/+7
2022-08-30Implement `Ready::into_inner()`dAxpeDDa-0/+24
2022-07-16Stabilize `future_poll_fn`Yuki Okushi-9/+8
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-06-30Stabilize `into_future`Yoshua Wuyts-14/+6