about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/thir
AgeCommit message (Collapse)AuthorLines
2023-11-29Add `never_patterns` feature gateNadrieril-1/+1
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-2/+2
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-06Visit patterns in THIR let expressionsMatthew Jasper-1/+2
This fixes some THIR unsafety checking errors not being emitted for let expressions in these situations.
2023-10-16Address review commentsMatthew Jasper-1/+1
Clean up code and add comments. Use InlineConstant to wrap range patterns.
2023-10-16Fix inline const pattern unsafety checking in THIRMatthew Jasper-3/+4
THIR unsafety checking was getting a cycle of function unsafety checking -> building THIR for the function -> evaluating pattern inline constants in the function -> building MIR for the inline constant -> checking unsafety of functions (so that THIR can be stolen) This is fixed by not stealing THIR when generating MIR but instead when unsafety checking. This leaves an issue with pattern inline constants not being unsafety checked because they are evaluated away when generating THIR. To fix that we now represent inline constants in THIR patterns and visit them in THIR unsafety checking.
2023-10-14Propagate pattern errors via a new `PatKind::Error` variantNadrieril-1/+1
Instead of via `Const::new_error`
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-3/+3
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-1/+1
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-5/+5
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-1/+1
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-06-27`thir`: Add `Become` expression kindMaybe Waffle-0/+1
2023-04-21offset_ofDrMeepster-0/+1
2023-04-03Add Span to StmtKind::Let.Camille GILLOT-0/+1
2023-02-26Move THIR printing to rustc_mir_build.Camille GILLOT-881/+0
2023-01-27address reviewb-naber-7/+7
2023-01-26output tree representation for thir-treeb-naber-0/+881
2022-09-02Use boxed slices in `PatKind`.Nicholas Nethercote-3/+3
To shrink it a little more.
2022-09-02Clean up THIR patterns.Nicholas Nethercote-2/+2
`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-24Rename `thir::Adt` as `thir::AdtExpr`.Nicholas Nethercote-3/+3
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-2/+2
This shrinks `thir::Expr`.
2022-08-24Box `thir::ExprKind::Closure`.Nicholas Nethercote-2/+9
This shrinks `thir::Expr`.
2022-08-24Store blocks in `Thir`.Nicholas Nethercote-2/+2
Like expressions, statements, and match arms. This shrinks `thir::Stmt` and is a precursor to further shrinking `thir::Expr`.
2022-07-14Rollup merge of #99000 - JulianKnodt:allow_resolve_no_substs, r=lcnrDylan DPC-61/+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-61/+0
2022-07-11lower let-else in MIR insteadDing Xiang Fei-0/+4
2022-07-09don't allow ZST in ScalarIntRalf Jung-0/+1
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-05impl TypeVisitable in type traversal macrosAlan Egerton-1/+1
2022-05-23Fix precise field capture of univariant enumsTomasz Miąsko-1/+1
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-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-2/+2
global_asm!
2022-04-06get rid of visit_constant in thir visitorb-naber-2/+8
2022-04-02rebase and use ty::Const in patterns againb-naber-1/+0
2022-04-02do use ty::Const in patterns and abstract constsb-naber-6/+1
2022-04-02change thir to use mir::ConstantKind instead of ty::Constb-naber-1/+10
2022-03-23use NonHirLiteral instead of ScalarLiteral, move pattern related code to ↵b-naber-1/+1
pat_is_poly in IsThirPolymorphic
2022-03-23use ParamConst in ExprKind::ConstParamb-naber-1/+1
2022-03-23remove thir::Visitor::visit_constb-naber-11/+4
2022-03-23change thir to lazily create constantsb-naber-2/+5
2022-03-08mention ignored fields of ExprKind::StaticRefb-naber-1/+1
2022-03-08treat literals in ExprKind::StaticRef as mir::ConstantKind::Valb-naber-1/+1
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-5/+5
2022-02-20Revert "Auto merge of #93800 - b-naber:static-initializers-mir-val, r=oli-obk"Mark Rousskov-1/+1
This reverts commit a240ccd81c74c105b6f5fe84c46f8d36edb7e306, reversing changes made to 393fdc10483da930cdbb00eabc3635030d2e776f. This PR was likely responsible for a relatively large regression in dist-x86_64-msvc-alt builder times, from approximately 1.7 to 2.8 hours, bringing that builder into the pool of the slowest builders we currently have. This seems to be limited to the alt builder due to needing parallel-compiler enabled, likely leading to slow LLVM compilation for some reason.
2022-02-15use AllocId and Ty in ExprKind::StaticRef and delay ConstValue constructionb-naber-1/+1
2022-02-15Overhaul `Const`.Nicholas Nethercote-3/+3
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-8/+0
2021-09-09add a `CastKind` to `Node::Cast`Ellen-1/+9
2021-09-09nitsEllen-5/+24
2021-09-09rename mir -> thir around abstract constsEllen-0/+276