about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/thir.rs
AgeCommit message (Collapse)AuthorLines
2023-12-04Don't include destruction scopes in THIRMatthew Jasper-4/+2
They are not used by anyone, and add memory/performance overhead.
2023-11-29Add `never_patterns` feature gateNadrieril-1/+10
2023-11-15Re-format code with new rustfmtMark Rousskov-1/+3
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-1/+1
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-10-31Update MIR tests for offset_ofGeorge Bateman-1/+0
2023-10-31Enums in offset_of: update based on est31, scottmcm & llogiq reviewGeorge Bateman-2/+2
2023-10-31Support enum variants in offset_of!George Bateman-2/+3
2023-10-27Propagate half-open ranges through THIRNadrieril-23/+49
2023-10-27Abstract over `PatRange` boundary valueNadrieril-10/+213
2023-10-25Auto merge of #116482 - matthewjasper:thir-unsafeck-inline-constants, r=b-naberbors-1/+21
Fix inline const pattern unsafety checking in THIR Fix THIR unsafety checking of inline constants. - Steal THIR in THIR unsafety checking (if enabled) instead of MIR lowering. - Represent inline constants in THIR patterns.
2023-10-20s/generator/coroutine/Oli Scherer-2/+2
2023-10-16Address review commentsMatthew Jasper-2/+13
Clean up code and add comments. Use InlineConstant to wrap range patterns.
2023-10-16Fix inline const pattern unsafety checking in THIRMatthew Jasper-1/+10
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-5/+26
Instead of via `Const::new_error`
2023-10-11Avoid emitting the non_exhaustive error if other errors already occurredOli Scherer-5/+8
2023-09-27Auto merge of #115887 - RalfJung:pat, r=oli-obkbors-6/+10
thir::pattern: update some comments and error type names Follow-up to [these comments](https://github.com/rust-lang/rust/pull/105750#pullrequestreview-1629697578). Please carefully fact-check, I'm new to this area of the compiler!
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-5/+5
2023-09-16thir::pattern: update some comments and error type namesRalf Jung-6/+10
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-0/+1
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-11/+11
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-8/+8
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-4/+5
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/+4
2023-04-26Remove unused `TypeFoldable`/`TypeVisitable` impls.Nicholas Nethercote-1/+0
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-1/+6
Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
2023-04-21intern offsetof fieldsDrMeepster-2/+2
2023-04-21offset_ofDrMeepster-0/+5
2023-04-20Remove WithOptconstParam.Camille GILLOT-2/+2
2023-04-03Add Span to StmtKind::Let.Camille GILLOT-2/+54
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