summary refs log tree commit diff
path: root/tests/ui/pattern
AgeCommit message (Collapse)AuthorLines
2025-03-15Rollup merge of #138460 - xizheyin:issue-138319, r=petrochenkovLeón Orell Valerian Liehr-0/+22
Pass struct field HirId when check_expr_struct_fields Fixes #138319 r? compiler cc ``@Mark-Simulacrum``
2025-03-14Pass precise HirId when calling check_stabilityxizheyin-0/+22
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-03-13EUV: fix place of deref pattern's interior's scrutineedianne-0/+15
The place previously used here was that of the temporary holding the reference returned by `Deref::deref` or `DerefMut::deref_mut`. However, since the inner pattern of `deref!(inner)` expects the deref-target type itself, this would ICE when that type was inspected (e.g. by the EUV case for slice patterns). This adds a deref projection to fix that. Since current in-tree consumers of EUV (upvar inference and clippy) don't care about Rvalues, the place could be simplified to `self.cat_rvalue(pat.hir_id, self.pat_ty_adjusted(subpat)?)` to save some cycles. I personally find EUV to be a bit fragile, so I've opted for pedantic correctness. Maybe a `HACK` comment would suffice though?
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-40/+46
2025-02-25Make E0614 a structured errorEsteban Küber-2/+2
``` error[E0614]: type `(..., ..., ..., ...)` cannot be dereferenced --> $DIR/long-E0614.rs:10:5 | LL | *x; | ^^ can't be dereferenced | = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' = note: consider using `--verbose` to print the full type name to the console ```
2025-02-21Trim suggestion part before generating highlightsMichael Goulet-21/+21
2025-02-21More sophisticated span trimmingMichael Goulet-18/+12
2025-02-20Auto merge of #137295 - matthiaskrgr:rollup-tdu3t39, r=matthiaskrgrbors-1/+31
Rollup of 9 pull requests Successful merges: - #135296 (interpret: adjust vtable validity check for higher-ranked types) - #137106 (Add customized compare for Link in rustdoc) - #137253 (Restrict `bevy_ecs` `ParamSet` hack) - #137262 (Make fewer crates depend on `rustc_ast_ir`) - #137263 (Register `USAGE_OF_TYPE_IR_INHERENT`, remove inherent usages) - #137266 (MIR visitor tweaks) - #137269 (Pattern Migration 2024: properly label `&` patterns whose subpatterns are from macro expansions) - #137277 (stabilize `inherent_str_constructors`) - #137281 (Tweak "expected ident" parse error to avoid talking about doc comments) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19don't get trapped inside of expansions when trimming labelsdianne-6/+3
2025-02-19add a failing testdianne-1/+34
2025-02-18"classic2021" ruleset: experimentally add fallback-to-outer (eat both)dianne-116/+54
My reasoning: the ruleset implemented by the same feature gate in Edition 2024 always tries to eat the inherited reference first. For consistency, it makes sense to me to say across all editions that users should consider the inherited reference's mutability when wondering if a `&mut` pattern will type.
2025-02-18add mixed-edition testsdianne-0/+486
2025-02-18"structural2021" ruleset: add fallback-to-outer (eat both) deref ruledianne-173/+114
2025-02-18"classic2021" and "structural2021" rulesets: add eat-inherited-ref-alone ↵dianne-514/+163
deref rules
2025-02-18remove old edition-2021-specific testsdianne-187/+0
These are superseded by the old-edition revisions on the shared tests.
2025-02-18add test revisions for old-edition behavior of feature gatesdianne-322/+1783
This also adds `#[cfg]` attributes to tests for bindings' types, to make it visually clearer which revisions type successfully.
2025-02-18Rollup merge of #137161 - dianne:pat-migration-bookkeeping-for-macros, ↵Matthias Krüger-1/+36
r=Nadrieril Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions See the diff between the two commits for how this affected the error message and suggestion. In order to decide how to format those, the pattern migration diagnostic keeps track of which parts of the user's pattern cause problems in Edition 2024. However, it neglected to do some of this bookkeeping when pointing to macro expansion sites. This fixes that.
2025-02-16bookkeep properly when pointing into macro expansionsdianne-2/+6
2025-02-16add a failing testdianne-1/+32
2025-02-17Rename `pattern_complexity` attr as `pattern_complexity_limit`.Nicholas Nethercote-2/+2
For consistency with `recursion_limit`, `move_size_limit`, and `type_length_limit`.
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-16/+16
2025-02-14Consider add-prefix replacements tooMichael Goulet-36/+24
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-12/+8
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-226/+339
``` 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; | ```
2025-02-07Add comment for regression #136223 on borrowck-errors.rsShunpoco-5/+7
Signed-off-by: Shunpoco <tkngsnsk313320@gmail.com>
2025-02-07Rollup merge of #136577 - dianne:simple-pat-migration-simplification, ↵Matthias Krüger-171/+813
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-05add more pattern migration testsdianne-1/+400
Most of these are meant to test possible future improvements, but since they cover cases the existing test suite didn't, I figure including them now may be helpful.
2025-02-05try to suggest eliding redundant binding modifiersdianne-10/+13
2025-02-05reword default binding mode notesdianne-82/+82
2025-02-05Uniformly handle HIR literals in visitors and lintsOli Scherer-1/+10
2025-02-05Add regression testOli Scherer-0/+49
2025-02-05separate labels for default binding mode spans into their own notesdianne-165/+253
2025-02-04don't include trailing open parens in labels for reference patternsdianne-1/+1
2025-02-04experimentally label the spans for default binding modesdianne-166/+165
2025-02-03highlight the whole problem subpattern when pointing out the default binding ↵dianne-43/+161
mode
2025-02-03add tests for label formattingdianne-1/+47
2025-02-03use more specific wording for subpatterns from macro expansionsdianne-1/+1
2025-02-03reword pattern migration diagnostic to make sense in all editionsdianne-160/+149
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-01-30Rollup merge of #135434 - dianne:match-2024-for-edition-2024, r=NadrierilMatthias Krüger-303/+1832
Match Ergonomics 2024: update edition 2024 behavior of feature gates This updates the edition 2024 behavior of the feature gates `ref_pat_eat_one_layer_2024_structural` and `ref_pat_eat_one_layer_2024` to correspond to the left and right typing rules compared [here](https://nadrieril.github.io/typing-rust-patterns/?compare=true&opts2=AQEBAAABAQABAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=rules&do_cmp=true&ty_d=3&style=SequentBindingMode), respectively. I'll implement the proposed new behavior for editions ≤ 2021 in another PR. The tests are split up a bit awkwardly for practical reasons, but I've added new tests from 3 places: - I got tests for where the typing rules differ from the "Compare" tab of the page linked above. These had to be split up based on where the errors are emitted and how rustfixable they are, so they've ended up in different files to keep tidy. Within each file, though, the order of the tests matches the order the typing differences appear in that comparison (as of when this was written). - I used [this other comparison](https://nadrieril.github.io/typing-rust-patterns/?q=%5B%26mut+%26%28mut+x%29%5D%3A+%26mut+%5B%26CT%5D&compare=true&opts2=AQEBAgABAQEBAgIAAQEBAAEBAAABAAA%3D&opts1=AQEBAgEBAQEBAgIAAAAAAAAAAAAAAAA%3D&mode=compare&do_cmp=true&ty_d=3&style=SequentBindingMode) to test the `Deref(EatInner, FallbackToOuter)` rule of the left/"structural"/eat-inner ruleset. These are all in `well-typed-edition-2024.rs`. - I added some select tests for cases where the new typing rules differ from current stable Rust. I had to be pickier about what I included here, but I tried to make sure each typing rule got some coverage. That said, my approach for these tests was a bit ad-hoc, so I may have missed something. Relevant tracking issue: #123076 r? ````@ghost````
2025-01-29Handle all `PatExpr`s in dead code analysisOli Scherer-18/+3
2025-01-29Add regression test showing we don't realize some consts are usedOli Scherer-1/+24
2025-01-27Remove all dead files inside tests/ui/León Orell Valerian Liehr-778/+0
2025-01-21add tests differing between stable and new rules (with errors on new rules)dianne-18/+155
Since there are so many ways to write these, I've opted to only include two sorts of test: simple tests that directly target the rules differing between rulesets and nuanced tests that produce different errors under different rulesets. I've also tried not to add any duplicate tests. `well-typed-edition-2024.rs` already has tests disagreeing with stable, so I've opted not to include any in this commit that are well-typed under the new rules.
2025-01-21organize old well-typed-edition-2024 testsdianne-85/+100
This doesn't (or at least shouldn't!) add, remove, or change any test cases. I've grouped them by which rule variants they test.
2025-01-21add a stable edition 2021 revision to pattern typing testsdianne-198/+1103
This serves two purposes. First, they're additional tests that stable Rust behavior hasn't been messed with. There's plenty of other pattern tests, so this is less important, but these at least are targeted at what's being changed. Second, this helps document exactly where the new rulesets agree and disagree with stable pattern typing. This will be especially important after the new rules for old editions are updated, since they need to be strictly more permissive; any patterns well-typed on stable should also be well-typed with the same resultant bindings on the (upcoming) new new old-edition rules. The unusual test ordering on `borrowck-errors.rs` and `ref-binding-on-inh-ref-errors.rs` are to hopefully reduce how much adding new tests will mess with line numbers in their stderr.
2025-01-21add more information to old testsdianne-28/+36
2025-01-21minor test cleanupdianne-59/+26
- Removes some excess parens - Removes 3 duplicated tests
2025-01-20rename tests' revisions to allow testing multiple editionsdianne-93/+93
2025-01-20"structural" ruleset: match against the inherited ref when a reference ↵dianne-62/+61
pattern doesn't match the mutability of an inner reference This is the `Deref(EatInner, FallbackToOuter)` rule in Typing Rust Patterns.
2025-01-20"structural" ruleset: use the "classic" ruleset's diagnostic and fallback ↵dianne-355/+120
for inherited ref mutability mismatches I think the diagnostic could use some work, but it's more helpful than the alternative. The previous error was misleading, since it ignored the inherited reference altogether.