about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2025-02-10move pattern migration setup/emitting to a separate moduledianne-61/+104
2025-02-08Rustfmtbjorn3-253/+353
2025-02-07Rollup merge of #136577 - dianne:simple-pat-migration-simplification, ↵Matthias Krüger-61/+145
r=Nadrieril Pattern Migration 2024: try to suggest eliding redundant binding modifiers This is based on #136475. Only the last commit is new. This is a simpler, more restrictive alternative to #136496, meant to partially address #136047. If a pattern can be migrated to Rust 2024 solely by removing redundant binding modifiers, this will make that suggestion; otherwise, it uses the old suggestion of making the pattern fully explicit. Relevant tracking issue: #131414 ``@rustbot`` label A-diagnostics A-patterns A-edition-2024 r? ``@Nadrieril``
2025-02-07Rollup merge of #135973 - WaffleLapkin:tail-track-caller-fix, r=compiler-errorsMatthias Krüger-23/+28
fix tail call checks wrt `#[track_caller]` Only check the caller + disallow caller having the attribute. fixes #134336 r? `@compiler-errors` <sub>apparently there were no tests for `#[track_caller]` before... ooops</sub>
2025-02-06fix tail call checks wrt `#[track_caller]`Waffle Lapkin-23/+28
only check the caller + disallow caller having the attr.
2025-02-06Rollup merge of #136435 - Zalathar:thir-pat-stuff, r=NadrierilMatthias Krüger-139/+137
Simplify some code for lowering THIR patterns I've been playing around with some radically different ways of storing THIR patterns, and while those experiments haven't yet produced a clear win, I have noticed various smaller things in the existing code that can be made a bit nicer. Some of the more significant changes: - With a little bit of extra effort (and thoughtful use of Arc), we can completely remove an entire layer of `'pat` lifetimes from the intermediate data structures used for match lowering. - In several places, lists of THIR patterns were being double-boxed for no apparent reason.
2025-02-05peace of mind: be absolutely sure we don't try to emit a 0-part suggestiondianne-1/+4
2025-02-05try to suggest eliding redundant binding modifiersdianne-36/+45
2025-02-05peace of mind: remove a call to `Option::expect`dianne-2/+3
2025-02-05reword default binding mode notesdianne-9/+3
2025-02-05Auto merge of #136302 - oli-obk:push-vvqmwzunxsrk, r=compiler-errorsbors-21/+28
Avoid calling the layout_of query in lit_to_const We got all the information available locally
2025-02-05separate labels for default binding mode spans into their own notesdianne-10/+21
2025-02-04Rollup merge of #136526 - Zalathar:thir-cx, r=NadrierilMatthias Krüger-109/+86
mir_build: Rename `thir::cx::Cx` to `ThirBuildCx` and remove `UserAnnotatedTyHelpers` A combination of two loosely-related tweaks that would otherwise conflict with each other: - `Cx` is a pretty unhelpful type name, especially when jumping between THIR-building and MIR-building while trying to make changes to THIR data structures. - The `UserAnnotatedTyHelpers` trait doesn't appear to provide any benefit over a simple helper function, and its `tcx()` method is currently completely unnecessary. No functional change.
2025-02-04experimentally label the spans for default binding modesdianne-35/+94
2025-02-03highlight the whole problem subpattern when pointing out the default binding ↵dianne-2/+2
mode
2025-02-04Rollup merge of #136462 - Zalathar:endpoint, r=oli-obkMatthias Krüger-39/+42
mir_build: Simplify `lower_pattern_range_endpoint` By accumulating ascriptions and inline-consts in separate vectors, we can streamline some previously-tricky code for dealing with range patterns.
2025-02-04Rename `thir::cx::Cx` to `ThirBuildCx`Zalathar-9/+12
2025-02-04Remove helper trait `UserAnnotatedTyHelpers`Zalathar-100/+74
This trait doesn't appear to provide any benefit over a simple helper function.
2025-02-03Auto merge of #136352 - lqd:ensure-stacks, r=compiler-errorsbors-6/+12
Add a couple of missing `ensure_sufficient_stacks` r? `@saethlin` I hope you didn't spend time on this already. (I couldn't sleep, opened `check_tail_calls`, there was a single call where it could happen, might as well fix it) This PR adds a couple of missing `ensure_sufficient_stack`s: - one in `check_tail_calls` that prevented the #135709 backport on some targets. - after that was fixed, the test still didn't pass starting at 4MB, so I also added one in `check_unsafety` and that made it pass. I didn't add an `rmake` test purposefully limiting the min stack size on `issue-74564-if-expr-stack-overflow.rs`, but we could if we wanted to. On `apple-aarch64-darwin`, this is enough to make `RUST_MIN_STACK=$((1024*1024*3)) ./x test tests/ui --test-args tests/ui/issues/issue-74564-if-expr-stack-overflow.rs` pass for me locally, and it does stack overflow otherwise.
2025-02-03reword pattern migration diagnostic to make sense in all editionsdianne-8/+19
This aligns the main error message a bit more with the phrasing in the Edition Guide and provides a bit more information on the labels to (hopefully!) aid in understanding.
2025-02-03pattern migration: move labels out of the suggestion structdianne-19/+15
2025-02-03Slightly simplify the signature of `lower_match_arms`Zalathar-10/+8
This does mean that we have to resolve the list of arm IDs twice, but it's unclear whether that even matters, whereas the cleaner signature is a nice improvement.
2025-02-03Avoid double-boxing lists of THIR subpatternsZalathar-9/+9
2025-02-03Remove some non-trivial `box` patternsZalathar-23/+17
These particular patterns make it harder to experiment with alternate representations for THIR patterns and subpatterns.
2025-02-03Remove `'pat` lifetime from some match-lowering data structuresZalathar-97/+103
By storing `PatRange` in an Arc, and copying a few fields out of `Pat`, we can greatly simplify the lifetimes involved in match lowering.
2025-02-03Don't demand `&Box<Pat>` in `print_pat`Zalathar-2/+2
2025-02-03Simplify the pattern unpeeling in `lower_pattern_range_endpoint`Zalathar-26/+25
2025-02-03Return range endpoint ascriptions/consts via a `&mut Vec`Zalathar-12/+19
2025-02-03Flatten the option check in `lower_pattern_range_endpoint`Zalathar-31/+28
2025-02-02Rollup merge of #136328 - estebank:long-ty-path, r=jieyouxu,lqdMatthias Krüger-8/+4
Rework "long type names" printing logic Make it so more type-system types can be printed in a shortened version (like `Predicate`s). Centralize printing the information about the "full type name path". Make the "long type path" for the file where long types are written part of `Diag`, so that it becomes easier to keep track of it, and ensure it will always will be printed out last in the diagnostic by making its addition to the output implicit. Tweak the shortening of types in "expected/found" labels. Remove dead file `note.rs`.
2025-02-02Rollup merge of #136279 - Zalathar:ensure-ok, r=oli-obkMatthias Krüger-4/+4
Rename `tcx.ensure()` to `tcx.ensure_ok()`, and improve the associated docs This is all based on my archaeology for https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60TyCtxtEnsure.60. The main renamings are: - `tcx.ensure()` → `tcx.ensure_ok()` - `tcx.ensure_with_value()` → `tcx.ensure_done()` - Query modifier `ensure_forwards_result_if_red` → `return_result_from_ensure_ok` Hopefully these new names are a better fit for the *actual* function and purpose of these query call modes.
2025-02-01Rollup merge of #130514 - compiler-errors:unsafe-binders, r=oli-obkMatthias Krüger-13/+147
Implement MIR lowering for unsafe binders This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are `Copy`. Later on, I'll introduce a new trait that relaxes this requirement to being "is `Copy` or `ManuallyDrop<T>`" which more closely models how we treat union fields. Namely, wrapping unsafe binders is now `Rvalue::WrapUnsafeBinder`, which acts much like an `Rvalue::Aggregate`. Unwrapping unsafe binders are implemented as a MIR projection `ProjectionElem::UnwrapUnsafeBinder`, which acts much like `ProjectionElem::Field`. Tracking: - https://github.com/rust-lang/rust/issues/130516
2025-02-01Rename `tcx.ensure_with_value()` to `tcx.ensure_done()`Zalathar-3/+3
2025-02-01Rename `tcx.ensure()` to `tcx.ensure_ok()`Zalathar-1/+1
2025-01-31Rework "long type names" printing logicEsteban Küber-8/+4
Make it so more type-system types can be printed in a shortened version (like `Predicate`s). Centralize printing the information about the "full type name path". Make the "long type path" for the file where long types are written part of `Diag`, so that it becomes easier to keep track of it, and ensure it will always will be printed out last in the diagnostic by making its addition to the output implicit. Tweak the shortening of types in "expected/found" labels. Remove dead file `note.rs`.
2025-01-31Implement MIR, CTFE, and codegen for unsafe bindersMichael Goulet-13/+147
2025-01-31ensure sufficient stack in unsafety checkRémy Rakic-1/+4
2025-01-31ensure sufficient stack in tail call checkRémy Rakic-5/+8
2025-01-31Rollup merge of #136330 - nnethercote:rm-unnecessary-hooks, r=oli-obkMatthias Krüger-16/+14
Remove unnecessary hooks Some hooks can be downgraded to vanilla functions. r? `@oli-obk`
2025-01-31Remove the `mir_build` hook.Nicholas Nethercote-7/+5
It was downgraded from a query in #122721 but it can just be a vanilla function because it's not called in `rustc_middle`.
2025-01-31Remove the `thir_{tree,flat}` hooks.Nicholas Nethercote-9/+9
They were downgraded from queries in #123995 but they can just be vanilla functions because they are not called in `rustc_middle`.
2025-01-30add commentsLukas Markeffsky-0/+1
2025-01-30introduce `ty::Value`Lukas Markeffsky-1/+1
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-30Avoid calling the layout_of query in lit_to_constOli Scherer-23/+26
2025-01-30Don't allow negative unsigned literalsOli Scherer-1/+5
2025-01-29Auto merge of #134248 - oli-obk:patkind-path-removal, r=BoxyUwUbors-4/+0
Merge `PatKind::Path` into `PatKind::Expr` Follow-up to #134228 We always had a duplication where `Path`s could be represented as `PatKind::Path` or `PatKind::Lit(ExprKind::Path)`. We had to handle both everywhere, and still do after #134228, so I'm removing it now.
2025-01-29Eliminate PatKind::PathOli Scherer-4/+0
2025-01-29Rollup merge of #136121 - oli-obk:push-zzvxlynmnqpp, r=estebankLeón Orell Valerian Liehr-49/+50
Deduplicate operand creation between scalars, non-scalars and string patterns just something that felt duplicated and would make pattern type handling a bit more roundabout.
2025-01-28Rollup merge of #135748 - compiler-errors:len-2, r=RalfJung,oli-obkMatthias Krüger-10/+73
Lower index bounds checking to `PtrMetadata`, this time with the right fake borrow semantics 😸 Change `Rvalue::RawRef` to take a `RawRefKind` instead of just a `Mutability`. Then introduce `RawRefKind::FakeForPtrMetadata` and use that for lowering index bounds checking to a `PtrMetadata`. This new `RawRefKind::FakeForPtrMetadata` acts like a shallow fake borrow in borrowck, which mimics the semantics of the old `Rvalue::Len` operation we're replacing. We can then use this `RawRefKind` instead of using a span desugaring hack in CTFE. cc ``@scottmcm`` ``@RalfJung``
2025-01-28Edit the inputs to const == val check instead of duplicating logicOli Scherer-32/+34