about summary refs log tree commit diff
path: root/src/test/ui/closures/2229_closure_analysis
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-10257/+0
2023-01-05Detect closures assigned to binding in blockEsteban Küber-13/+16
Fix #58497.
2022-12-28Use verbose suggestions for mutability errorsEsteban Küber-3/+5
2022-11-10Tweak span for `#[must_use]`Esteban Küber-2/+2
Do not point at whole statement, only at the expression (skip pointing at `;`)
2022-10-01bless ui testsMaybe Waffle-19/+19
2022-09-26Auto merge of #102184 - chenyukang:fix-102087-add-binding-sugg, r=nagisabors-0/+5
Suggest Default::default() when binding isn't initialized Fixes #102087
2022-09-26fix #102087, Suggest Default::default() when binding isn't initializedyukang-0/+5
2022-09-23Adapt test resultsFlorian Bartels-2/+1
2022-09-23Restore ignore tagFlorian Bartels-1/+0
This test case actually requires std::process.
2022-09-03Include enum path in variant suggestionMichael Goulet-5/+5
2022-08-31Fix a bunch of typoDezhi Wu-9/+9
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-23Use par_body_owners for livenessSeo Sanghyeon-8/+8
2022-08-21Note closure kind mismatch causeMichael Goulet-2/+18
2022-08-21Rework point-at-argMichael Goulet-2/+2
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-6/+6
2022-07-19Mention first and last macro in backtraceMichael Goulet-5/+5
2022-07-08Auto merge of #98482 - cjgillot:short-struct-span-closure, r=estebankbors-20/+10
Shorten def_span of closures to just their header Continuation of https://github.com/rust-lang/rust/pull/93967.
2022-07-07Tweak wording and spansEsteban Küber-17/+17
2022-07-07On partial uninit error point at where we need initEsteban Küber-29/+41
When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an unitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context.
2022-07-07Shorten span for closures.Camille GILLOT-20/+10
2022-07-01Auto merge of #93967 - cjgillot:short-struct-span, r=petrochenkovbors-2/+2
Shorten def_span for more items. The `def_span` query only returns the signature span for functions. Struct/enum/union definitions can also have a very long body. This PR shortens the associated span.
2022-07-01Shorten def_span for more items.Camille GILLOT-2/+2
2022-06-22Uniform spans in dead code lint.Camille GILLOT-2/+2
2022-06-19collapse dead code warnings into a single diagnosticTakayuki Maeda-17/+15
add comments in `store_dead_field_or_variant` support multiple log level add a item ident label fix ui tests fix a ui test fix a rustdoc ui test use let chain refactor: remove `store_dead_field_or_variant` fix a tiny bug
2022-06-17Auto merge of #97892 - klensy:fix-spaces, r=oli-obkbors-1/+1
diagnostics: remove trailing spaces Remove few occurrences of trailing spaces and drive by fix of needless alloc of const string.
2022-06-16--bless uiMaybe Waffle-12/+9
2022-06-16 fix one more case of trailing spaceklensy-1/+1
2022-05-23Fix precise field capture of univariant enumsTomasz Miąsko-0/+27
When constructing a MIR from a THIR field expression, introduce an additional downcast projection before accessing a field of an enum. When rebasing a place builder on top of a captured place, account for the fact that a single HIR enum field projection corresponds to two MIR projection elements: a downcast element and a field element.
2022-05-05Put the 2229 migration errors in alphabetical orderScott McMurray-3/+3
Looks like they were in FxHash order before, so it might just be luck that this used to be consistent across different word lengths.
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-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-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-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-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-05apply suggestions from code reviewNiko Matsakis-42/+42