about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/expr.rs
AgeCommit message (Collapse)AuthorLines
2021-07-09Update the comment on `lower_expr_try`Scott McMurray-7/+8
I'd updated the ones inside the method, but not its doc comment.
2021-06-10Add support for using qualified paths with structs in expression and patternRyan Levick-9/+11
position.
2021-05-18Auto merge of #84767 - scottmcm:try_trait_actual, r=lcnrbors-32/+26
Implement the new desugaring from `try_trait_v2` ~~Currently blocked on https://github.com/rust-lang/rust/issues/84782, which has a PR in https://github.com/rust-lang/rust/pull/84811~~ Rebased atop that fix. `try_trait_v2` tracking issue: https://github.com/rust-lang/rust/issues/84277 Unfortunately this is already touching a ton of things, so if you have suggestions for good ways to split it up, I'd be happy to hear them. (The combination between the use in the library, the compiler changes, the corresponding diagnostic differences, even MIR tests mean that I don't really have a great plan for it other than trying to have decently-readable commits. r? `@ghost` ~~(This probably shouldn't go in during the last week before the fork anyway.)~~ Fork happened.
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-318/+3
On x86, the default syntax is also switched to Intel to match asm!
2021-05-08Make `Diagnostic::span_fatal` unconditionally raise an errorJoshua Nelson-3/+1
It had no callers which didn't immediately call `raise()`, and this unifies the behavior with `Session`.
2021-05-06Actually implement the feature in the compilerScott McMurray-32/+26
Including all the bootstrapping tweaks in the library.
2021-04-29Make current_hir_id_owner a simple tuple.Camille GILLOT-1/+1
2021-04-07Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkovDylan DPC-3/+3
Use AnonConst for asm! constants This replaces the old system which used explicit promotion. See #83169 for more background. The syntax for `const` operands is still the same as before: `const <expr>`. Fixes #83169 Because the implementation is heavily based on inline consts, we suffer from the same issues: - We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`. - We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-06Use AnonConst for asm! constantsAmanieu d'Antras-3/+3
2021-04-04Allow clobbering unsupported registers in asm!Amanieu d'Antras-32/+50
Previously registers could only be marked as clobbered if the target feature for that register was enabled. This restriction is now removed.
2021-03-17Auto merge of #83188 - petrochenkov:field, r=lcnrbors-14/+20
ast/hir: Rename field-related structures I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent. - `StructField` -> `FieldDef` ("field definition") - `Field` -> `ExprField` ("expression field", not "field expression") - `FieldPat` -> `PatField` ("pattern field", not "field pattern") Various visiting and other methods working with the fields are renamed correspondingly too. The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-16ast: Reduce size of `ExprKind` by boxing fields of `ExprKind::Struct`Vadim Petrochenkov-8/+9
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-7/+12
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-13Always lower asm! to valid HIRAmanieu d'Antras-45/+44
2021-03-09Use BTreeMap to store attributes.Camille GILLOT-9/+15
2021-03-09Remove hir::Expr::attrs.Camille GILLOT-22/+14
2021-03-09Remove hir::Param::attrs.Camille GILLOT-1/+1
2021-03-09Remove hir::Arm::attrs.Camille GILLOT-16/+3
2021-03-09Take a slice in stmt_let_pat.Camille GILLOT-3/+3
2021-03-09Collect attributes during HIR lowering.Camille GILLOT-9/+11
2021-03-07Remove notes, increase S/N ratioEsteban Küber-18/+11
2021-03-07Account for `if (let pat = expr) {}`Esteban Küber-2/+47
Partially address #82827.
2021-02-25Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obkbors-2/+56
Add #[rustc_legacy_const_generics] This is the first step towards removing `#[rustc_args_required_const]`: a new attribute is added which rewrites function calls of the form `func(a, b, c)` to `func::<{b}>(a, c)`. This allows previously stabilized functions in `stdarch` which use `rustc_args_required_const` to use const generics instead. This new attribute is not intended to ever be stabilized, it is only intended for use in `stdarch` as a replacement for `#[rustc_args_required_const]`. ```rust #[rustc_legacy_const_generics(1)] pub fn foo<const Y: usize>(x: usize, z: usize) -> [usize; 3] { [x, Y, z] } fn main() { assert_eq!(foo(0 + 0, 1 + 1, 2 + 2), [0, 2, 4]); assert_eq!(foo::<{1 + 1}>(0 + 0, 2 + 2), [0, 2, 4]); } ``` r? `@oli-obk`
2021-02-25Address review commentsAmanieu d'Antras-40/+8
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-2/+88
2021-02-19Lower condition of `if` expression before it's "then" blockEsteban Küber-1/+2
Fix #82290, fix #82250.
2021-02-09Rename HIR UnOp variantsÖmer Sinan Ağacan-3/+3
This renames the variants in HIR UnOp from enum UnOp { UnDeref, UnNot, UnNeg, } to enum UnOp { Deref, Not, Neg, } Motivations: - This is more consistent with the rest of the code base where most enum variants don't have a prefix. - These variants are never used without the `UnOp` prefix so the extra `Un` prefix doesn't help with readability. E.g. we don't have any `UnDeref`s in the code, we only have `UnOp::UnDeref`. - MIR `UnOp` type variants don't have a prefix so this is more consistent with MIR types. - "un" prefix reads like "inverse" or "reverse", so as a beginner in rustc code base when I see "UnDeref" what comes to my mind is something like "&*" instead of just "*".
2021-01-23Rollup merge of #81249 - cjgillot:issue-79537, r=oli-obkJonas Schievink-13/+18
Lower closure prototype after its body. Fixes #79537. r? `@Mark-Simulacrum`
2021-01-21Add loop head span to hirEsteban Küber-4/+15
2021-01-21Lower closure prototype after its body.Camille GILLOT-13/+18
2021-01-07Reintroduce hir::ExprKind::IfCaio-25/+31
2020-12-17Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasperYuki Okushi-5/+10
Implement if-let match guards Implements rust-lang/rfcs#2294 (tracking issue: #51114). I probably should do a few more things before this can be merged: - [x] Add tests (added basic tests, more advanced tests could be done in the future?) - [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements) - [x] Fix clippy However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs. Thanks a lot `@matthewjasper` :heart: for helping me with lowering to MIR! Would you be interested in reviewing this? r? `@ghost` for now
2020-12-06Retain assembly operands span when lowering AST to HIRTomasz Miąsko-6/+4
2020-12-06Introduce if-let guards in the HIRLeSeulArtichaut-5/+10
2020-12-03Combination of commitsRich Kadel-1/+1
Fixes multiple issue with counters, with simplification Includes a change to the implicit else span in ast_lowering, so coverage of the implicit else no longer spans the `then` block. Adds coverage for unused closures and async function bodies. Fixes: #78542 Adding unreachable regions for known MIR missing from coverage map Cleaned up PR commits, and removed link-dead-code requirement and tests Coverage no longer depends on Issue #76038 (`-C link-dead-code` is no longer needed or enforced, so MSVC can use the same tests as Linux and MacOS now) Restrict adding unreachable regions to covered files Improved the code that adds coverage for uncalled functions (with MIR but not-codegenned) to avoid generating coverage in files not already included in the files with covered functions. Resolved last known issue requiring --emit llvm-ir workaround Fixed bugs in how unreachable code spans were added.
2020-11-23Lower `if let` before the arms.Camille GILLOT-2/+2
2020-11-15Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkovJonas Schievink-1/+18
Make `_` an expression, to discard values in destructuring assignments This is the third and final step towards implementing destructuring assignment (RFC: rust-lang/rfcs#2909, tracking issue: #71126). This PR is the third and final part of #71156, which was split up to allow for easier review. With this PR, an underscore `_` is parsed as an expression but is allowed *only* on the left-hand side of a destructuring assignment. There it simply discards a value, similarly to the wildcard `_` in patterns. For instance, ```rust (a, _) = (1, 2) ``` will simply assign 1 to `a` and discard the 2. Note that for consistency, ``` _ = foo ``` is also allowed and equivalent to just `foo`. Thanks to ````@varkor```` who helped with the implementation, particularly around pre-expansion gating. r? ````@petrochenkov````
2020-11-14Add underscore expressions for destructuring assignmentsFabian Zaiser-1/+18
Co-authored-by: varkor <github@varkor.com>
2020-11-13Reuse vectorDániel Buga-1/+5
2020-11-11Implement destructuring assignment for structs and slicesFabian Zaiser-7/+119
Co-authored-by: varkor <github@varkor.com>
2020-11-07Implement destructuring assignment for tuplesFabian Zaiser-1/+130
Co-authored-by: varkor <github@varkor.com>
2020-10-21Unconditionally capture tokens for attributes.Aaron Hill-3/+5
This allows us to avoid synthesizing tokens in `prepend_attr`, since we have the original tokens available. We still need to synthesize tokens when expanding `cfg_attr`, but this is an unavoidable consequence of the syntax of `cfg_attr` - the user does not supply the `#` and `[]` tokens that a `cfg_attr` expands to.
2020-10-18Auto merge of #78066 - bugadani:wat, r=jonas-schievinkbors-44/+39
Clean up small, surprising bits of code This PR clean up a small number of unrelated, small things I found while browsing the code base.
2020-10-18Early return to decrease indentationDániel Buga-44/+39
2020-10-16Lower inline const's AST to HIRSantiago Pastorino-2/+3
2020-10-16Parse inline const expressionsSantiago Pastorino-0/+3
2020-10-15Replace target.target with target and target.ptr_width with target.pointer_widthest31-1/+1
Preparation for a subsequent change that replaces rustc_target::config::Config with its wrapped Target. On its own, this commit breaks the build. I don't like making build-breaking commits, but in this instance I believe that it makes review easier, as the "real" changes of this PR can be seen much more easily. Result of running: find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \; find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \; find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \; ./x.py fmt
2020-10-06Separate bounds and predicates for associated/opaque typesMatthew Jasper-11/+19
2020-09-10use sort_unstable to sort primitive typesMatthias Krüger-2/+3
It's not important to retain original order if we have &[1, 1, 2, 3] for example. clippy::stable_sort_primitive
2020-08-30mv compiler to compiler/mark-0/+1789