about summary refs log tree commit diff
path: root/src/test/ui/closures
AgeCommit message (Collapse)AuthorLines
2022-04-14make unaligned_reference warning visible in future compat reportRalf Jung-0/+14
2022-04-14make unaligned_references lint deny-by-defaultRalf Jung-11/+8
2022-04-10only suggest removing semicolon when expr implements traitMichael Goulet-3/+3
2022-04-05diagnostics: tweak error message to give more rationale to unsafe FnMichael Howell-2/+2
2022-04-04diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMutMichael Howell-0/+1
Fixes #90073
2022-03-30Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakisbors-3/+3
Lazy type-alias-impl-trait take two ### user visible change 1: RPIT inference from recursive call sites Lazy TAIT has an insta-stable change. The following snippet now compiles, because opaque types can now have their hidden type set from wherever the opaque type is mentioned. ```rust fn bar(b: bool) -> impl std::fmt::Debug { if b { return 42 } let x: u32 = bar(false); // this errors on stable 99 } ``` The return type of `bar` stays opaque, you can't do `bar(false) + 42`, you need to actually mention the hidden type. ### user visible change 2: divergence between RPIT and TAIT in return statements Note that `return` statements and the trailing return expression are special with RPIT (but not TAIT). So ```rust #![feature(type_alias_impl_trait)] type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { return vec![42]; } std::iter::empty().collect() //~ ERROR `Foo` cannot be built from an iterator } fn bar(b: bool) -> impl std::fmt::Debug { if b { return vec![42] } std::iter::empty().collect() // Works, magic (accidentally stabilized, not intended) } ``` But when we are working with the return value of a recursive call, the behavior of RPIT and TAIT is the same: ```rust type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { return vec![]; } let mut x = foo(false); x = std::iter::empty().collect(); //~ ERROR `Foo` cannot be built from an iterator vec![] } fn bar(b: bool) -> impl std::fmt::Debug { if b { return vec![]; } let mut x = bar(false); x = std::iter::empty().collect(); //~ ERROR `impl Debug` cannot be built from an iterator vec![] } ``` ### user visible change 3: TAIT does not merge types across branches In contrast to RPIT, TAIT does not merge types across branches, so the following does not compile. ```rust type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { vec![42_i32] } else { std::iter::empty().collect() //~^ ERROR `Foo` cannot be built from an iterator over elements of type `_` } } ``` It is easy to support, but we should make an explicit decision to include the additional complexity in the implementation (it's not much, see a721052457cf513487fb4266e3ade65c29b272d2 which needs to be reverted to enable this). ### PR formalities previous attempt: #92007 This PR also includes #92306 and #93783, as they were reverted along with #92007 in #93893 fixes #93411 fixes #88236 fixes #89312 fixes #87340 fixes #86800 fixes #86719 fixes #84073 fixes #83919 fixes #82139 fixes #77987 fixes #74282 fixes #67830 fixes #62742 fixes #54895
2022-03-28Suggest function borrow ignoring needs_noteMichael Goulet-0/+16
`needs_note` is false if we've already suggested why the type is Copy... but that has nothing to do with the diagnostic.
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-3/+3
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-20Filter OnceNote in diagnostic infra.Camille GILLOT-10/+0
2022-03-08Change wording of suggestion to add missing `match` armEsteban Kuber-6/+6
2022-03-08Point at uncovered variants in enum definition in `note` instead of a ↵Esteban Kuber-12/+25
`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-1/+4
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-3/+14
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-6/+16
Given ```rust match Some(42) {} ``` suggest ```rust match Some(42) { None | Some(_) => todo!(), } ```
2022-02-24Restrict query recursion in `needs_significant_drop`Jakob Degen-0/+14
Overly aggressive use of the query system to improve caching lead to query cycles and consequently ICEs. This patch fixes this by restricting the use of the query system as a cache to those cases where it is definitely correct.
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-3/+3
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-3/+3
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-01-31Auto merge of #90891 - nbdd0121:format, r=Mark-Simulacrumbors-2/+2
Create `core::fmt::ArgumentV1` with generics instead of fn pointer Split from (and prerequisite of) #90488, as this seems to have perf implication. `@rustbot` label: +T-libs
2022-01-29Create `core::fmt::ArgumentV1` with generics instead of fn pointerGary Guo-2/+2
2022-01-28Add test for old ICEBen Reeves-0/+17
The ICE from #84044 no longer occurs.
2022-01-17Emit simpler code from format_argsDavid Tolnay-2/+2
2022-01-07Flatten InferredCaptureInformationGary Guo-28/+101
Min capture computation can already handle the same place appearing twice, and previous commits made CaptureInfo construction very cheap, so just delegate all work to min capture and let InferBorrowKind and process_collected_capture_information handle everything linearly.
2021-12-26fix typo: intialized -> initializedHiroshi Kori-1/+1
2021-12-17Bless ui testsDeadbeef-4/+4
2021-12-11Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgrbors-1/+6
Rollup of 6 pull requests Successful merges: - #83174 (Suggest using a temporary variable to fix borrowck errors) - #89734 (Point at capture points for non-`'static` reference crossing a `yield` point) - #90270 (Make `Borrow` and `BorrowMut` impls `const`) - #90741 (Const `Option::cloned`) - #91548 (Add spin_loop hint for RISC-V architecture) - #91721 (Minor improvements to `future::join!`'s implementation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-11Rollup merge of #89734 - estebank:issue-72312, r=nikomatsakisMatthias Krüger-1/+6
Point at capture points for non-`'static` reference crossing a `yield` point ``` error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement --> $DIR/issue-72312.rs:10:24 | LL | pub async fn start(&self) { | ^^^^^ this data with an anonymous lifetime `'_`... ... LL | require_static(async move { | -------------- ...is required to live as long as `'static` here... LL | &self; | ----- ...and is captured here | note: `'static` lifetime requirement introduced by this trait bound --> $DIR/issue-72312.rs:2:22 | LL | fn require_static<T: 'static>(val: T) -> T { | ^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0759`. ``` Fix #72312.
2021-12-11Rollup merge of #91718 - RalfJung:unaligned_references, r=nagisaMatthias Krüger-0/+1
give more help in the unaligned_references lint Cc https://github.com/rust-lang/rust/issues/82523#issuecomment-988138440 ``@kaisq``
2021-12-10fix tests after rebaseEsteban Kuber-1/+6
2021-12-09Add needs-unwind to tests that depend on panickingDavid Koloski-2/+4
This directive isn't automatically set by compiletest or x.py, but can be turned on manually for targets that require it.
2021-12-09give more help in the unaligned_references lintRalf Jung-0/+1
2021-11-28Rollup merge of #90131 - camsteffen:fmt-args-span-fix, r=cjgillotMatthias Krüger-0/+7
Fix a format_args span to be expansion I found this while exploring solutions for rust-lang/rust-clippy#7843. r? `@m-ou-se`
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-0/+10
Be more thorough in using `ItemObligation` and `BindingObligation` when evaluating obligations so that we can point at trait bounds that introduced unfulfilled obligations. We no longer incorrectly point at unrelated trait bounds (`substs-ppaux.verbose.stderr`). In particular, we now point at trait bounds on method calls. We no longer point at "obvious" obligation sources (we no longer have a note pointing at `Trait` saying "required by a bound in `Trait`", like in `associated-types-no-suitable-supertrait*`). Address part of #89418.
2021-11-18Move some tests to more reasonable directoriesCaio-0/+18
2021-11-17Rollup merge of #90667 - rukai:improve_static_lifetime_diagnostics, r=estebankMatthias Krüger-7/+26
Improve diagnostics when a static lifetime is expected Makes progress towards https://github.com/rust-lang/rust/issues/90600 The diagnostics here were previously entirely removed due to giving a misleading suggestion but if we instead provide an informative label in that same location it should better help the user understand the situation. I included the example from the issue as it demonstrates an area where the diagnostics are still lacking. Happy to remove that if its just adding noise atm.
2021-11-14Move some tests to more reasonable directoriesCaio-0/+58
2021-11-14Improve diagnostics when a static lifetime is expectedLucas Kent-7/+26
2021-11-09Auto merge of #90485 - camsteffen:fmt-args-less-bind, r=m-ou-sebors-2/+2
Don't destructure args tuple in format_args! This allows Clippy to parse the HIR more simply since `arg0` is changed to `_args.0`. (cc rust-lang/rust-clippy#7843). From rustc's perspective, I think this is something between a lateral move and a tiny improvement since there are fewer bindings. r? `@m-ou-se`
2021-11-08Auto merge of #89488 - c410-f3r:testsssssss, r=petrochenkovbors-0/+56
Move some tests to more reasonable directories - 8 cc #73494 r? `@petrochenkov`
2021-11-06Don't destructure args tuple in format_args!Cameron Steffen-2/+2
2021-11-06Move some tests to more reasonable directoriesCaio-0/+56
2021-11-06Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakisbors-3/+3
Normalize obligations for closure confirmation Based on #90017 Fixes #74261 Fixes #71955 Fixes #88459 r? `@nikomatsakis`
2021-11-05apply suggestions from code reviewNiko Matsakis-42/+42
2021-11-04handle case of a variable not capturedNiko Matsakis-0/+95
2021-11-04rework diagnostic reporting to be more structuredNiko Matsakis-45/+56
2021-10-29Fix a format_args span to be expansionCameron Steffen-0/+7
2021-10-23Add regresstion test for #90024.Jakob Degen-0/+37
Uses 2 MCVEs from the issue tracker that test opposite sides of the problem.
2021-10-18Normalize obligations for closure confirmationjackh726-3/+3
2021-10-15Bless testsCameron Steffen-1/+1
2021-10-13Remove textual span from diagnostic stringOli Scherer-4/+4
2021-10-08Add regression testGary Guo-0/+40