about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/thir.rs
AgeCommit message (Collapse)AuthorLines
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-1/+1
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-28Move `mir::Field` → `abi::FieldIdx`Scott McMurray-5/+5
The first PR for https://github.com/rust-lang/compiler-team/issues/606 This is just the move-and-rename, because it's plenty big-and-bitrotty already. Future PRs will start using `FieldIdx` more broadly, and concomitantly removing `FieldIdx::new`s.
2023-03-02Make `ExprKind` the first field in `thir::Expr`Nilstrieb-3/+3
This makes its `Debug` impl print it first which is useful, as it's the most important part when looking at an expr.
2023-02-27Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obkbors-3/+23
Avoid invoking typeck from borrowck This PR attempts to reduce direct dependencies between typeck and MIR-related queries. The goal is to have all the information transit either through THIR or through dedicated queries that avoid depending on the whole `TypeckResults`. In a first commit, we store the type information that MIR building requires into THIR. This avoids edges between mir_built and typeck. In the second and third commit, we wrap informations around closures (upvars, kind origin and user-provided signature) to avoid borrowck depending on typeck information. There should be a single remaining borrowck -> typeck edge in the good path, due to inline consts.
2023-02-26Move THIR printing to rustc_mir_build.Camille GILLOT-1/+0
2023-02-26Store the body type in THIR.Camille GILLOT-3/+23
2023-01-26output tree representation for thir-treeb-naber-0/+1
2023-01-11Migrate deconstruct_pat.rsmejrs-0/+7
2022-12-18A few small cleanups for `newtype_index`Nilstrieb-2/+1
Remove the `..` from the body, only a few invocations used it and it's inconsistent with rust syntax. Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18Make `#[debug_format]` an attribute in `newtype_index`Nilstrieb-1/+1
This removes the `custom` format functionality as its only user was trivially migrated to using a normal format. If a new use case for a custom formatting impl pops up, you can add it back.
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-2/+1
2022-10-12Use `tidy-alphabetical` in the compilerNilstrieb-1/+2
2022-10-10Fix compiler docsGuillaume Gomez-1/+1
2022-09-26remove cfg(bootstrap)Pietro Albini-4/+0
2022-09-17Auto merge of #98588 - b-naber:valtrees-cleanup, r=lcnrbors-2/+2
Use only ty::Unevaluated<'tcx, ()> in type system r? `@lcnr`
2022-09-14address review againb-naber-2/+2
2022-09-13Also compute implicit params in THIR.Camille GILLOT-3/+5
2022-09-13Compute explicit MIR params on THIR.Camille GILLOT-0/+25
2022-09-07Use niche-filling optimization even when multiple variants have data.Michael Benfield-4/+8
Fixes #46213
2022-09-03Include enum path in variant suggestionMichael Goulet-11/+27
2022-09-02Use boxed slices in `PatKind`.Nicholas Nethercote-10/+10
To shrink it a little more.
2022-09-02Box `CanonicalUserTypeAnnotation::CanonicalUserType`.Nicholas Nethercote-2/+2
This shrinks `Ascription`, which shrinks `PatKind::AscribeUserType`, which shrinks `Pat`.
2022-09-02Box `PatKind::Range`.Nicholas Nethercote-5/+5
Because it's the biggest variant. Also, make `PatRange` non-`Copy`, because it's 104 bytes, which is pretty big.
2022-09-02Clean up THIR patterns.Nicholas Nethercote-24/+24
`thir::Pat::kind` is a `Box<PatKind>`, which doesn't follow the usual pattern in AST/HIR/THIR which is that the "kind" enum for a node is stored inline within the parent struct. This commit makes the `PatKind` directly inline within the `Pat`. This requires using `Box<Pat>` in all the types that hold a `Pat. Ideally, `Pat` would be stored in `Thir` like `Expr` and `Stmt` and referred to with a `PatId` rather than `Box<Pat>`. But this is hard to do because lots of `Pat`s get created after the destruction of the `Cx` that does normal THIR building. But this does get us a step closer to `PatId`, because all the `Box<Pat>` occurrences would be replaced with `PatId` if `PatId` ever happened. At 128 bytes, `Pat` is large. Subsequent commits will shrink it.
2022-08-24Add some more THIR size assertions.Nicholas Nethercote-0/+3
2022-08-24Rename `thir::Adt` as `thir::AdtExpr`.Nicholas Nethercote-2/+2
This matches the naming scheme used elsewhere, e.g. in the AST, and avoids name clashes with the `ExprKind::Closure` variant.
2022-08-24Box `thir::ExprKind::InlineAsm`.Nicholas Nethercote-7/+10
This shrinks `thir::Expr`.
2022-08-24Box `thir::ExprKind::Closure`.Nicholas Nethercote-8/+11
This shrinks `thir::Expr`.
2022-08-24Store blocks in `Thir`.Nicholas Nethercote-3/+4
Like expressions, statements, and match arms. This shrinks `thir::Stmt` and is a precursor to further shrinking `thir::Expr`.
2022-08-24Box `user_ty` fields in `thir::ExprKind`.Nicholas Nethercote-12/+12
This shrinks several large variants of `ExprKind`.
2022-08-24Define index types within `thir_with_elements`.Nicholas Nethercote-28/+13
The macro already generates other stuff, might as well generate these index types as well.
2022-08-10Avoid repeating qualifiers on `static_assert_size` calls.Nicholas Nethercote-4/+4
Some of these don't need a `use` statement because there is already a `#[macro_use] extern crate rustc_data_structures` item in the crate.
2022-08-01Rollup merge of #100003 - nnethercote:improve-size-assertions, r=lqdMatthias Krüger-4/+11
Improve size assertions. - For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order. r? `@lqd`
2022-08-01Improve size assertions.Nicholas Nethercote-4/+11
- For any file with four or more size assertions, move them into a separate module (as is already done for `hir.rs`). - Add some more for AST nodes and THIR nodes. - Put the `hir.rs` ones in alphabetical order.
2022-07-30Use LocalDefId for closures moreCameron Steffen-1/+2
2022-07-14Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnrDylan DPC-1/+0
Move abstract const to middle Moves AbstractConst (and all associated methods) to rustc middle for use in `rustc_infer`. This allows for const resolution in infer to use abstract consts to walk consts and check if they are resolvable. This attempts to resolve the issue where `Foo<{ concrete const }, generic T>` is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved. r? `@lcnr`
2022-07-12Move abstract const to rustc_middle::tykadmin-1/+0
2022-07-11lower let-else in MIR insteadDing Xiang Fei-0/+3
2022-07-09review feedbackRalf Jung-6/+0
2022-07-09don't allow ZST in ScalarIntRalf Jung-1/+5
There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So instead add new ZST variants to those types that did not have other variants which could be used for this purpose.
2022-07-05Add #[derive(TypeVisitable)]Alan Egerton-12/+2
2022-06-09thir: wrap hir id of vars into local var idDing Xiang Fei-3/+17
2022-05-23Fix precise field capture of univariant enumsTomasz Miąsko-1/+3
When constructing a MIR from a THIR field expression, introduce an additional downcast projection before accessing a field of an enum. When rebasing a place builder on top of a captured place, account for the fact that a single HIR enum field projection corresponds to two MIR projection elements: a downcast element and a field element.
2022-05-21correctly deal with user type ascriptions in patlcnr-41/+9
2022-05-16use GlobalId in eval_to_valtree query and introduce query for ↵b-naber-3/+3
valtree_to_const_val
2022-04-20Make all thir types implement cloneXavier Denis-12/+12
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-1/+2
global_asm!
2022-04-02rebase and use ty::Const in patterns againb-naber-6/+2
2022-04-02do use ty::Const in patterns and abstract constsb-naber-4/+8
2022-04-02change thir to use mir::ConstantKind instead of ty::Constb-naber-8/+8