summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2025-02-10peace of mind: be absolutely sure we don't try to emit a 0-part suggestiondianne-1/+4
(cherry picked from commit 8dcdb3eb3c28428267bd7bf4cb63e06f9e4330c1)
2025-02-10try to suggest eliding redundant binding modifiersdianne-36/+45
(cherry picked from commit b32a5331dcdcc1993fefeff412a20766557e558d)
2025-02-10peace of mind: remove a call to `Option::expect`dianne-2/+3
(cherry picked from commit 060cc37f3225dd69b5d0df089eec52ff92953b01)
2025-02-10reword default binding mode notesdianne-9/+3
(cherry picked from commit a5cc4cbe64876c339cc1fb47fb962792bc142146)
2025-02-10separate labels for default binding mode spans into their own notesdianne-10/+21
(cherry picked from commit 767f82039c221fa609f752d2a2ea4ffd664f8138)
2025-02-10experimentally label the spans for default binding modesdianne-35/+94
(cherry picked from commit 203d3109d8e96a6a4075205e836216d7cd281d5b)
2025-02-10highlight the whole problem subpattern when pointing out the default binding ↵dianne-2/+2
mode (cherry picked from commit 4331f55b729d1a41004305f85dfe4dbbcec3ee3f)
2025-02-10reword 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. (cherry picked from commit bdc6c4d07b5ccb91df396e152deafc3a66b539ab)
2025-02-10pattern migration: move labels out of the suggestion structdianne-19/+15
(cherry picked from commit 724b885b4e486a355d176dc78098e131f9c1b2ef)
2025-02-06ensure sufficient stack in unsafety checkRémy Rakic-1/+4
(cherry picked from commit 94562ee1eae83d6cc80bda4d57b43bcdb7a842b5)
2025-02-06ensure sufficient stack in tail call checkRémy Rakic-5/+8
(cherry picked from commit 2c778c1e4ca8053e787998c9b18bb57222719a3d)
2025-02-06Revert "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. (cherry picked from commit 122a55bb442bd1995df9cf9b36e6f65ed3ef4a1d)
2025-02-06Revert "Rollup merge of #134371 - scottmcm:fix-134352, r=oli-obk"Rémy Rakic-25/+7
This reverts commit 7c301ecdf5e806b7aa3c44e4a185049fabbc4381, reversing changes made to dffaad83327454430129802f240121f8c7866208. (cherry picked from commit 0bb4880581a6963e0b895f9550e9147c68b9537a)
2025-02-06Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-3/+7
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca. (cherry picked from commit ca1c17c88d1f625763859396ba7a50f36ac45cc0)
2025-01-23Always force non-trimming of path in `unreachable_patterns` lintEsteban Küber-8/+1
Creating a "trimmed DefID path" when no error is being emitted is an ICE (on purpose). If we create a trimmed path for a lint that is then silenced before being emitted causes a known ICE. This side-steps the issue by always using `with_no_trimmed_path!`. This was verified to fix https://github.com/quinn-rs/quinn/, but couldn't write a repro case for the test suite. Fix #135289. (cherry picked from commit 93a19501c2bad56e73f0ac9f3ae062b614d30832)
2025-01-10run borrowck tests on BIDs and emit tail-expr-drop-order lints forDing Xiang Fei-3/+3
potential violations (cherry picked from commit 045271ccccd6c485f65ed94aeef3357a512e22fb)
2024-12-27Fix typoschloefeal-1/+1
Signed-off-by: chloefeal <188809157+chloefeal@users.noreply.github.com>
2024-12-22Delete `Rvalue::Len`Scott McMurray-7/+3
Everything's moved to `PtrMetadata` instead.
2024-12-20Handle DropKind::ForLint in coroutines correctlyMichael Goulet-10/+10
2024-12-19Auto merge of #134486 - compiler-errors:drop-for-lint, r=nikomatsakisbors-41/+107
Make sure we handle `backwards_incompatible_lint` drops appropriately in drop elaboration In #131326, a new kind of scheduled drop (`drop_kind: DropKind::Value` + `backwards_incompatible_lint: true`) was added so that we could insert a new kind of no-op MIR statement (`backward incompatible drop`) for linting purposes. These drops were intended to have *no side-effects*, but drop elaboration code forgot to handle these drops specially and they were handled otherwise as normal drops in most of the code. This ends up being **unsound** since we insert more than one drop call for some values, which means that `Drop::drop` could be called more than once. This PR fixes this by splitting out the `DropKind::ForLint` and adjusting the code. I'm not totally certain if all of the places I've adjusted are either reachable or correct, but I'm pretty certain that it's *more* correct than it was previously. cc `@dingxiangfei2009` r? nikomatsakis Fixes #134482
2024-12-19pacify merciless fmtNiko Matsakis-5/+5
2024-12-19explain how `build_scope_drops` worksNiko Matsakis-2/+38
2024-12-19Rename Scope.id to Scope.local_id, remove trivial accessorMichael Goulet-14/+20
2024-12-19Use TypingEnv from MIR builderMichael Goulet-4/+1
2024-12-18Separate DropKind::ForLintMichael Goulet-39/+69
2024-12-18Rollup merge of #134399 - spastorino:invert-if-condition, r=jieyouxu许杰友 Jieyou Xu (Joe)-3/+3
Do not do if ! else, use unnegated cond and swap the branches instead I'm tidying up my ergonomic ref counting PR and I'm going to make some small, simple and unrelated changes outside that PR, so the main PR sticks more straight to the point.
2024-12-18Rollup merge of #134394 - dianne:clarify-pat-2024-migration, r=compiler-errors许杰友 Jieyou Xu (Joe)-15/+42
Clarify the match ergonomics 2024 migration lint's output This makes a few changes: - Rather than using the whole pattern as a span for the lint, this collects spans for each problematic default binding mode reset and labels them with why they're problems. - The lint's suggestions are now verbose-styled, so that it's clear what's being suggested vs. what's problematic. - The wording is now less technical, and the hard error version of this diagnostic now links to the same reference material as the lint (currently an unwritten page of the edition guide). I'm not totally confident in the wording or formatting, so I'd appreciate feedback on that in particular. I tried to draw a connection with word choice between the labels and the suggestion, but it might be imprecise, unclear, or cluttered. If so, it might be worth making the labels more terse and adding notes that explain them, but that's harder to read in a way too. cc ```@Nadrieril``` ```@Jules-Bertholet``` Closes #133854. For reference, the error from that issue becomes: ``` error: pattern uses features incompatible with edition 2024 --> $DIR/remove-me.rs:6:25 | LL | map.iter().filter(|(&(_x, _y), &_c)| false); | ^ ^ cannot implicitly match against multiple layers of reference | | | cannot implicitly match against multiple layers of reference | help: make the implied reference pattern explicit | LL | map.iter().filter(|&(&(_x, _y), &_c)| false); | + ```
2024-12-18mir: require `is_cleanup` when creating `BasicBlockData`DianQK-8/+9
2024-12-18Do not do if ! else, use unnegated cond and swap the branches insteadSantiago Pastorino-3/+3
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-10/+5
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-12-17Add the edition guide link from the match 2024 migration lint to the error ↵dianne-0/+4
as well
2024-12-17Clarify the match ergonomics 2024 migration lint's outputdianne-15/+38
2024-12-17Rollup merge of #134400 - spastorino:fix-some-comments, r=compiler-errorsJacob Pratt-1/+1
Fix some comments related to upvars handling I'm tidying up my ergonomic ref counting PR and I'm going to make some small, simple and unrelated changes outside that PR, so the main PR sticks more straight to the point.
2024-12-17Explain why `build` was renamed to `builder`Zalathar-0/+8
2024-12-17Rename `rustc_mir_build::build` to `builder`Zalathar-53/+53
2024-12-16Adjust upvar.rs file pathSantiago Pastorino-1/+1
2024-12-16Rollup merge of #134371 - scottmcm:fix-134352, r=oli-obkMatthias Krüger-7/+25
Check for array lengths that aren't actually `usize` I wish typeck wouldn't give us `ty::Array`s that have this problem in the first place, but we can check for it. Fixes #134352 cc ``@matthiaskrgr``
2024-12-16Rollup merge of #134197 - Enselic:mirror, r=lcnrMatthias Krüger-0/+8
rustc_mir_build: Clarify that 'mirrored' does not mean 'flipped' or 'reversed' My intuition for 'mirrored' is that it means 'flipped' or 'reversed'. Clarify that that is not what is meant to 'mirror' the THIR from the HIR.
2024-12-16Rollup merge of #134314 - compiler-errors:default-struct-value-const, r=estebankMatthias Krüger-5/+11
Make sure to use normalized ty for unevaluated const in default struct value This cleans up the way that we construct the `mir::Const::Unevaluated` for default struct values. We were previously using `from_unevaluated`, which doesn't normalize the type, and is really only used for inline assembly. Other codepaths (such as `ExprKind::NamedConst`) use the type from the body. Also, let's stop using `literal_operand`, which also is really not meant for calls other than for literal comparisons in pattern lowering. Also move all of the tests to a separate subdirectory so they don't need to have the same prefix on all the test files. Fixes #134298 r? estebank or reassign
2024-12-15Check for array lengths that aren't actually `usize`Scott McMurray-7/+25
2024-12-15Add hir::AttributeJonathan Dönszelmann-2/+1
2024-12-15Rollup merge of #134285 - oli-obk:push-vwrqsqlwnuxo, r=UrgauStuart Cook-10/+6
Add some convenience helper methods on `hir::Safety` Makes a lot of call sites simpler and should make any refactorings needed for https://github.com/rust-lang/rust/pull/134090#issuecomment-2541332415 simpler, as fewer sites have to be touched in case we end up storing some information in the variants of `hir::Safety`
2024-12-14Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵bors-9/+83
r=davidtwco,RalfJung Bounds-check with PtrMetadata instead of Len in MIR Rather than emitting `Len(*_n)` in array index bounds checks, emit `PtrMetadata(copy _n)` instead -- with some asterisks for arrays and `&mut` that need it to be done slightly differently. We're getting pretty close to removing `Len` entirely, actually. I think just one more PR after this (for slice drop shims). r? mir
2024-12-14Add some convenience helper methods on `hir::Safety`Oli Scherer-10/+6
2024-12-14Make sure to use normalized ty for unevaluated const for default struct valueMichael Goulet-5/+11
2024-12-14Split UserTypeAnnotation to have a kindMichael Goulet-7/+7
2024-12-13rustc_mir_build: Clarify that 'mirrored' does not mean 'flipped' or 'reversed'Martin Nordholts-0/+8
My intuition for 'mirrored' is that it means 'flipped' or 'reversed'. Clarify that that is not what is meant to 'mirror' the THIR from the HIR.
2024-12-13Don't retag the `PtrMetadata(&raw const *_n)` in slice indexingScott McMurray-2/+11
2024-12-12Add unwrap_unsafe_binder and wrap_unsafe_binder macro operatorsMichael Goulet-0/+5
2024-12-09review comments: rewordingsEsteban Küber-1/+1