about summary refs log tree commit diff
path: root/tests/ui/dropck
AgeCommit message (Collapse)AuthorLines
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-2/+5
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
2025-08-07Rollup merge of #143764 - dianne:primary-binding-drop-order, ↵Stuart Cook-10/+10
r=Nadrieril,traviscross lower pattern bindings in the order they're written and base drop order on primary bindings' order To fix rust-lang/rust#142163, this PR does two things: - Makes match arms base their drop order on the first sub-branch instead of the last sub-branch. Together with the second change, this makes bindings' drop order correspond to the relative order of when each binding first appears (i.e. the order of the "primary" bindings). - Lowers pattern bindings in the order they're written (still treating the right-hand side of a ``@`` as coming before the binding on the left). In each sub-branch of a match arm, this is the order that would be obtained if the or-alternatives chosen in that sub-branch were inlined into the arm's pattern. This both affects drop order (making bindings in or-patterns not be dropped first) and fixes the issue in [this test](https://github.com/rust-lang/rust/blob/2a023bf80a6fbd6a06d5460a34eb247b986286ed/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs) from rust-lang/rust#121716. My approach to the second point is admittedly a bit trickier than may be necessary. To avoid passing around a counter when building `FlatPat`s, I've instead added just enough information to recover the original structure of the pattern's bindings from a `MatchTreeSubBranch`'s path through the `Candidate` tree. Some alternatives: - We could use a counter, then sort bindings by their ordinals when making `MatchTreeSubBranch`es. - I'd like to experiment with always merging sub-candidates and removing `test_remaining_match_pairs_after_or`; that would require lowering bindings and guards in a different way. That makes it a bigger change too, though, so I figure it might be simplest to start here. - For a very big change, we could track which or-alternatives succeed at runtime to base drop order on the binding order in the particular alternatives matched. This is a breaking change. It will need a crater run, language team sign-off, and likely updates to the Reference. This will conflict with rust-lang/rust#143376 and probably also rust-lang/rust#143028, so they shouldn't be merged at the same time. r? `@matthewjasper` or `@Nadrieril`
2025-08-07Rollup merge of #143028 - dianne:let-else-storage, r=oli-obk,traviscrossStuart Cook-5/+22
emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching This PR removes special handling of `let`-`else`, so that `StorageLive`s are emitted and `StorageDead`s are scheduled only after pattern-matching has succeeded. This means `StorageDead`s will no longer appear for all of its bindings on the `else` branch (because they're not live yet) and its drops&`StorageDead`s will happen together like they do elsewhere, rather than having all drops first, then all `StorageDead`s. This fixes rust-lang/rust#142056, and is therefore a breaking change. I believe it'll need a crater run and a T-lang nomination/fcp thereafter. Specifically, this makes drop-checking slightly more restrictive for `let`-`else` to match the behavior of other variable binding forms. An alternative approach could be to change the relative order of drops and `StorageDead`s for other binding forms to make drop-checking more permissive, but making that consistent would be a significantly more involved change. r? mir cc `````@dingxiangfei2009````` `````@rustbot````` label +T-lang +needs-crater
2025-08-06base drop order on the first sub-branchdianne-10/+10
2025-06-30Unconditionally run `check_item_type` on all itemsOli Scherer-15/+24
2025-06-25emit `StorageLive` and schedule `StorageDead` for `let`-`else` after matchingdianne-5/+22
2025-06-08add tests for pattern binding drop order edge casesdianne-0/+124
I couldn't find existing tests that for this behavior, so this should make sure it doesn't accidentally change.
2025-06-03Use non-2015 edition paths in tests that do not test for their resolutionLukas Wirth-1/+1
This allows for testing these tests on editions other than 2015
2025-05-07Remove manual WF hackMichael Goulet-4/+38
2025-02-24Don't immediately panic if dropck fails without returning errorsMatthew Jasper-0/+33
Type lowering can give non-fatal errors that dropck then uses to suppress its own errors. Assume this is the cases when we can't find the error in borrowck.
2025-02-17Update tests for dropck normalization errorsMatthew Jasper-0/+176
Takes crash tests from #135039, #103899, #91985 and #105299 and turns them into ui tests
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-2/+2
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-6/+4
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-4/+6
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2024-12-07Use trait name instead of full constraint in suggestion messageEsteban Küber-4/+4
``` help: consider restricting type parameter `T` with traits `Copy` and `Trait` | LL | fn duplicate_custom<T: Copy + Trait>(t: S<T>) -> (S<T>, S<T>) { | ++++++++++++++ ``` ``` help: consider restricting type parameter `V` with trait `Copy` | LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V { | +++++++++++++++++++ ```
2024-12-07reword trait bound suggestion message to include the boundsEsteban Küber-4/+4
2024-11-26Rollup merge of #133402 - compiler-errors:drop-and-destruct, r=lcnrMichael Goulet-39/+0
Constify `Drop` and `Destruct` r? `@lcnr` or `@fee1-dead`
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-1/+0
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-11-25Constify Drop and DestructMichael Goulet-39/+0
2024-11-05Tweak E0320 overflow error wordingEsteban Küber-12/+12
Surrount type with backticks as we should in every error.
2024-11-03Yeet effects featureMichael Goulet-16/+4
2024-10-28Hack out effects support for old solverMichael Goulet-6/+1
2024-10-17Rollup merge of #128391 - cafce25:issue-128390, r=lcnrMatthias Krüger-3/+4
Change orphan hint from "only" to "any uncovered type inside..." Fix #128390
2024-09-26Make new information notes instead of labelsJonathan Birk-4/+4
2024-09-24replace "cast" with "coercion" where applicableLukas Markeffsky-6/+6
This changes the remaining span for the cast, because the new `Cast` category has a higher priority (lower `Ord`) than the old `Coercion` category, so we no longer report the region error for the "unsizing" coercion from `*const Trait` to itself.
2024-08-11Add more information link to orphan implsJonathan Birk-1/+2
2024-07-31Rollup merge of #128438 - Bryanskiy:empty-array-dropck, r=lcnrMatthias Krüger-0/+23
Add special-case for [T, 0] in dropck_outlives implements/fixes #110288. r? `@lcnr`
2024-07-31Add special-case for [T, 0] in dropckBryanskiy-0/+23
2024-07-30Adjust orphan note in testsJonathan Birk-1/+1
2024-07-26Peel off explicit (or implicit) deref before suggesting clone on move error ↵Michael Goulet-5/+0
in borrowck
2024-07-02Rewrite dropckBoxy-359/+241
2024-07-01introduce testsBoxy-0/+310
2024-04-11Suggest `.clone()` when moved while borrowedEsteban Küber-0/+5
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-28/+28
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-2/+2
2023-11-24Show number in error message even for one errorNilstrieb-12/+12
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-12Note about object lifetime defaults in does not live long enough errorNilstrieb-0/+12
This is a aspect of Rust that frequently trips up people who are not aware of it yet. This diagnostic attempts to explain what's happening and why the lifetime constraint, that was never mentioned in the source, arose.
2023-11-02review + add testslcnr-0/+41
2023-07-22Rollup merge of #112508 - compiler-errors:trait-sig-lifetime-sugg-ice, ↵Matthias Krüger-4/+4
r=cjgillot Tweak spans for self arg, fix borrow suggestion for signature mismatch 1. Adjust a suggestion message that was annoying me 2. Fix #112503 by recording the right spans for the `self` part of the `&self` 0th argument 3. Remove the suggestion for adjusting a trait signature on type mismatch, bc that's gonna probably break all the other impls of the trait even if it fixes its one usage :sweat_smile:
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-2/+2
2023-06-28Adjust inner span of implicit self ref argumentMichael Goulet-4/+4
2023-05-04Even more testsMichael Goulet-0/+280
2023-04-27Explicitly reject negative and reservation drop implsMichael Goulet-0/+33
2023-01-17Account for method call and indexing when looking for inner-most path in ↵Esteban Küber-0/+2
expression
2023-01-15Tweak E0597Esteban Küber-6/+26
CC #99430
2023-01-11Move /src/test to /testsAlbert Larsan-0/+1663