about summary refs log tree commit diff
path: root/src/test/ui/pattern
AgeCommit message (Collapse)AuthorLines
2022-03-30Restore `impl Future<Output = Type>` to async blocksMichael Goulet-1/+1
2022-03-27Point (again) to more expressions with their type, even if not fully resolvedEsteban Kuber-1/+8
2022-03-22remove [async output] from impl FutureMichael Goulet-1/+1
2022-03-16Rollup merge of #94868 - dtolnay:noblock, r=Dylan-DPCDylan DPC-1/+1
Format core and std macro rules, removing needless surrounding blocks Many of the asserting and printing macros in `core` and `std` are written with prehistoric-looking formatting, like this: https://github.com/rust-lang/rust/blob/335ffbfa547df94ac236f5c56130cecf99c8d82b/library/std/src/macros.rs#L96-L101 In modern Rust style this would conventionally be written as follows instead, always using braces and a trailing semicolon on the macro arms: https://github.com/rust-lang/rust/blob/af53809c874e0afb7be966df4d3cfcaa05277c53/library/std/src/macros.rs#L98-L105 Getting rid of the unneeded braces inside the expansion reduces extraneous indentation in macro-expanded code. For example: ```rust println!("repro {}", true); ``` ```rust // before: { ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); }; ``` ```rust // after: ::std::io::_print( ::core::fmt::Arguments::new_v1( &["repro ", "\n"], &[::core::fmt::ArgumentV1::new_display(&true)], ), ); ```
2022-03-12Fix rebase conflicts with stderr filesDevin Ragotzy-53/+160
2022-03-12Only filter doc(hidden) fields/variants when not crate localDevin Ragotzy-9/+65
2022-03-12Update output for doc hidden usefulness ui test outputDevin Ragotzy-62/+64
2022-03-12Add struct to doc hidden usefulness ui testsDevin Ragotzy-11/+35
2022-03-12Add struct to stability ui tests in usefulnessDevin Ragotzy-15/+60
2022-03-11Format core and std macro rules, removing needless surrounding blocksDavid Tolnay-1/+1
2022-03-08Do not suggest `let_else` if no bindings would be introducedEsteban Kuber-16/+0
2022-03-08Suggest `if let`/`let_else` for refutable pat in `let`Esteban Kuber-14/+38
2022-03-08Change wording of suggestion to add missing `match` armEsteban Kuber-146/+146
2022-03-08Point at uncovered variants in enum definition in `note` instead of a ↵Esteban Kuber-523/+654
`span_label` This makes the order of the output always consistent: 1. Place of the `match` missing arms 2. The `enum` definition span 3. The structured suggestion to add a fallthrough arm
2022-03-08When finding a match expr with multiple arms that requires more, suggest itEsteban Kuber-47/+235
Given ```rust match Some(42) { Some(0) => {} Some(1) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} Some(1) => {} None | Some(_) => todo!(), } ```
2022-03-08When finding a match expr with a single arm that requires more, suggest itEsteban Kuber-76/+377
Given ```rust match Some(42) { Some(0) => {} } ``` suggest ```rust match Some(42) { Some(0) => {} None | Some(_) => todo!(), } ```
2022-03-08When encountering a match expr with no arms, suggest itEsteban Kuber-146/+181
Given ```rust match Some(42) {} ``` suggest ```rust match Some(42) { None | Some(_) => todo!(), } ```
2022-03-03Cleanup feature gates.Camille GILLOT-13/+12
2022-01-18Formally implement let chainsCaio-30/+0
2022-01-01Move `PatKind::Lit` checking from ast_validation to ast loweringAaron Hill-0/+71
Fixes #92074 This allows us to insert an `ExprKind::Err` when an invalid expression is used in a literal pattern, preventing later stages of compilation from seeing an unexpected literal pattern.
2021-12-14Make TyS::is_suggestable more structualMichael Goulet-8/+1
2021-11-26Auto merge of #91164 - Badel2:usefulness-stack-overflow, r=davidtwcobors-0/+14
Fix stack overflow in `usefulness.rs` Fix #88747 Applied the suggestion from `@nbdd0121,` not sure if this has any drawbacks. The first call to `ensure_sufficient_stack` is not needed to fix the test case, but I added it to be safe.
2021-11-25Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebankMatthias Krüger-1/+1
Print associated types on opaque `impl Trait` types This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future. before: ``` error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32` ``` after: ``` error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32` ``` --- Questions: 1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary? 2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later.. 3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back? 4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that? r? ````@estebank````
2021-11-23Fix stack overflow in `usefulness.rs`Badel2-0/+14
2021-11-23Update test outputsMichael Goulet-1/+1
2021-11-22Split inline const to two feature gatesGary Guo-1/+1
2021-11-20Rollup merge of #90575 - m-ou-se:compatible-variant-improvements, r=estebankMatthias Krüger-4/+6
Improve suggestions for compatible variants on type mismatch. Fixes #90553. Before: ![image](https://user-images.githubusercontent.com/783247/140385675-6ff41090-eca2-41bc-b161-99c5dabfec61.png) After: ![image](https://user-images.githubusercontent.com/783247/140385748-20cf26b5-ea96-4e56-8af2-5fe1ab16fd3b.png) r? `````@estebank`````
2021-11-18Move some tests to more reasonable directoriesCaio-0/+44
2021-11-16Update tests.Mara Bos-4/+6
2021-11-06Move some tests to more reasonable directoriesCaio-0/+121
2021-10-19Reject closures in patternsTomasz Miąsko-0/+28
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-1/+1
2021-10-13Rollup merge of #89777 - pierwill:fix-88233, r=Mark-SimulacrumYuki Okushi-1/+1
Edit explanation of test for nested type ascriptions Fixes typo ("an ascribing") and removes extra. Closes #88233.
2021-10-12Filter unstable and doc hidden variants in usefulness checkingDevin Ragotzy-0/+185
Add test cases for unstable variants Add test cases for doc hidden variants Move is_doc_hidden to method on TyCtxt Add unstable variants test to reachable-patterns ui test Rename reachable-patterns -> omitted-patterns
2021-10-11Edit explanation of test for nested type ascriptionspierwill-1/+1
Closes #88233
2021-10-04Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakisJubilee-12/+66
Perform type inference in range pattern Fix #88074
2021-10-01Rollup merge of #89441 - Nadrieril:fix-89393, r=tmandryManish Goregaokar-22/+56
Normalize after substituting via `field.ty()` Back in https://github.com/rust-lang/rust/issues/72476 I hadn't understood where the problem was coming from, and only worked around the issue. What happens is that calling `field.ty()` on a field of a generic struct substitutes the appropriate generics but doesn't normalize the resulting type. As a consumer of types I'm surprised that one would substitute without normalizing, feels like a footgun, so I added a comment. Fixes https://github.com/rust-lang/rust/issues/89393.
2021-10-01Normalize after substituting via `field.ty()`Nadrieril-22/+56
2021-09-29Auto merge of #88950 - Nadrieril:deconstruct-pat, r=oli-obkbors-16/+95
Add an intermediate representation to exhaustiveness checking The exhaustiveness checking algorithm keeps deconstructing patterns into a `Constructor` and some `Fields`, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start. I find this makes code easier to follow. In particular `DeconstructedPat::specialize` is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm from `rustc_middle::Pat`.
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-9/+9
2021-09-26Replace `Pat` with a new intermediate representationNadrieril-14/+48
2021-09-26Rework `Fields` internals.Nadrieril-2/+2
Now `Fields` is just a `Vec` of patterns, with some extra info on the side to reconstruct patterns when needed. This emphasizes that this extra info is not central to the algorithm.
2021-09-22Add testsNadrieril-0/+45
2021-09-10Add a range pattern inference failing testGary Guo-0/+49
2021-09-10Add ui test for issue 88074Gary Guo-0/+16
2021-09-10Perform type inference in range patternGary Guo-12/+1
2021-08-30Handle irrufutable or unreachable let-elseCameron Steffen-12/+21
2021-08-26Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebankManish Goregaokar-37/+1020
Make spans for tuple patterns in E0023 more precise As suggested in #86307. Closes #86307. r? ````@estebank````
2021-08-25Adjust spansNoah Lev-69/+193
* Highlight the whole pattern if it has no fields * Highlight the whole definition if it has no fields * Only highlight the pattern name if the pattern is multi-line * Determine whether a pattern is multi-line based on distance from name to last field, rather than first field
2021-08-21Bless testsNoah Lev-17/+17