about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/builder/expr
AgeCommit message (Collapse)AuthorLines
2025-09-26ProjectionElem::Subtype -> CastKind::Subtypebeepster4096-2/+1
2025-09-25mark THIR use as candidate for constness checkDing Xiang Fei-1/+4
2025-09-25do not materialise X in [X; 0] when X is unsizing a constDing Xiang Fei-1/+20
2025-09-16Remove Rvalue::Len.Camille Gillot-1/+1
2025-09-01Auto merge of #144783 - folkertdev:loop-match-diverging-loop, r=SparrowLiibors-3/+5
fix `#[loop_match]` on diverging loop tracking issue: https://github.com/rust-lang/rust/issues/132306 fixes https://github.com/rust-lang/rust/issues/144492 fixes https://github.com/rust-lang/rust/issues/144493 fixes https://github.com/rust-lang/rust/issues/144781 this generated invalid MIR before. issue https://github.com/rust-lang/rust/issues/143806 still has an issue where we assign `state = state` which is invalid in MIR. Fixing that problem is tricky, so I'd like to do that separately. r? `@bjorn3`
2025-08-10add place mention for `#[loop_match]` scrutineeFolkert de Vries-2/+4
2025-08-06coverage: Remove all unstable support for MC/DC instrumentationZalathar-2/+0
2025-08-04fix `#[loop_match]` on diverging loopFolkert de Vries-1/+1
this generated invalid MIR before
2025-08-02Rollup merge of #144478 - joshtriplett:doc-code-formatting-prep, r=AmanieuSamuel Tardieu-1/+3
Improve formatting of doc code blocks We don't currently apply automatic formatting to doc comment code blocks. As a result, it has built up various idiosyncracies, which make such automatic formatting difficult. Some of those idiosyncracies also make things harder for human readers or other tools. This PR makes a few improvements to doc code formatting, in the hopes of making future automatic formatting easier, as well as in many cases providing net readability improvements. I would suggest reading each commit separately, as each commit contains one class of changes.
2025-07-25Improve and regularize comment placement in doc codeJosh Triplett-1/+3
Because doc code does not get automatically formatted, some doc code has creative placements of comments that automatic formatting can't handle. Reformat those comments to make the resulting code support standard Rust formatting without breaking; this is generally an improvement to readability as well. Some comments are not indented to the prevailing indent, and are instead aligned under some bit of code. Indent them to the prevailing indent, and put spaces *inside* the comments to align them with code. Some comments span several lines of code (which aren't the line the comment is about) and expect alignment. Reformat them into one comment not broken up by unrelated intervening code. Some comments are placed on the same line as an opening brace, placing them effectively inside the subsequent block, such that formatting would typically format them like a line of that block. Move those comments to attach them to what they apply to. Some comments are placed on the same line as a one-line braced block, effectively attaching them to the closing brace, even though they're about the code inside the block. Reformat to make sure the comment will stay on the same line as the code it's commenting.
2025-07-24Auto merge of #144389 - scottmcm:no-more-mir-cast-assume, r=davidtwcobors-78/+2
MIR-build: No longer emit assumes in enum-as casting This just uses the `valid_range` from the backend, so it's duplicating the range metadata that now we include on parameters and loads, and thus no longer seems to be useful -- notably there's no codegen test failures from removing it. (Because it's using data from the same source as the backend annotations, it doesn't do anything to mitigate things like rust-lang/rust#144388 where the range in the layout is more permissive than the actual possible discriminants. A variant of this that actually checked the discriminants more specifically might be useful, so could potentially be added in future, but I don't think the *current* checks are actually providing value.) r? mir Randomly turns out that this Fixes https://github.com/rust-lang/rust/issues/121097
2025-07-24MIR-build: No longer emit assumes in enum-as castingScott McMurray-78/+2
This just uses the `valid_range` from the backend, so it's duplicating the range metadata that now we include on parameters and loads.
2025-07-23Remove useless lifetime parameter.Camille GILLOT-17/+3
2025-07-23Give an AllocId to ConstValue::Slice.Camille GILLOT-13/+28
2025-07-05Remove yields_in_scope from the scope tree.Camille GILLOT-3/+0
2025-07-01loop match: run exhaustiveness checkFolkert de Vries-4/+8
2025-07-01Auto merge of #141875 - nnethercote:ByteSymbol, r=petrochenkovbors-11/+12
Introduce `ByteSymbol` It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings.
2025-06-30Introduce `ByteSymbol`.Nicholas Nethercote-11/+12
It's like `Symbol` but for byte strings. The interner is now used for both `Symbol` and `ByteSymbol`. E.g. if you intern `"dog"` and `b"dog"` you'll get a `Symbol` and a `ByteSymbol` with the same index and the characters will only be stored once. The motivation for this is to eliminate the `Arc`s in `ast::LitKind`, to make `ast::LitKind` impl `Copy`, and to avoid the need to arena-allocate `ast::LitKind` in HIR. The latter change reduces peak memory by a non-trivial amount on literal-heavy benchmarks such as `deep-vector` and `tuple-stress`. `Encoder`, `Decoder`, `SpanEncoder`, and `SpanDecoder` all get some changes so that they can handle normal strings and byte strings. This change does slow down compilation of programs that use `include_bytes!` on large files, because the contents of those files are now interned (hashed). This makes `include_bytes!` more similar to `include_str!`, though `include_bytes!` contents still aren't escaped, and hashing is still much cheaper than escaping.
2025-06-29mir: Add a `new` method to `statement`dianqk-20/+17
Avoid introducing a large number of changes when adding optional initialization fields.
2025-06-23Add `#[loop_match]` for improved DFA codegenbjorn3-2/+129
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
2025-06-13Unimplement unsized_localsmejrs-3/+3
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-2/+2
2025-05-28Handle e2021 precise capturing of unsafe binderMichael Goulet-2/+2
2025-05-27Rollup merge of #141513 - nia-e:allocbytes-extend, r=RalfJung许杰友 Jieyou Xu (Joe)-3/+3
interpret: add allocation parameters to `AllocBytes` Necessary for a better implementation of [rust-lang/miri#4343](https://github.com/rust-lang/miri/pull/4343). Also included here is the code from that PR, adapted to this new interface for the sake of example and so that CI can run on them; the Miri changes can be reverted and merged separately, though. r? `@RalfJung`
2025-05-26extend allocbytes with associated typeNia Espera-3/+3
2025-05-23Properly analyze captures from unsafe bindersMichael Goulet-0/+3
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-0/+2
async_drop_in_place::{closure}, scoped async drop added.
2025-04-07Make use generated TerminatorKind::Call have call_source UseSantiago Pastorino-1/+1
2025-04-03Rollup merge of #138610 - oli-obk:no-sort-hir-ids, r=compiler-errorsMatthias Krüger-1/+1
impl !PartialOrd for HirId revive of https://github.com/rust-lang/rust/pull/92233 Another checkbox of https://github.com/rust-lang/rust/issues/90317, another small step in making incremental less likely to die in horrible ways
2025-04-03Upvars HirIds always have the same owner, thus just use an ItemLocalIdOli Scherer-1/+1
2025-04-03Tighten up assignment operator representations.Nicholas Nethercote-2/+8
In the AST, currently we use `BinOpKind` within `ExprKind::AssignOp` and `AssocOp::AssignOp`, even though this allows some nonsensical combinations. E.g. there is no `&&=` operator. Likewise for HIR and THIR. This commit introduces `AssignOpKind` which only includes the ten assignable operators, and uses it in `ExprKind::AssignOp` and `AssocOp::AssignOp`. (And does similar things for `hir::ExprKind` and `thir::ExprKind`.) This avoids the possibility of nonsensical combinations, as seen by the removal of the `bug!` case in `lang_item_for_binop`. The commit is mostly plumbing, including: - Adds an `impl From<AssignOpKind> for BinOpKind` (AST) and `impl From<AssignOp> for BinOp` (MIR/THIR). - `BinOpCategory` can now be created from both `BinOpKind` and `AssignOpKind`. - Replaces the `IsAssign` type with `Op`, which has more information and a few methods. - `suggest_swapping_lhs_and_rhs`: moves the condition to the call site, it's easier that way. - `check_expr_inner`: had to factor out some code into a separate method. I'm on the fence about whether avoiding the nonsensical combinations is worth the extra code.
2025-04-02Move methods from `Map` to `TyCtxt`, part 5.Nicholas Nethercote-2/+2
This eliminates all methods on `Map`. Actually removing `Map` will occur in a follow-up PR.
2025-03-13Simplify lit_to_mir_constant a bitbjorn3-16/+11
2025-03-10Allow int literals for pattern types with int base typesOli Scherer-1/+6
2025-03-06Add UseCloned trait related codeSantiago Pastorino-26/+46
2025-03-06Implement .use keyword as an alias of cloneSantiago Pastorino-1/+45
2025-02-23Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, ↵Jacob Pratt-3/+3
r=saethlin,traviscross Greatly simplify lifetime captures in edition 2024 Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-3/+3
2025-02-22Make a fake body to store typeck results for global_asmMichael Goulet-13/+4
2025-02-21Put a `BlockTailInfo` in `BlockFrame::TailExpr`.Nicholas Nethercote-2/+1
Because it has the same fields, and avoids the need to deconstruct the latter to construct the former.
2025-02-21Rename `ClearCrossCrate::assert_crate_local`.Nicholas Nethercote-2/+2
As `unwrap_crate_local`, because it follows exactly the standard form of an `unwrap` function.
2025-02-08Rustfmtbjorn3-102/+132
2025-02-05Auto merge of #136302 - oli-obk:push-vvqmwzunxsrk, r=compiler-errorsbors-10/+11
Avoid calling the layout_of query in lit_to_const We got all the information available locally
2025-01-31Implement MIR, CTFE, and codegen for unsafe bindersMichael Goulet-8/+46
2025-01-30Avoid calling the layout_of query in lit_to_constOli Scherer-10/+11
2025-01-28Represent the raw pointer for a array length check as a new kind of fake borrowMichael Goulet-16/+5
2025-01-27Reapply "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Michael Goulet-9/+83
r=davidtwco,RalfJung" This reverts commit 122a55bb442bd1995df9cf9b36e6f65ed3ef4a1d.
2025-01-18Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Rémy Rakic-83/+9
r=davidtwco,RalfJung" This reverts commit b57d93d8b9525fa261404b4cd9c0670eeb1264b8, reversing changes made to 0aeaa5eb22180fdf12a8489e63c4daa18da6f236.
2025-01-18Revert "Rollup merge of #134371 - scottmcm:fix-134352, r=oli-obk"Rémy Rakic-25/+7
This reverts commit 7c301ecdf5e806b7aa3c44e4a185049fabbc4381, reversing changes made to dffaad83327454430129802f240121f8c7866208.
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-1/+1
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.