summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/expr.rs
AgeCommit message (Collapse)AuthorLines
2022-08-04with_lifetime_binder is now lower_lifetime_binder and doesn't need a closureSantiago Pastorino-32/+31
2022-08-04Completely remove captures flagSantiago Pastorino-21/+7
2022-08-04Add captures flag to capture or not while loweringSantiago Pastorino-7/+21
2022-07-12Add an indirection for closures in `hir::ExprKind`Maybe Waffle-14/+21
This helps bring `hir::Expr` size down, `Closure` was the biggest variant, especially after `for<>` additions.
2022-07-12Lower closure binders to hir & properly check themMaybe Waffle-19/+29
2022-07-12Parse closure bindersMaybe Waffle-0/+24
This is first step in implementing RFC 3216. - Parse `for<'a>` before closures in ast - Error in lowering - Add `closure_lifetime_binder` feature
2022-07-06Remove `sess` field from LoweringContext.Camille GILLOT-13/+20
2022-06-21Use CreateParameter mode for closures too.Camille GILLOT-23/+34
2022-06-17Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoeristerbors-12/+5
Split up `Definitions` and `ResolverAstLowering`. Split off https://github.com/rust-lang/rust/pull/95573 r? `@michaelwoerister`
2022-06-15Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011Yuki Okushi-20/+20
Make `ExprKind::Closure` a struct variant. Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`. r? ``@Aaron1011``
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-8/+1
2022-06-14Do not modify the resolver outputs.Camille GILLOT-2/+2
2022-06-14Make ResolverAstLowering a struct.Camille GILLOT-3/+3
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-1/+1
2022-06-12Make `ExprKind::Closure` a struct variant.Camille GILLOT-20/+20
2022-06-01Remove #[rustc_box] attr during loweringest31-3/+6
2022-06-01Add #[rustc_box]est31-1/+13
This commit adds an alternative content boxing syntax, and uses it inside alloc. The usage inside the very performance relevant code in liballoc is the only remaining relevant usage of box syntax in the compiler (outside of tests, which are comparatively easy to port). box syntax was originally designed to be used by all Rust developers. This introduces a replacement syntax more tailored to only being used inside the Rust compiler, and with it, lays the groundwork for eventually removing box syntax.
2022-05-18Auto merge of #96863 - SparrowLii:let, r=michaelwoeristerbors-2/+8
use `hir::Let` in `hir::Guard::IfLet` This PR fixes the FIXME about using `hir::Let` in `hir::Guard::IfLet`
2022-05-09use hir::Let in hir::GuardSparrowLii-2/+8
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-3/+3
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-03Auto merge of #95380 - compiler-errors:unit-destructure-assign, r=nikomatsakisbors-0/+37
Fix unit struct/enum variant in destructuring assignment See https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md#guide-level-explanation, "including **unit** and tuple structs" Fixes #94319
2022-05-02fix most compiler/ doctestsElliot Roberts-3/+3
2022-04-30Add `do yeet` expressions to allow experimentation in nightlyScott McMurray-0/+39
Using an obviously-placeholder syntax. An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point. But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-27Use LifetimeRes during lowering.Camille GILLOT-1/+0
2022-04-06Fix unit struct/enum variant in destructuring assignmentMichael Goulet-0/+37
2022-03-30async: Give predictable, reserved name to binding generated from .await ↵Michael Woerister-13/+16
expressions. This name makes it to debuginfo and allows debuggers to identify such bindings and their captured versions in suspended async fns.
2022-02-20Rollup merge of #94146 - est31:let_else, r=cjgillotMatthias Krüger-3/+2
Adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
2022-02-19Adopt let else in more placesest31-3/+2
2022-02-17Add more information to `impl Trait` deny errorMichael Goulet-10/+16
2022-01-23Rollup merge of #93103 - estebank:await-span, r=nagisaMatthias Krüger-10/+10
Tweak `expr.await` desugaring `Span` Fix #93074
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-6/+1
2022-01-20Tweak `expr.await` desugaring `Span`Esteban Kuber-10/+10
Fix #93074
2022-01-18Formally implement let chainsCaio-6/+12
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-33/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-33/+0
2022-01-10Use pre-interned symbols in a couple of placesbjorn3-6/+8
2021-12-23implement `generic_arg_infer` for array lengthslcnr-1/+1
2021-12-17Auto merge of #89841 - cormacrelf:let-else-typed, r=nagisabors-5/+9
Implement let-else type annotations natively Tracking issue: #87335 Fixes #89688, fixes #89807, edit: fixes #89960 as well As explained in https://github.com/rust-lang/rust/issues/89688#issuecomment-940405082, the previous desugaring moved the let-else scrutinee into a dummy variable, which meant if you wanted to refer to it again in the else block, it had moved. This introduces a new hir type, ~~`hir::LetExpr`~~ `hir::Let`, which takes over all the fields of `hir::ExprKind::Let(...)` and adds an optional type annotation. The `hir::Let` is then treated like a `hir::Local` when type checking a function body, specifically: * `GatherLocalsVisitor` overrides a new `Visitor::visit_let_expr` and does pretty much exactly what it does for `visit_local`, assigning a local type to the `hir::Let` ~~(they could be deduplicated but they are right next to each other, so at least we know they're the same)~~ * It reuses the code in `check_decl_local` to typecheck the `hir::Let`, simply returning 'bool' for the expression type after doing that. * ~~`FnCtxt::check_expr_let` passes this local type in to `demand_scrutinee_type`, and then imitates check_decl_local's pattern checking~~ * ~~`demand_scrutinee_type` (the blindest change for me, please give this extra scrutiny) uses this local type instead of of creating a new one~~ * ~~Just realised the `check_expr_with_needs` was passing NoExpectation further down, need to pass the type there too. And apparently this Expectation API already exists.~~ Some other misc notes: * ~~Is the clippy code supposed to be autoformatted? I tried not to give huge diffs but maybe some rustfmt changes simply haven't hit it yet.~~ * in `rustc_ast_lowering/src/block.rs`, I noticed some existing `self.alias_attrs()` calls in `LoweringContext::lower_stmts` seem to be copying attributes from the lowered locals/etc to the statements. Is that right? I'm new at this, I don't know.
2021-12-15Rollup merge of #90521 - jhpratt:stabilize-destructuring_assignment, ↵Matthias Krüger-19/+0
r=jackh726,pnkfelix Stabilize `destructuring_assignment` Closes #71126 - [Stabilization report](https://github.com/rust-lang/rust/issues/71126#issuecomment-941148058) - [Completed FCP](https://github.com/rust-lang/rust/issues/71126#issuecomment-954914819) `@rustbot` label +F-destructuring-assignment +T-lang Also needs +relnotes but I don't have permission to add that tag.
2021-12-14Stabilize `destructuring_assignment`Jacob Pratt-19/+0
2021-12-13Fix rebase and clippy testsEsteban Kuber-7/+17
2021-12-13Keep info on pre-desugaring expression for better "incorrect `.await`" ↵Esteban Kuber-11/+40
suggestion Keep the `HirId` of `.await`ed expressions so in the case of a `fn` call on on a sync `fn`, we can suggest maybe turning it into an `async fn`.
2021-12-13When `.await` is called on a non-`Future` expression, suggest removalEsteban Kuber-2/+3
Keep track of the origin of a `T: Future` obligation when caused by an `.await` expression. Address #66731.
2021-12-13let-else: add hir::Let and type check it like a hir::LocalCormac Relf-5/+9
unify typeck of hir::Local and hir::Let remove extraneous pub(crate/super)
2021-12-03Auto merge of #90737 - eholk:intofuture, r=tmandrybors-4/+20
Reintroduce `into_future` in `.await` desugaring This is a reintroduction of the remaining parts from https://github.com/rust-lang/rust/pull/65244 that have not been relanded yet. This isn't quite ready to merge yet. The last attempt was reverting due to performance regressions, so we need to make sure this does not introduce those issues again. Issues #67644, #67982 /cc `@yoshuawuyts`
2021-11-25On type mismatch caused by assignment, point at assigneeEsteban Küber-4/+12
* Do not emit unnecessary E0308 after E0070 * Show fewer errors on `while let` missing `let` * Hide redundant E0308 on `while let` missing `let` * Point at binding definition when possible on invalid assignment * do not point at closure twice * do not suggest `if let` for literals in lhs * account for parameter types
2021-11-22Fix commentsEric Holk-2/+2
2021-11-22Reintroduce `into_future` in `.await` desugaringEric Holk-5/+21
This is a reintroduction of the remaining parts from https://github.com/rust-lang/rust/pull/65244 that have not been relanded yet. Issues GH-67644, GH-67982
2021-11-21Simplify for loop desugarCameron Steffen-99/+38
2021-10-22Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwcoYuki Okushi-21/+18
Don't mark for loop iter expression as desugared We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.