about summary refs log tree commit diff
path: root/src/test/ui/generator
AgeCommit message (Collapse)AuthorLines
2021-09-30Rollup merge of #89321 - tmiasko:rebase-resume-arg, r=estebankManish Goregaokar-3/+9
Rebase resume argument projections during state transform When remapping a resume argument with projections rebase them on top of the new base. The case where resume argument has projections is unusual, but might arise with box syntax where the assignment is performed directly into the box without an intermediate temporary. Fixes #85635.
2021-09-30Auto merge of #89110 - Aaron1011:adjustment-span, r=estebankbors-2/+2
Use larger span for adjustment THIR expressions Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions. These spans are recoded when we first create the adjustment during typecheck. For example, an autoref adjustment triggered by a method call will record the span of the entire method call. The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-28Rebase resume argument projections during state transformTomasz Miąsko-3/+9
When remapping a resume argument with projections rebase them on top of the new base. The case where resume argument has projections is unusual, but might arise with box syntax where the assignment is performed directly into the box without an intermediate temporary.
2021-09-27Improve cause information for NLL higher-ranked errorsAaron Hill-0/+5
This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
2021-09-25Use larger span for adjustments on method callsAaron Hill-2/+2
Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-17Rollup merge of #88911 - FabianWolff:issue-88653, r=petrochenkovYuki Okushi-0/+31
Improve error message for type mismatch in generator arguments Fixes #88653. The code example given there is invalid because the `Generator` trait (unlike the `Fn` traits) does not take the generator arguments in tupled-up form (because there can only be one argument, from my understanding). Hence, the type error in the example in #88653 is correct, because the given generator takes a `bool` argument, whereas the function's return type talks about a generator with a `(bool,)` argument. The error message is both confusing and wrong, though: It is wrong because it displays the wrong "expected signature", and it is confusing because both the "expected" and "found" notes point at the same span. With my changes, I get the following, more helpful output: ``` error[E0631]: type mismatch in generator arguments --> test.rs:5:22 | 5 | fn foo(bar: bool) -> impl Generator<(bool,)> { | ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _` 6 | |bar| { | ----- found signature of `fn(bool) -> _` ```
2021-09-16Point at call span that introduced obligation for the argEsteban Kuber-1/+3
2021-09-13Improve error message for type mismatch in generator argumentsFabian Wolff-0/+31
2021-08-25Auto merge of #87937 - LeSeulArtichaut:active-if-let-guards, r=nagisabors-1/+0
Don't mark `if_let_guard` as an incomplete feature I don't think there is any reason for `if_let_guard` to be an incomplete feature, and I think the reason they were marked in the first place was simply because they weren't implemented at all. r? `@pnkfelix` cc tracking issue #51114
2021-08-18Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakisbors-6/+16
Matthew's work on improving NLL's "higher-ranked subtype error"s This PR rebases `@matthewjasper's` [branch](https://github.com/matthewjasper/rust/tree/nll-hrtb-errors) which has great work to fix the obscure higher-ranked subtype errors that are tracked in #57374. These are a blocker to turning full NLLs on, and doing some internal cleanups to remove some of the old region code. The goal is so `@nikomatsakis` can take a look at this early, and I'll then do my best to help do the changes and followup work to land this work, and move closer to turning off the migration mode. I've only updated the branch and made it compile, removed a warning or two. r? `@nikomatsakis` (Here's the [zulip topic to discuss this](https://rust-lang.zulipchat.com/#narrow/stream/122657-t-compiler.2Fwg-nll/topic/.2357374.3A.20improving.20higher-ranked.20subtype.20errors.20via.20.2386700) that Niko wanted)
2021-08-16Use note to point at bound introducing requirementEsteban Küber-41/+63
2021-08-16Don't mark `if_let_guard` as an incomplete featureLéo Lanteri Thauvin-1/+0
2021-08-15Report nicer errors for HRTB NLL errors from queriesMatthew Jasper-6/+16
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-1/+1
2021-07-27Remove min_tait and full_tait stderr dangling filesSantiago Pastorino-44/+0
2021-07-27Make all tests use type_alias_impl_trait feature instead of minSantiago Pastorino-7/+20
2021-07-27Use type_alias_impl_trait instead of min in compiler and libSantiago Pastorino-27/+7
2021-07-20Auto merge of #87141 - spastorino:remove_impl_trait_in_bindings, r=oli-obkbors-79/+23
Remove impl trait in bindings Closes #86729 r? `@oli-obk`
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-1/+5
* Always point at macros, including derive macros * Point at non-local items that introduce a trait requirement * On private associated item, point at definition
2021-07-18Remove impl_trait_in_bindings feature flagSantiago Pastorino-79/+23
2021-07-06Revert "Revert "Update tests""bjorn3-5/+5
This reverts commit 715c68fe90c6f1d0b3004ad18f16e0811f209992.
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-3/+3
2021-06-12Pretty print generator witness only in `-Zverbose` modeTomasz Miąsko-4/+4
In release build of deeply-nested-async benchmark the size of `no-opt.bc` file is reduced from 46MB to 62kB.
2021-06-07Revert "Update tests"bjorn3-5/+5
This reverts commit c76b1b031753fc08a18a3906d828683476c1e595.
2021-05-30Update testsbjorn3-5/+5
2021-05-27Test THIR unsafeck for unsafe ops in closuresLeSeulArtichaut-0/+3
2021-05-24Replace more "NULL" with "null"LeSeulArtichaut-1/+1
2021-05-20Check for raw pointer dereference in THIR unsafeckLeSeulArtichaut-1/+15
2021-05-12Don't suggest adding `'static` lifetime to argumentsAaron Hill-3/+0
Fixes #69350 This is almost always the wrong this to do
2021-05-02Change 'NULL' to 'null'Brent Kerby-1/+1
2021-05-01Closure capture borrow diagnostics for disjoint capturesChris Pardy-1/+1
2021-04-06Always mention `Box::pin` when dealing with `!Unpin`Esteban Küber-0/+2
2021-04-02Auto merge of #80828 - SNCPlay42:opaque-projections, r=estebankbors-3/+3
Fix expected/found order on impl trait projection mismatch error fixes #68561 This PR adds a new `ObligationCauseCode` used when checking the concrete type of an impl trait satisfies its bounds, and checks for that cause code in the existing test to see if a projection's normalized type should be the "expected" or "found" type. The second commit adds a `peel_derives` to that test, which appears to be necessary in some cases (see projection-mismatch-in-impl-where-clause.rs, which would still give expected/found in the wrong order otherwise). This caused some other changes in diagnostics not involving impl trait, but they look correct to me.
2021-03-20Move some tests to more reasonable directories - 5Caio-0/+20
2021-03-16fix expected/found order on impl trait projection mismatchSNCPlay42-3/+3
2021-03-15Only allow tait defining uses in function and method return positionOli Scherer-11/+75
2021-03-15Replace `type_alias_impl_trait` by `min_type_alias_impl_trait` with no ↵Oli Scherer-3/+56
actual changes in behaviour This makes `type_alias_impl_trait` not actually do anything anymore
2021-03-12Make def_key and HIR parenting consistent.Camille GILLOT-5/+5
2021-02-19Rollup merge of #82245 - estebank:issue-78653, r=matthewjasperDylan DPC-0/+28
Do not ICE when evaluating locals' types of invalid `yield` When a `yield` is outside of a generator, check its value regardless to avoid an ICE while trying to get all locals' types in writeback. Fix #78653.
2021-02-17Do not ICE when evaluating locals' types of invalid `yield`Esteban Küber-0/+28
When a `yield` is outside of a generator, check its value regardless to avoid an ICE while trying to get all locals' types in writeback. Fix #78653.
2021-02-10Keep existing names of regions in placeholder_errorMatthew Jasper-4/+4
2021-02-09Remove unnecessary note on errorsMatthew Jasper-12/+0
Seeing the trait definition doesn't help with implementation not general enough errors, so don't make the error message larger to show it.
2021-02-06path trimming: ignore type aliasesDan Aloni-5/+5
2021-02-01Update ui testsJesus Rubio-0/+1
2021-01-15Rollup merge of #81008 - tmiasko:generator-layout-err, r=tmandryYuki Okushi-0/+37
Don't ICE when computing a layout of a generator tainted by errors Fixes #80998.
2021-01-14Don't ICE when computing a layout of a generator tainted by errorsTomasz Miąsko-0/+37
2021-01-14Encode optimized MIR of generators when emitting metadataTomasz Miąsko-0/+34
2021-01-12Provide more information for HRTB lifetime errors involving closuresEsteban Küber-2/+30
2020-12-06Add a few basic tests for if-let guardsLeSeulArtichaut-0/+11
2020-11-23Rename `optin_builtin_traits` to `auto_traits`Camelid-1/+1
They were originally called "opt-in, built-in traits" (OIBITs), but people realized that the name was too confusing and a mouthful, and so they were renamed to just "auto traits". The feature flag's name wasn't updated, though, so that's what this PR does. There are some other spots in the compiler that still refer to OIBITs, but I don't think changing those now is worth it since they are internal and not particularly relevant to this PR. Also see <https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/opt-in.2C.20built-in.20traits.20(auto.20traits).20feature.20name>.