about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
AgeCommit message (Collapse)AuthorLines
2021-03-13Rollup merge of #82984 - camsteffen:lower-block, r=cjgillotYuki Okushi-20/+6
Simplify ast block lowering
2021-03-12Make def_key and HIR parenting consistent.Camille GILLOT-21/+28
2021-03-10Simplify lower ast blockCameron Steffen-20/+6
2021-03-10Auto merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=Amanieubors-4/+4
Implement RFC 2945: "C-unwind" ABI ## Implement RFC 2945: "C-unwind" ABI This branch implements [RFC 2945]. The tracking issue for this RFC is #74990. The feature gate for the issue is `#![feature(c_unwind)]`. This RFC was created as part of the ffi-unwind project group tracked at rust-lang/lang-team#19. ### Changes Further details will be provided in commit messages, but a high-level overview of the changes follows: * A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`, and `Thiscall` variants, marking whether unwinding across FFI boundaries is acceptable. The cases where each of these variants' `unwind` member is true correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings introduced in RFC 2945 [3]. * This commit adds a `c_unwind` feature gate for the new ABI strings. Tests for this feature gate are included in `src/test/ui/c-unwind/`, which ensure that this feature gate works correctly for each of the new ABIs. A new language features entry in the unstable book is added as well. * We adjust the `rustc_middle::ty::layout::fn_can_unwind` function, used to compute whether or not a `FnAbi` object represents a function that should be able to unwind when `panic=unwind` is in use. * Changes are also made to `rustc_mir_build::build::should_abort_on_panic` so that the function ABI is used to determind whether it should abort, assuming that the `panic=unwind` strategy is being used, and no explicit unwind attribute was provided. [RFC 2945]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md
2021-03-09rustc_target: add "unwind" payloads to `Abi`katelyn a. martin-4/+4
### Overview This commit begins the implementation work for RFC 2945. For more information, see the rendered RFC [1] and tracking issue [2]. A boolean `unwind` payload is added to the `C`, `System`, `Stdcall`, and `Thiscall` variants, marking whether unwinding across FFI boundaries is acceptable. The cases where each of these variants' `unwind` member is true correspond with the `C-unwind`, `system-unwind`, `stdcall-unwind`, and `thiscall-unwind` ABI strings introduced in RFC 2945 [3]. ### Feature Gate and Unstable Book This commit adds a `c_unwind` feature gate for the new ABI strings. Tests for this feature gate are included in `src/test/ui/c-unwind/`, which ensure that this feature gate works correctly for each of the new ABIs. A new language features entry in the unstable book is added as well. ### Further Work To Be Done This commit does not proceed to implement the new unwinding ABIs, and is intentionally scoped specifically to *defining* the ABIs and their feature flag. ### One Note on Test Churn This will lead to some test churn, in re-blessing hash tests, as the deleted comment in `src/librustc_target/spec/abi.rs` mentioned, because we can no longer guarantee the ordering of the `Abi` variants. While this is a downside, this decision was made bearing in mind that RFC 2945 states the following, in the "Other `unwind` Strings" section [3]: > More unwind variants of existing ABI strings may be introduced, > with the same semantics, without an additional RFC. Adding a new variant for each of these cases, rather than specifying a payload for a given ABI, would quickly become untenable, and make working with the `Abi` enum prone to mistakes. This approach encodes the unwinding information *into* a given ABI, to account for the future possibility of other `-unwind` ABI strings. ### Ignore Directives `ignore-*` directives are used in two of our `*-unwind` ABI test cases. Specifically, the `stdcall-unwind` and `thiscall-unwind` test cases ignore architectures that do not support `stdcall` and `thiscall`, respectively. These directives are cribbed from `src/test/ui/c-variadic/variadic-ffi-1.rs` for `stdcall`, and `src/test/ui/extern/extern-thiscall.rs` for `thiscall`. This would otherwise fail on some targets, see: https://github.com/rust-lang-ci/rust/commit/fcf697f90206e9c87b39d494f94ab35d976bfc60 ### Footnotes [1]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md [2]: https://github.com/rust-lang/rust/issues/74990 [3]: https://github.com/rust-lang/rfcs/blob/master/text/2945-c-unwind-abi.md#other-unwind-abi-strings
2021-03-09Use BTreeMap to store attributes.Camille GILLOT-30/+60
2021-03-09Alias attributes of hir::Stmt.Camille GILLOT-5/+17
The attributes for statements and those of the statements' content.
2021-03-09Remove hir::Expr::attrs.Camille GILLOT-24/+16
2021-03-09Remove hir::Item::attrs.Camille GILLOT-4/+1
2021-03-09Remove hir::ImplItem::attrs.Camille GILLOT-1/+1
2021-03-09Remove hir::TraitItem::attrs.Camille GILLOT-8/+2
2021-03-09Remove hir::ForeignItem::attrs.Camille GILLOT-1/+1
2021-03-09Remove hir::StructField::attrs.Camille GILLOT-1/+1
2021-03-09Remove hir::Variant::attrs.Camille GILLOT-1/+1
2021-03-09Remove hir::Param::attrs.Camille GILLOT-3/+2
2021-03-09Remove hir::Arm::attrs.Camille GILLOT-16/+3
2021-03-09Remove hir::Crate::attrs.Camille GILLOT-2/+2
2021-03-09Remove hir::MacroDef::attrs.Camille GILLOT-2/+1
2021-03-09Remove hir::GenericParam::attrs.Camille GILLOT-4/+1
2021-03-09Remove hir::Local::attrs.Camille GILLOT-12/+2
2021-03-09Take a slice in stmt_let_pat.Camille GILLOT-9/+16
2021-03-09Collect attributes during HIR lowering.Camille GILLOT-53/+89
2021-03-08Rollup merge of #82854 - estebank:issue-82827, r=oli-obkMara Bos-2/+40
Account for `if (let pat = expr) {}` Fix #82827.
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-03-06Edit ructc_ast_lowering docspierwill-7/+9
Fixes some punctuation and formatting; also makes some small wording changes.
2021-02-25Auto merge of #82447 - Amanieu:legacy_const_generics, r=oli-obkbors-2/+58
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-25Add a cache for rustc_legacy_const_genericsAmanieu d'Antras-1/+1
2021-02-25Address review commentsAmanieu d'Antras-51/+9
2021-02-24TODO -> FIXMEAmanieu d'Antras-1/+1
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-2/+100
2021-02-23Rollup merge of #82308 - estebank:issue-82290, r=lcnrDylan DPC-1/+2
Lower condition of `if` expression before it's "then" block Fix #82290, fix #82250.
2021-02-19Lower condition of `if` expression before it's "then" blockEsteban Küber-1/+2
Fix #82290, fix #82250.
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-1/+6
Also remove `ast::Mod` which is mostly redundant now
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-37/+24
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-16Auto merge of #81611 - cjgillot:meowner, r=estebankbors-51/+57
Only store a LocalDefId in some HIR nodes Some HIR nodes are guaranteed to be HIR owners: Item, TraitItem, ImplItem, ForeignItem and MacroDef. As a consequence, we do not need to store the `HirId`'s `local_id`, and we can directly store a `LocalDefId`. This allows to avoid a bit of the dance with `tcx.hir().local_def_id` and `tcx.hir().local_def_id_to_hir_id` mappings.
2021-02-16avoid full-slicing slicesMatthias Krüger-1/+1
If we already have a slice, there is no need to get another full-range slice from that, just use the original. clippy::redundant_slicing
2021-02-15Trait impls are Items, therefore HIR owners.Camille GILLOT-6/+4
2021-02-15Only store a LocalDefId in hir::MacroDef.Camille GILLOT-2/+2
2021-02-15Index Modules using their LocalDefId.Camille GILLOT-8/+8
2021-02-15Only store a LocalDefId in hir::ForeignItem.Camille GILLOT-3/+3
2021-02-15Only store a LocalDefId in hir::ImplItem.Camille GILLOT-3/+3
2021-02-15Only store a LocalDefId in hir::TraitItem.Camille GILLOT-3/+3
2021-02-15Only store a LocalDefId in hir::Item.Camille GILLOT-22/+28
Items are guaranteed to be HIR owner.
2021-02-15Use ItemId as a strongly typed index.Camille GILLOT-5/+7
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-02-04lowering of generic args in AssocTyConstraintb-naber-9/+37
2021-02-02Auto merge of #81405 - bugadani:ast, r=cjgillotbors-20/+29
Box the biggest ast::ItemKind variants This PR is a different approach on https://github.com/rust-lang/rust/pull/81400, aiming to save memory in humongous ASTs. The three affected item kind enums are: - `ast::ItemKind` (208 -> 112 bytes) - `ast::AssocItemKind` (176 -> 72 bytes) - `ast::ForeignItemKind` (176 -> 72 bytes)
2021-02-02Bump rustfmt versionMark Rousskov-1/+3
Also switches on formatting of the mir build module
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-20/+29