about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/thir
AgeCommit message (Collapse)AuthorLines
2024-10-29TypingMode :thinking:lcnr-2/+4
2024-10-29Remove region from adjustmentsMichael Goulet-4/+5
2024-10-24Rollup merge of #131909 - clubby789:enum-overflow-cast, r=compiler-errorsStuart Cook-1/+8
Prevent overflowing enum cast from ICEing Fixes #131902
2024-10-24stabilize if_let_rescopeDing Xiang Fei-1/+1
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-2/+2
2024-10-20Rip out old effects var handling code from traitsMichael Goulet-11/+1
2024-10-19Prevent overflowing enum cast from ICEingclubby789-1/+8
2024-10-16Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelixMatthias Krüger-8/+19
Implement edition 2024 match ergonomics restrictions This implements the minimalest version of [match ergonomics for edition 2024](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html). This minimal version makes it an error to ever reset the default binding mode. The implemented proposal is described precisely [here](https://hackmd.io/zUqs2ISNQ0Wrnxsa9nhD0Q#RFC-3627-nano), where it is called "RFC 3627-nano". Rules: - Rule 1C: When the DBM (default binding mode) is not `move` (whether or not behind a reference), writing `mut`, `ref`, or `ref mut` on a binding is an error. - Rule 2C: Reference patterns can only match against references in the scrutinee when the DBM is `move`. This minimal version is forward-compatible with the main proposals for match ergonomics 2024: [RFC3627](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html) itself, the alternative [rule 4-early variant](https://rust-lang.github.io/rfcs/3627-match-ergonomics-2024.html), and [others](https://hackmd.io/zUqs2ISNQ0Wrnxsa9nhD0Q). The idea is to give us more time to iron out a final proposal. This includes a migration lint that desugars any offending pattern into one that doesn't make use of match ergonomics. Such patterns have identical meaning across editions. This PR insta-stabilizes the proposed behavior onto edition 2024. r? `@ghost` Tracking: - https://github.com/rust-lang/rust/issues/123076
2024-10-11Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiserbors-15/+5
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * https://github.com/rust-lang/rust/issues/49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-08Change error messageNadrieril-4/+3
2024-10-08Stabilize `min_match_ergonomics_2024`Nadrieril-1/+1
2024-10-08Error on resetted binding mode in edition 2024Nadrieril-8/+20
2024-10-06various fixes for `naked_asm!` implementationFolkert de Vries-1/+4
- fix for divergence - fix error message - fix another cranelift test - fix some cranelift things - don't set the NORETURN option for naked asm - fix use of naked_asm! in doc comment - fix use of naked_asm! in run-make test - use `span_bug` in unreachable branch
2024-10-01Remove unnamed field featureMichael Goulet-15/+5
2024-09-28tweak Const::identity_unevaluated name and docsRalf Jung-10/+6
2024-09-28try to get rid of mir::Const::normalizeRalf Jung-4/+2
2024-09-24be even more precise about "cast" vs "coercion"Lukas Markeffsky-7/+26
2024-09-24use more accurate spans for user type ascriptionsLukas Markeffsky-4/+15
2024-09-24unify dyn* coercions with other pointer coercionsLukas Markeffsky-1/+0
2024-09-23Rollup merge of #130715 - compiler-errors:mir-build-const-eval, r=BoxyUwUMatthias Krüger-1/+3
Replace calls to `ty::Const::{try_}eval` in mir build/pattern analysis We normalize consts in writeback: #130645. This means that consts are gonna be as normalized as they're ever gonna get in MIR building and pattern analysis. Therefore we can just use `try_to_target_usize` rather than calling `eval_target_usize`. Regarding the `.expect` calls, I'm not totally certain whether they're correct given rigid unevaluated consts. But this PR shouldn't make *more* ICEs occur; we may have to squash these ICEs when mGCE comes around, tho 😺
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-10/+12
2024-09-22Replace calls to Const::eval in mir buildMichael Goulet-1/+3
2024-09-19pin_ergonomics: allow reborrowing as Pin<&T>Eric Holk-6/+9
2024-09-19Allow shortening reborrowsEric Holk-43/+57
Generating a call to `as_mut()` let to more restrictive borrows than what reborrowing usually gives us. Instead, we change the desugaring to reborrow the pin internals directly which makes things more expressive.
2024-09-18Begin experimental support for pin reborrowingEric Holk-0/+45
This commit adds basic support for reborrowing `Pin` types in argument position. At the moment it only supports reborrowing `Pin<&mut T>` as `Pin<&mut T>` by inserting a call to `Pin::as_mut()`, and only in argument position (not as the receiver in a method call).
2024-09-13Add a machine-applicable suggestion to "unreachable pattern"Nadrieril-5/+30
2024-09-11rescope temp lifetime in let-chain into IfElseDing Xiang Fei-1/+7
apply rules by span edition
2024-08-25Avoid taking reference of &TyKindMichael Goulet-1/+1
2024-08-21Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxuMatthias Krüger-7/+2
Use shorthand field initialization syntax more aggressively in the compiler Caught these when cleaning up #129344 and decided to run clippy to find the rest
2024-08-21Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostics, ↵Matthias Krüger-2/+2
r=jieyouxu Use `bool` in favor of `Option<()>` for diagnostics We originally only supported `Option<()>` for optional notes/labels, but we now support `bool`. Let's use that, since it usually leads to more readable code. I'm not removing the support from the derive macro, though I guess we could error on it... 🤔
2024-08-21Rollup merge of #129281 - Nadrieril:tweak-unreachable-lint-wording, r=estebankMatthias Krüger-4/+22
Tweak unreachable lint wording Some tweaks to the notes added in https://github.com/rust-lang/rust/pull/128034. r? `@estebank`
2024-08-21Simplify some redundant field namesMichael Goulet-7/+2
2024-08-21Use bool in favor of Option<()> for diagnosticsMichael Goulet-2/+2
2024-08-20Move the "matches no value" note to be a span labelNadrieril-1/+3
2024-08-19Cap the number of patterns pointed to by the lintNadrieril-3/+17
2024-08-19Add a note with a link to explain empty typesNadrieril-0/+2
2024-08-18rename AddressOf -> RawBorrow inside the compilerRalf Jung-5/+5
2024-08-17Remove a useless ref/id/ref round-trip from `pattern_from_hir`Zalathar-6/+2
This re-lookup of `&hir::Pat` by its ID appears to be an artifact of earlier complexity that has since been removed from the compiler.
2024-08-13Remove a no-longer-true `assert`Nadrieril-4/+6
2024-08-11Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errorsMatthias Krüger-2/+4
Use more slice patterns inside the compiler Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'. r? ghost
2024-08-10Stabilize `min_exhaustive_patterns`Nadrieril-4/+2
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-2/+4
2024-07-29Rollup merge of #128304 - Zalathar:thir-pat-display, r=NadrierilMatthias Krüger-4/+4
Isolate the diagnostic code that expects `thir::Pat` to be printable Currently, `thir::Pat` implements `fmt::Display` (and `IntoDiagArg`) directly, for use by a few diagnostics. That makes it tricky to experiment with alternate representations for THIR patterns, because the patterns currently need to be printable on their own. That immediately rules out possibilities like storing subpatterns as a `PatId` index into a central list (instead of the current directly-owned `Box<Pat>`). This PR therefore takes an incremental step away from that obstacle, by removing `thir::Pat` from diagnostic structs in `rustc_pattern_analysis`, and hiding the pattern-printing process behind a single public `Pat::to_string` method. Doing so makes it easier to identify and update the code that wants to print patterns, and gives a place to pass in additional context in the future if necessary. --- I'm currently not sure whether switching over to `PatId` is actually desirable or not, but I think this change makes sense on its own merits, by reducing the coupling between `thir::Pat` and the pattern-analysis error types.
2024-07-29Encapsulate the printing of `WitnessPat`Zalathar-4/+4
This hides the fact that we print `WitnessPat` by converting it to `thir::Pat` and then printing that.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-28/+28
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Auto merge of #128034 - Nadrieril:explain-unreachable, r=compiler-errorsbors-25/+64
exhaustiveness: Explain why a given pattern is considered unreachable This PR tells the user why a given pattern is considered unreachable. I reused the intersection information we were already computing; even though it's incomplete I convinced myself that it is sufficient to always get a set of patterns that cover the unreachable one. I'm not a fan of the diagnostic messages I came up with, I'm open to suggestions. Fixes https://github.com/rust-lang/rust/issues/127870. This is also the other one of the two diagnostic improvements I wanted to do before https://github.com/rust-lang/rust/pull/122792. Note: the first commit is an unrelated drive-by tweak. r? `@compiler-errors`
2024-07-25Turn an unreachable code path into an ICEOli Scherer-11/+5
2024-07-24Improve "covered_by_many" errorNadrieril-2/+11
2024-07-24Explain why a given pattern is considered unreachableNadrieril-19/+45
2024-07-24Move rustc-specific entrypoint to the `rustc` moduleNadrieril-6/+10