about summary refs log tree commit diff
path: root/tests/ui/closures/2229_closure_analysis
AgeCommit message (Collapse)AuthorLines
2025-08-27Stabilize BTree{Map,Set}::extract_ifSidney Cammeresi-1/+0
2025-08-20handle opaque types before region inferencelcnr-21/+22
2025-08-19bless tests with new lint messagesKarol Zwolak-2/+2
2025-07-25Mention type that could be `Clone` but isn't in more casesEsteban Küber-0/+18
When encountering a moved value of a type that isn't `Clone` because of unmet obligations, but where all the unmet predicates reference crate-local types, mention them and suggest cloning, as we do in other cases already: ``` error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure --> f111.rs:14:25 | 13 | fn do_stuff(foo: Option<Foo>) { | --- captured outer variable 14 | require_fn_trait(|| async { | -- ^^^^^ `foo` is moved here | | | captured by this `Fn` closure 15 | if foo.map_or(false, |f| f.foo()) { | --- | | | variable moved due to use in coroutine | move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait | note: if `Foo` implemented `Clone`, you could clone the value --> f111.rs:4:1 | 4 | struct Foo; | ^^^^^^^^^^ consider implementing `Clone` for this type ... 15 | if foo.map_or(false, |f| f.foo()) { | --- you could clone this value ```
2025-07-16future-incompat lints: don't link to the nightly edition-guide versiondianne-28/+28
2025-05-27Update tests with Range parameter to `BTreeMap::extract_if` etc.Sidney Cammeresi-2/+2
2025-04-10replace `//@ compile-flags: --edition` with `//@ edition`Pietro Albini-4/+4
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-47/+47
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-2/+2
2025-02-14Consider add-prefix replacements tooMichael Goulet-3/+2
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-3/+2
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; | ```
2025-01-27Reapply "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Michael Goulet-38/+8
r=davidtwco,RalfJung" This reverts commit 122a55bb442bd1995df9cf9b36e6f65ed3ef4a1d.
2025-01-24Add some notes and test some more pattern variantsZalathar-1/+19
2025-01-24Rename test to `unresolvable-upvar-issue-87987.rs`Zalathar-15/+2
This also suppresses an irrelevant warning, to avoid having to re-bless the output snapshot.
2025-01-18Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵Rémy Rakic-8/+38
r=davidtwco,RalfJung" This reverts commit b57d93d8b9525fa261404b4cd9c0670eeb1264b8, reversing changes made to 0aeaa5eb22180fdf12a8489e63c4daa18da6f236.
2024-12-31chore: fix some typospeicuiping-1/+1
Signed-off-by: peicuiping <ezc5@sina.cn>
2024-12-15Auto merge of #134318 - matthiaskrgr:rollup-jda0jkx, r=matthiaskrgrbors-0/+5
Rollup of 7 pull requests Successful merges: - #132939 (Suggest using deref in patterns) - #133293 (Updates Solaris target information, adds Solaris maintainer) - #133392 (Fix ICE when multiple supertrait substitutions need assoc but only one is provided) - #133986 (Add documentation for anonymous pipe module) - #134022 (Doc: Extend for tuples to be stabilized in 1.85.0) - #134259 (Clean up `infer_return_ty_for_fn_sig`) - #134264 (Arbitrary self types v2: Weak & NonNull diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-14Rollup merge of #132939 - uellenberg:suggest-deref, r=oli-obkMatthias Krüger-0/+5
Suggest using deref in patterns Fixes #132784 This changes the following code: ```rs use std::sync::Arc; fn main() { let mut x = Arc::new(Some(1)); match x { Some(_) => {} None => {} } } ``` to output ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | LL | match x { | - this expression has type `Arc<Option<{integer}>>` ... LL | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | LL | match *x { | ~~ ``` instead of ```rs error[E0308]: mismatched types --> src/main.rs:5:9 | 4 | match x { | - this expression has type `Arc<Option<{integer}>>` 5 | Some(_) => {} | ^^^^^^^ expected `Arc<Option<{integer}>>`, found `Option<_>` | = note: expected struct `Arc<Option<{integer}>>` found enum `Option<_>` ``` This makes it more obvious that a Deref is available, and gives a suggestion on how to use it in order to fix the issue at hand.
2024-12-14Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadata, ↵bors-38/+8
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-13Suggest using deref in patternsuellenberg-0/+5
Fixes #132784
2024-12-12Filter empty lines, comments and delimiters from previous to last multiline ↵Esteban Küber-114/+31
span rendering
2024-12-12Tweak multispan renderingEsteban Küber-30/+0
Consider comments and bare delimiters the same as an "empty line" for purposes of hiding rendered code output of long multispans. This results in more aggressive shortening of rendered output without losing too much context, specially in `*.stderr` tests that have "hidden" comments.
2024-12-03Bounds-check with PtrMetadata instead of Len in MIRScott McMurray-38/+8
2024-11-23Update tests for new TRPL chapter orderChris Krycho-7/+7
2024-11-17Make suggestion verboseEsteban Küber-4/+5
2024-11-17Point at `const` definition when used instead of a binding in a `let` statementEsteban Küber-1/+3
After: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | const PAT: u32 = 0; | -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable ... LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ``` Before: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ```
2024-11-13Suggest borrowing arguments in generic positions when trait bounds are satisfieddianne-16/+0
This subsumes the suggestions to borrow arguments with `AsRef`/`Borrow` bounds and those to borrow arguments with `Fn` and `FnMut` bounds. It works for other traits implemented on references as well, such as `std::io::Read`, `std::io::Write`, and `core::fmt::Write`. Incidentally, by making the logic for suggesting borrowing closures general, this removes some spurious suggestions to mutably borrow `FnMut` closures in assignments, as well as an unhelpful suggestion to add a `Clone` constraint to an `impl Fn` argument.
2024-11-04Remove BorrowKind glob, make names longerMichael Goulet-239/+239
2024-10-05Document things a bit more carefully, also account for coercion in ↵Michael Goulet-4/+2
check_expr_has_type_or_error
2024-08-10Update testsNadrieril-2/+1
2024-07-04More accurate mutability suggestionEsteban Küber-9/+15
2024-07-02chore: remove duplicate wordshattizai-2/+2
2024-06-20Fix `...` in multline code-skips in suggestionsEsteban Küber-3/+3
When we have long code skips, we write `...` in the line number gutter. For suggestions, we were "centering" the `...` with the line, but that was consistent with what we do in every other case.
2024-05-03turn pointer_structural_match into a hard errorRalf Jung-27/+2
2024-04-10Handle more cases of value suggestionsEsteban Küber-2/+2
2024-02-23Rollup merge of #120742 - Nadrieril:use-min_exh_pats, r=compiler-errorsMatthias Krüger-12/+0
mark `min_exhaustive_patterns` as complete This is step 1 and 2 of my [proposal](https://github.com/rust-lang/rust/issues/119612#issuecomment-1918097361) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references. r? ``@ghost``
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-196/+196
2024-02-13Unmark the feature gate as incompleteNadrieril-12/+0
2024-02-08Rollup merge of #120775 - Nadrieril:more-min_exh_pats, r=compiler-errorsMatthias Krüger-1/+15
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-08Test `min_exhaustive_patterns` in more casesNadrieril-1/+15
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-1/+1
2024-02-05update the tracking issue for structural match violationsRalf Jung-2/+2
and bless a test I missed
2024-02-05show indirect_structural_match and pointer_structural_match in future compat ↵Ralf Jung-0/+11
reports
2024-01-13Bless testsGeorge-lewis-261/+357
Update tests
2024-01-05Remove `hir::Guard`Matthew Jasper-2/+2
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-10/+10
2023-12-18Fix ICE `ProjectionKinds Deref and Field were mismatched`Gurinder Singh-0/+27
2023-11-24Show number in error message even for one errorNilstrieb-22/+22
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-08Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwcobors-1/+14
patterns: reject raw pointers that are not just integers Matching against `0 as *const i32` is fine, matching against `&42 as *const i32` is not. This extends the existing check against function pointers and wide pointers: we now uniformly reject all these pointer types during valtree construction, and then later lint because of that. See [here](https://github.com/rust-lang/rust/pull/116930#issuecomment-1784654073) for some more explanation and context. Also fixes https://github.com/rust-lang/rust/issues/116929. Cc `@oli-obk` `@lcnr`