]> git.lizzy.rs Git - rust.git/commit
Avoid `GenFuture` shim when compiling async constructs
authorArpad Borsos <swatinem@swatinem.de>
Fri, 18 Nov 2022 21:56:22 +0000 (22:56 +0100)
committerArpad Borsos <swatinem@swatinem.de>
Thu, 24 Nov 2022 09:04:27 +0000 (10:04 +0100)
commit9f36f988ad873f5d34cd9c08e4903c597ffc9532
tree48825cd5da62cbc7f585c6c991a3b8e25d01dd20
parentfd815a5091eb4d49cd317f8ad272f17b7a5f550d
Avoid `GenFuture` shim when compiling async constructs

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.
41 files changed:
compiler/rustc_ast_lowering/src/expr.rs
compiler/rustc_borrowck/src/diagnostics/region_errors.rs
compiler/rustc_borrowck/src/type_check/mod.rs
compiler/rustc_const_eval/src/transform/check_consts/check.rs
compiler/rustc_hir/src/lang_items.rs
compiler/rustc_hir_typeck/src/check.rs
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
compiler/rustc_lint/src/unused.rs
compiler/rustc_middle/src/traits/mod.rs
compiler/rustc_middle/src/traits/select.rs
compiler/rustc_middle/src/traits/structural_impls.rs
compiler/rustc_middle/src/ty/print/pretty.rs
compiler/rustc_mir_transform/src/generator.rs
compiler/rustc_resolve/src/late.rs
compiler/rustc_span/src/symbol.rs
compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
compiler/rustc_trait_selection/src/traits/project.rs
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
compiler/rustc_trait_selection/src/traits/select/confirmation.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_trait_selection/src/traits/util.rs
compiler/rustc_traits/src/chalk/lowering.rs
compiler/rustc_ty_utils/src/instance.rs
library/core/src/future/mod.rs
library/core/src/task/poll.rs
src/test/codegen/async-fn-debug-awaitee-field.rs
src/test/run-make/coverage-reports/expected_show_coverage.async2.txt
src/test/ui/async-await/async-block-control-flow-static-semantics.stderr
src/test/ui/async-await/async-borrowck-escaping-block-error.stderr
src/test/ui/async-await/generator-desc.stderr
src/test/ui/async-await/issue-68112.drop_tracking.stderr
src/test/ui/async-await/issue-68112.no_drop_tracking.stderr
src/test/ui/async-await/issue-70935-complex-spans.drop_tracking.stderr
src/test/ui/async-await/issues/issue-78938-async-block.stderr
src/test/ui/async-await/try-on-option-in-async.stderr
src/test/ui/chalkify/bugs/async.stderr
src/test/ui/lazy-type-alias-impl-trait/freeze_cycle.rs
src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
src/tools/clippy/clippy_lints/src/doc.rs
src/tools/clippy/clippy_lints/src/manual_async_fn.rs
src/tools/clippy/tests/ui/author/blocks.stdout