summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/expr.rs
AgeCommit message (Collapse)AuthorLines
2023-04-27Make async removal span more resilient to macro expansionsMichael Goulet-10/+2
2023-04-27Tweak await spanMichael Goulet-14/+8
2023-04-26IntoFuture::into_future is no longer unstableMichael Goulet-6/+1
2023-04-21offset_ofDrMeepster-0/+7
2023-04-16Alloc `hir::Lit` in an arena to remove the destructor from `Expr`Nilstrieb-30/+25
This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena. This is something I'm working on.
2023-04-10Fix typos in compilerDaniPopes-3/+3
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-40/+37
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-37/+27
Remove `identity_future` indirection 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. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-1/+0
2023-03-08Remove `identity_future` indirectionArpad Borsos-37/+27
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-03-02Restrict `#[rustc_box]` to `Box::new` callsclubby789-10/+2
2023-02-25Add ErrorGuaranteed to HIR ExprKind::ErrMichael Goulet-8/+11
2023-02-21Use `ThinVec` in `ast::AngleBracketedArgs`.Nicholas Nethercote-1/+1
2023-02-21Use `ThinVec` in various AST types.Nicholas Nethercote-2/+2
This commit changes the sequence parsers to produce `ThinVec`, which triggers numerous conversions.
2023-02-14Better label for illegal impl trait typesMichael Goulet-2/+2
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-6/+82
Move format_args!() into AST (and expand it during AST lowering) Implements https://github.com/rust-lang/compiler-team/issues/541 This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier. This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`. This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-12parse const closuresDeadbeef-0/+6
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-0/+1
2023-01-11Expose some LoweringContext methods.Mara Bos-5/+9
2023-01-11Add some helper functions to LoweringContext.Mara Bos-1/+72
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-2/+2
2022-12-21Update track_caller tests; run fmtBryan Garza-5/+2
2022-12-21Improve code based on feedback.Bryan Garza-22/+20
This patch improves the readability of some of the code by using if-let-chains. Also, make use of the `add_feature_diagnostics` function.
2022-12-21Update track_caller logic/lint after rebaseBryan Garza-26/+27
2022-12-19Revert "Replace usage of `ResumeTy` in async lowering with `Context`"Andrew Pollack-36/+21
2022-12-13Rollup merge of #105464 - nbdd0121:hir, r=compiler-errorsMatthias Krüger-37/+48
Support #[track_caller] on async closures Follow up on #105180 r? ```@compiler-errors``` cc ```@cjgillot```
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-1/+1
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
2022-12-08Move paren expr and loop HIR loweringGary Guo-28/+37
2022-12-08Support `#[track_caller]` on async closuresGary Guo-9/+11
2022-12-07Rollup merge of #105343 - nbdd0121:hir, r=fee1-deadMatthias Krüger-94/+39
Simplify attribute handling in rustc_ast_lowering Given that attributes is stored in a separate BTreeMap, it's not necessary to pass it in when constructing `hir::Expr`. We can just construct `hir::Expr` and then call `self.lower_attrs` later if it needs attributes. As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-06Replace usage of `ResumeTy` in async lowering with `Context`Arpad Borsos-21/+36
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-12-06Simplify attribute handling in rustc_ast_loweringGary Guo-94/+39
Given that attributes is stored in a separate BTreeMap, it's not necessary to pass it in when constructing `hir::Expr`. We can just construct `hir::Expr` and then call `self.lower_attrs` later if it needs attributes. As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-05Rollup merge of #105180 - nbdd0121:async_track_caller, r=compiler-errorsMatthias Krüger-14/+18
Use proper HirId for async track_caller attribute check Fix #105134
2022-12-05Add fixme noteGary Guo-0/+2
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-0/+8
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-03Auto merge of #105133 - oli-obk:promoted_def_ids, r=cjgillotbors-1/+1
Ensure query backtraces work for `DefId`s created after ast lowering r? `@cjgillot`
2022-12-02Use proper HirId for async track_caller attribute checkGary Guo-14/+16
2022-12-02Add `StrStyle` to `ast::LitKind::ByteStr`.Nicholas Nethercote-1/+1
This is required to distinguish between cooked and raw byte string literals in an `ast::LitKind`, without referring to an adjacent `token::Lit`. It's a prerequisite for the next commit.
2022-12-01Fill in `def_span` when creating def ids.Oli Scherer-1/+1
This makes sure that ICEing because of def ids created outside of ast lowering will be able to produce a query backtrace and not cause a double panic because of trying to call the `def_span` query
2022-11-29Avoid more `MetaItem`-to-`Attribute` conversions.Nicholas Nethercote-10/+7
There is code for converting `Attribute` (syntactic) to `MetaItem` (semantic). There is also code for the reverse direction. The reverse direction isn't really necessary; it's currently only used when generating attributes, e.g. in `derive` code. This commit adds some new functions for creating `Attributes`s directly, without involving `MetaItem`s: `mk_attr_word`, `mk_attr_name_value_str`, `mk_attr_nested_word`, and `ExtCtxt::attr_{word,name_value_str,nested_word}`. These new methods replace the old functions for creating `Attribute`s: `mk_attr_inner`, `mk_attr_outer`, and `ExtCtxt::attribute`. Those functions took `MetaItem`s as input, and relied on many other functions that created `MetaItems`, which are also removed: `mk_name_value_item`, `mk_list_item`, `mk_word_item`, `mk_nested_word_item`, `{MetaItem,MetaItemKind,NestedMetaItem}::token_trees`, `MetaItemKind::attr_args`, `MetaItemLit::{from_lit_kind,to_token}`, `ExtCtxt::meta_word`. Overall this cuts more than 100 lines of code and makes thing simpler.
2022-11-28Keep track of the start of the argument block of a closureSarthak Singh-0/+8
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-2/+3
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-24Record in HIR whether lifetime elision was succesful.Camille GILLOT-2/+3
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-13/+23
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. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-13/+23
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-23Fix rebaseEsteban Küber-1/+1
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-2/+2
2022-11-23Rollup merge of #104721 - WaffleLapkin:deref-harder, r=oli-obkDylan DPC-84/+78
Remove more `ref` patterns from the compiler r? `@oli-obk` Previous PR: https://github.com/rust-lang/rust/pull/104500
2022-11-22Rollup merge of #104612 - Swatinem:async-ret-y, r=estebankManish Goregaokar-9/+9
Lower return type outside async block creation This allows feeding a different output type to async blocks with a different `ImplTraitContext`. Spotted this while working on #104321
2022-11-22`rustc_ast_lowering`: remove `ref` patternsMaybe Waffle-84/+78