about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2024-02-19Eagerly simplify match pairsNadrieril-102/+61
2024-02-19Don't repeatedly simplify already-simplified match pairsNadrieril-11/+7
2024-02-19Make `simplify_candidate` more generalNadrieril-48/+56
Because we will soon need to apply it to match pairs that aren't directly in a candidate.
2024-02-19Move `Or` test outside of `simplify_candidate`Nadrieril-31/+26
2024-02-19Switch to Vec of MatchPairsNadrieril-6/+3
Because I'm about to make MatchPair recursive, which I can't do with SmallVec, and I need to share code between the two.
2024-02-17Replace the loop with recursive calls for clarityNadrieril-28/+31
2024-02-17Move the loop out of the functionNadrieril-51/+50
2024-02-17Move everything into the loopNadrieril-38/+36
2024-02-17No need for empty special case anymoreNadrieril-3/+0
2024-02-17It's fine to assign `otherwise_block`s to unreachable candidatesNadrieril-11/+4
2024-02-17Reuse `next_prebinding`Nadrieril-8/+3
The moment we get a candidate without guard, the return block becomes a fresh block linked to nothing. So we can keep assigning a fresh block every iteration to reuse the `next_prebinding` logic.
2024-02-17Simplify return block computationNadrieril-6/+4
2024-02-17Merge the two loopsNadrieril-26/+17
2024-02-17Tweak the function boundaryNadrieril-18/+10
2024-02-17Don't bother to save a blockNadrieril-4/+0
2024-02-17Rollup merge of #121085 - davidtwco:always-eager-diagnostics, r=nnethercoteMatthias Krüger-1/+1
errors: only eagerly translate subdiagnostics Subdiagnostics don't need to be lazily translated, they can always be eagerly translated. Eager translation is slightly more complex as we need to have a `DiagCtxt` available to perform the translation, which involves slightly more threading of that context. This slight increase in complexity should enable later simplifications - like passing `DiagCtxt` into `AddToDiagnostic` and moving Fluent messages into the diagnostic structs rather than having them in separate files (working on that was what led to this change). r? ```@nnethercote```
2024-02-16Fix an ICE in the recursion lintOli Scherer-1/+3
2024-02-15errors: only eagerly translate subdiagnosticsDavid Wood-1/+1
Subdiagnostics don't need to be lazily translated, they can always be eagerly translated. Eager translation is slightly more complex as we need to have a `DiagCtxt` available to perform the translation, which involves slightly more threading of that context. This slight increase in complexity should enable later simplifications - like passing `DiagCtxt` into `AddToDiagnostic` and moving Fluent messages into the diagnostic structs rather than having them in separate files (working on that was what led to this change). Signed-off-by: David Wood <david@davidtw.co>
2024-02-15Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.Nicholas Nethercote-15/+9
This mostly works well, and eliminates a couple of delayed bugs. One annoying thing is that we should really also add an `ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`, so we have to fake it.
2024-02-14Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errorsbors-2/+11
Continue compilation after check_mod_type_wf errors The ICEs fixed here were probably reachable through const eval gymnastics before, but now they are easily reachable without that, too. The new errors are often bugfixes, where useful errors were missing, because they were reported after the early abort. In other cases sometimes they are just duplication of already emitted errors, which won't be user-visible due to deduplication. fixes https://github.com/rust-lang/rust/issues/120860
2024-02-14Continue compilation after check_mod_type_wf errorsOli Scherer-2/+11
2024-02-14Use fewer delayed bugs.Nicholas Nethercote-10/+15
For some cases where it's clear that an error has already occurred, e.g.: - there's a comment stating exactly that, or - things like HIR lowering, where we are lowering an error kind The commit also tweaks some comments around delayed bug sites.
2024-02-13Rollup merge of #120978 - Nadrieril:sane-blocks, r=matthewjasperMatthias Krüger-71/+61
match lowering: simplify block creation Match lowering was doing complicated things with block creation. As far as I can tell it was trying to avoid creating unneeded blocks, but of the three places that start out with `otherwise = &mut None`, two of them called `otherwise.unwrap_or_else(|| self.cfg.start_new_block())` anyway. As far as I can tell the only place where this PR makes a difference is in `lower_match_tree`, which did indeed sometimes avoid creating the unreachable final block + FakeRead. Unless this is important I propose we do the naive thing instead. I have not checked all the graph isomorphisms by hand, but at a glance the test diff looks sensible. r? `@matthewjasper`
2024-02-12Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obkMatthias Krüger-3/+3
Dejargonize `subst` In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12Start blocks eagerlyNadrieril-71/+61
2024-02-12Dejargnonize substShoyu Vanilla-3/+3
2024-02-12Lowering field access for anonymous adtsFrank King-5/+15
2024-02-11Rollup merge of #120872 - petrochenkov:opthirpar, r=cjgillotMatthias Krüger-1/+1
hir: Refactor getters for HIR parents See individual commits. I ended up removing on of the FIXMEs from https://github.com/rust-lang/rust/pull/120206 instead of addressing it.
2024-02-10hir: Remove `hir::Map::{opt_parent_id,parent_id,get_parent,find_parent}`Vadim Petrochenkov-1/+1
2024-02-10Remove unnecessary `min_specialization` after bootstrapZalathar-1/+1
These crates all needed specialization for `newtype_index!`, which will no longer be necessary when the current nightly eventually becomes the next bootstrap compiler.
2024-02-09Rollup merge of #120817 - compiler-errors:more-mir-errors, r=oli-obkMatthias Krüger-10/+26
Fix more `ty::Error` ICEs in MIR passes Fixes #120791 - Add a check for `ty::Error` in the `ByMove` coroutine pass Fixes #120816 - Add a check for `ty::Error` in the MIR validator Also a drive-by fix for a FIXME I had asked oli to add r? oli-obk
2024-02-09Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwcoMatthias Krüger-0/+3
Invert diagnostic lints. That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted. r? ````@davidtwco````
2024-02-09Don't ICE in ByMoveBody when coroutine is taintedMichael Goulet-10/+26
2024-02-08Rollup merge of #120801 - oli-obk:drop_recursion_ice, r=NilstriebMatthias Krüger-6/+5
Avoid ICE in drop recursion check in case of invalid drop impls fixes #120787
2024-02-08Rollup merge of #120775 - Nadrieril:more-min_exh_pats, r=compiler-errorsMatthias Krüger-2/+4
Make `min_exhaustive_patterns` match `exhaustive_patterns` better Split off from https://github.com/rust-lang/rust/pull/120742. There remained two edge cases where `min_exhaustive_patterns` wasn't behaving like `exhaustive_patterns`. This fixes them, and tests the feature in a bunch more cases. I essentially went through all uses of `exhaustive_patterns` to see which ones would be interesting to compare between the two features. r? `@compiler-errors`
2024-02-08Avoid ICE in drop recursion check in case of invalid drop implsOli Scherer-6/+5
2024-02-08Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgrbors-63/+56
Rollup of 9 pull requests Successful merges: - #119592 (resolve: Unload speculatively resolved crates before freezing cstore) - #120103 (Make it so that async-fn-in-trait is compatible with a concrete future in implementation) - #120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s) - #120214 (match lowering: consistently lower bindings deepest-first) - #120688 (GVN: also turn moves into copies with projections) - #120702 (docs: also check the inline stmt during redundant link check) - #120727 (exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered") - #120734 (Add `SubdiagnosticMessageOp` as a trait alias.) - #120739 (improve pretty printing for associated items in trait objects) r? `@ghost` `@rustbot` modify labels: rollup
2024-02-08Match `min_exhaustive_patterns` implementation with `exhaustive_patterns`Nadrieril-2/+4
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-4/+29
2024-02-08Rollup merge of #120734 - nnethercote:SubdiagnosticMessageOp, r=compiler-errorsMatthias Krüger-9/+3
Add `SubdiagnosticMessageOp` as a trait alias. It avoids a lot of repetition. r? matthewjasper
2024-02-08Rollup merge of #120214 - Nadrieril:fix-120210, r=pnkfelixMatthias Krüger-54/+53
match lowering: consistently lower bindings deepest-first Currently when lowering match expressions to MIR, we do a funny little dance with the order of bindings. I attempt to explain it in the third commit: we handle refutable (i.e. needing a test) patterns differently than irrefutable ones. This leads to inconsistencies, as reported in https://github.com/rust-lang/rust/issues/120210. The reason we need a dance at all is for situations like: ```rust fn foo1(x: NonCopyStruct) { let y @ NonCopyStruct { copy_field: z } = x; // the above should turn into let z = x.copy_field; let y = x; } ``` Here the `y ```````@```````` binding will move out of `x`, so we need to copy the field first. I believe that the inconsistency came about when we fixed https://github.com/rust-lang/rust/issues/69971, and didn't notice that the fix didn't extend to refutable patterns. My guess then is that ordering bindings by "deepest-first, otherwise source order" is a sound choice. This PR implements that (at least I hope, match lowering is hard to follow :smiling_face_with_tear:). Fixes https://github.com/rust-lang/rust/issues/120210 r? ```````@oli-obk``````` since you merged the original fix to https://github.com/rust-lang/rust/issues/69971 cc ```````@matthewjasper```````
2024-02-08Add `SubdiagnosticMessageOp` as a trait alias.Nicholas Nethercote-9/+3
It avoids a lot of repetition.
2024-02-06Rollup merge of #120423 - RalfJung:indirect-structural-match, r=petrochenkovMatthias Krüger-95/+36
update indirect structural match lints to match RFC and to show up for dependencies This is a large step towards implementing https://github.com/rust-lang/rfcs/pull/3535. We currently have five lints related to "the structural match situation": - nontrivial_structural_match - indirect_structural_match - pointer_structural_match - const_patterns_without_partial_eq - illegal_floating_point_literal_pattern This PR concerns the first 3 of them. (The 4th already is set up to show for dependencies, and the 5th is removed by https://github.com/rust-lang/rust/pull/116284.) nontrivial_structural_match is being removed as per the RFC; the other two are enabled to show up in dependencies. Fixes https://github.com/rust-lang/rust/issues/73448 by removing the affected analysis.
2024-02-06Rollup merge of #120331 - Nadrieril:no-arena, r=compiler-errorsMatthias Krüger-2/+1
pattern_analysis: use a plain `Vec` in `DeconstructedPat` The use of an arena-allocated slice in `DeconstructedPat` dates to when we needed the arena anyway for lifetime reasons. Now that we don't, I'm thinking that if `thir::Pat` can use plain old `Vec`s, maybe so can I. r? ```@ghost```
2024-02-06Teach typeck/borrowck/solvers how to deal with async closuresMichael Goulet-2/+20
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-1/+4
2024-02-06Invert diagnostic lints.Nicholas Nethercote-0/+3
That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has be converted to use translated diagnostics. This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.
2024-02-05get rid of nontrivial_structural_match lint and custom_eq const qualifRalf Jung-95/+36
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-14/+26
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-01-31Remove `pattern_arena` from `RustcMatchCheckCtxt`Nadrieril-2/+1