summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
AgeCommit message (Collapse)AuthorLines
2021-03-18hir: Preserve used syntax in `TyKind::TraitObject`Vadim Petrochenkov-1/+2
2021-03-17Auto merge of #83188 - petrochenkov:field, r=lcnrbors-22/+28
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-17Rollup merge of #83124 - cjgillot:iiib, r=petrochenkovYuki Okushi-63/+15
Do not insert impl_trait_in_bindings opaque definitions twice. The reference to the item already appears inside the `OpaqueDef`. It does not need to be repeated as a statement.
2021-03-17Rollup merge of #83092 - petrochenkov:qspan, r=estebankYuki Okushi-5/+8
More precise spans for HIR paths `Ty::assoc_item` is lowered to `<Ty>::assoc_item` in HIR, but `Ty` got span from the whole path. This PR fixes that, and adjusts some diagnostic code that relied on `Ty` having the whole path span. This is a pre-requisite for https://github.com/rust-lang/rust/pull/82868 (we cannot report suggestions like `Tr::assoc` -> `<dyn Tr>::assoc` with the current imprecise spans). r? ````@estebank````
2021-03-16Auto merge of #82838 - Amanieu:rustdoc_asm, r=nagisabors-45/+44
Allow rustdoc to handle asm! of foreign architectures This allows rustdoc to process code containing `asm!` for architectures other than the current one. Since this never reaches codegen, we just replace target-specific registers and register classes with a dummy one. Fixes #82869
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-15/+20
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-15More precise spans for HIR pathsVadim Petrochenkov-5/+8
2021-03-15Special case type aliases from impl trait in const/static typesOli Scherer-2/+2
2021-03-14Remove dead code.Camille GILLOT-25/+0
2021-03-14Do not insert impl_trait_in_bindings opaque definitions twice.Camille GILLOT-38/+15
2021-03-13Always lower asm! to valid HIRAmanieu d'Antras-45/+44
2021-03-13Auto merge of #82891 - cjgillot:monoparent, r=petrochenkovbors-21/+28
Make def_key and HIR parenting consistent. r? `@petrochenkov`
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