about summary refs log tree commit diff
path: root/src/test/ui/hrtb
AgeCommit message (Collapse)AuthorLines
2022-08-13moveEllen-1365/+0
2022-08-10Rollup merge of #100098 - compiler-errors:field-suggestion-fixups, r=davidtwcoMatthias Krüger-8/+0
Some "this expression has a field"-related fixes Each commit does something different and is worth reviewing, but the final diff from `master..HEAD` contains the sum of the changes to the UI tests, since some commits added UI tests "regressions" which were later removed in other commits. The only change I could see adding on top of this is suppressing `Clone::clone` from the "this expression has a field that has this method" suggestion, since it's so commonly implemented by types that it's not worthwhile suggesting in general.
2022-08-08Adjust wordingMichael Goulet-9/+16
2022-08-07Implement special-cased projection error message for some common traitsMichael Goulet-2/+2
2022-08-03Don't suggest field method if it's just missing some boundsMichael Goulet-8/+0
2022-07-28Remove guess_head_span.Camille GILLOT-26/+16
2022-07-18Add regression test for #95230Yuki Okushi-0/+7
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-08Auto merge of #98816 - estebank:implicit-sized, r=oli-obkbors-4/+4
Track implicit `Sized` obligations in type params When we evaluate `ty::GenericPredicates` we introduce the implicit `Sized` predicate of type params, but we do so with only the `Predicate` its `Span` as context, we don't have an `Obligation` or `ObligationCauseCode` we could influence. To try and carry this information through, we add a new field to `ty::GenericPredicates` that tracks both which predicates come from a type param and whether that param has any bounds already (to use in suggestions). We also suggest adding a `?Sized` bound if appropriate on E0599. Address part of #98539.
2022-07-07Track implicit `Sized` obligations in type paramsEsteban Küber-4/+4
Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting the HIR Generics. (Fix #98539)
2022-07-07Shorten span for closures.Camille GILLOT-14/+14
2022-06-26compiletest: add issue number param to `known-bug`David Knaack-1/+1
2022-06-25Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, ↵Matthias Krüger-4/+4
r=compiler-errors Point to type parameter definition when not finding variant, method and associated item fixes #77391
2022-06-22point to type param definition when not finding variant, method and assoc typeTakayuki Maeda-4/+4
use `def_ident_span` , `body_owner_def_id` instead of `in_progress_typeck_results`, `guess_head_span` use `body_id.owner` directly add description to label
2022-06-21Rollup merge of #98022 - compiler-errors:erroneous-borrowck-span, r=oli-obkYuki Okushi-1/+1
Fix erroneous span for borrowck error I am not confident that this is the correct fix, but it does the job. Open to suggestions for a real fix instead. Fixes #97997 The issue is that we pass a [dummy location](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_middle/mir/visit.rs.html#302) when type-checking the ["required consts"](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/struct.Body.html#structfield.required_consts) that are needed by the MIR body during borrowck. This means that when we fail to evaluate the constant, we use the span of `bb0[0]`, instead of the actual span of the constant. There are quite a few other places that use `START_BLOCK.start_location()`, `Location::START`, etc. when calling for a random/unspecified `Location` value. This is because, unlike (for example) `Span`, we don't have a dummy/miscellaneous value to use instead. I would appreciate guidance (either in this PR, or a follow-up) on what needs to be done to clean this up in general.
2022-06-19Make missing argument placeholder more obvious that it's a placeholderMichael Goulet-2/+2
2022-06-12Fix erroneous span for borrowck errorMichael Goulet-1/+1
2022-06-10Rollup merge of #97937 - TaKO8Ki:fix-typo-in-hrtb-just-for-static, r=Dylan-DPCYuki Okushi-1/+1
Fix a typo in `test/ui/hrtb/hrtb-just-for-static.rs` closes #97934
2022-06-10fix a typoTakayuki Maeda-1/+1
2022-06-03Fully stabilize NLLJack Huey-206/+38
2022-05-22Use revisions for NLL in hrtbJack Huey-71/+95
2022-05-22Use revisions for NLL in nllJack Huey-12/+0
2022-05-22Do leak check after function ptr coercionJack Huey-2/+2
2022-05-06Link to correct issue in issue-95034 testAli MJ Al-Nasrawy-0/+2
2022-04-24suggestion if struct field has methodMichael Goulet-0/+16
2022-04-16Implementation for 65853Jack Huey-3/+5
This attempts to bring better error messages to invalid method calls, by applying some heuristics to identify common mistakes. The algorithm is inspired by Levenshtein distance and longest common sub-sequence. In essence, we treat the types of the function, and the types of the arguments you provided as two "words" and compute the edits to get from one to the other. We then modify that algorithm to detect 4 cases: - A function input is missing - An extra argument was provided - The type of an argument is straight up invalid - Two arguments have been swapped - A subset of the arguments have been shuffled (We detect the last two as separate cases so that we can detect two swaps, instead of 4 parameters permuted.) It helps to understand this argument by paying special attention to terminology: "inputs" refers to the inputs being *expected* by the function, and "arguments" refers to what has been provided at the call site. The basic sketch of the algorithm is as follows: - Construct a boolean grid, with a row for each argument, and a column for each input. The cell [i, j] is true if the i'th argument could satisfy the j'th input. - If we find an argument that could satisfy no inputs, provided for an input that can't be satisfied by any other argument, we consider this an "invalid type". - Extra arguments are those that can't satisfy any input, provided for an input that *could* be satisfied by another argument. - Missing inputs are inputs that can't be satisfied by any argument, where the provided argument could satisfy another input - Swapped / Permuted arguments are identified with a cycle detection algorithm. As each issue is found, we remove the relevant inputs / arguments and check for more issues. If we find no issues, we match up any "valid" arguments, and start again. Note that there's a lot of extra complexity: - We try to stay efficient on the happy path, only computing the diagonal until we find a problem, and then filling in the rest of the matrix. - Closure arguments are wrapped in a tuple and need to be unwrapped - We need to resolve closure types after the rest, to allow the most specific type constraints - We need to handle imported C functions that might be variadic in their inputs. I tried to document a lot of this in comments in the code and keep the naming clear.
2022-04-08Rollup merge of #95102 - compiler-errors:issue-94034-bug, r=jackh726Dylan DPC-0/+97
Add known-bug for #95034 Couldn't fix the issue, since I am no type theorist and inference variables in universes above U0 scare me. But I at least wanted to add a known-bug test for it. cc #95034 (does not fix)
2022-03-23Add known-bug for #94034Michael Goulet-0/+97
2022-03-24Properly track `ImplObligation`sEsteban Kuber-16/+16
Instead of probing for all possible impls that could have caused an `ImplObligation`, keep track of its `DefId` and obligation spans for accurate error reporting. Follow up to #89580. Addresses #89418. Remove some unnecessary clones. Tweak output for auto trait impl obligations.
2021-12-11Tweak assoc type obligation spansEsteban Kuber-1/+6
* Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors
2021-11-30Remove all migrate.nll.stderr filesLucas Kent-30/+29
2021-11-20Point at `impl` blocks when they introduce unmet obligationsEsteban Kuber-28/+32
Group obligations by `impl` block that introduced them.
2021-11-20Point at source of trait bound obligations in more placesEsteban Kuber-5/+21
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-04Erase regions within `vtable_trait_first_method_offset`.Charles Lew-0/+32
2021-10-25fix(rustc_typeck): report function argument errors on matching typeMichael Howell-4/+10
Fixes #90101
2021-10-03Don't suggest replacing region with 'static in NLLAaron Hill-4/+0
Fixes #73159 This is similar to #69350 - if the user didn't initially write out a 'static lifetime, adding 'static in response to a lifetime error is usually the wrong thing to do.
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-16Point at call span that introduced obligation for the argEsteban Kuber-3/+9
2021-09-09In relate_tys, when creating new universes, insert missing universes as otherjackh726-0/+35
2021-08-26Rollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakisManish Goregaokar-18/+5
Handle type ascription type ops in NLL HRTB diagnostics Currently, there are still a few cases of the "higher-ranked subtype error" of yore, 4 of which are related to type ascription. This PR is a follow-up to #86700, adding support for type ascription type ops, and makes 3 of these tests output the same diagnostics in NLL mode as the migrate mode (and 1 is now much closer, especially if you ignore that it already outputs an additional error in NLL mode -- which could be a duplicate caused by a lack of normalization like [these comments point out](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/compiler/rustc_traits/src/type_op.rs#L122-L157), or an imprecision in some parts of normalization as [described here](https://github.com/rust-lang/rust/pull/86700#discussion_r689086688)). Since we discussed these recently: - [here](https://github.com/rust-lang/rust/pull/86700#discussion_r689158868), cc ````@matthewjasper,```` - and [here](https://github.com/rust-lang/rust/issues/57374#issuecomment-901500856), cc ````@Aaron1011.```` It should only leave [this TAIT test](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs) as still emitting [the terse error](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr). r? ````@estebank```` (so that they shake their fist at NLL's general direction less often) or ````@nikomatsakis```` or matthew or aaron, the more the merrier.
2021-08-24Normalize associated types with bound varsJack Huey-3/+3
2021-08-24Update NLL HRTB type ascription blessed expectationsRémy Rakic-18/+5
Some of these tests have reached parity with the migrate-mode output.
2021-08-22Fix typos “a”→“an”Frank Steffahn-2/+2
2021-08-18Auto merge of #86700 - lqd:matthews-nll-hrtb-errors, r=nikomatsakisbors-16/+41
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-18Auto merge of #87738 - lqd:polonius-master, r=nikomatsakisbors-17/+19
Update `polonius-engine` to 0.13.0 This PR updates the use of `polonius-engine` to the recently released 0.13.0: - this version renamed a lot of relations to match the current terminology - "illegal subset relationships errors" (AKA "subset errors" or "universal region errors" in rustc parlance) have been implemented in all variants, and therefore the `Hybrid` variant can be the rustc default once again - some of the blessed expectations were updated: new tests have been added since the last time I updated the tests, diagnostics have changed, etc. In particular: - a few tests had trivial expectations changes such as basic diagnostics changes for the migrate-mode and full NLLs - others were recursion and lengths limits which emits a file, and under the polonius compare-mode, the folder has a different name - a few tests were ignored in the NLL compare-mode for reasons that obviously also apply to Polonius - some diagnostics were unified so that older expectations no longer made sense: the NLL and Polonius outputs were identical. - in a few cases Polonius gets a chance to emit more errors than NLLs A few tests in the compare-mode still are super slow and trigger the 60s warning, or OOM rustc during fact generation, and I've detailed these [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Challenges.20for.20move.2Finit.2C.20liveness.2C.20and.20.60Location.3A.3AAll.60): - `src/test/ui/numbers-arithmetic/saturating-float-casts.rs` -> OOM during rustc fact generation - `src/test/ui/numbers-arithmetic/num-wrapping.rs` - `src/test/ui/issues/issue-72933-match-stack-overflow.rs` - `src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs` - `src/test/ui/repr/repr-no-niche.rs` In addition, 2 tests don't currently pass and I didn't want to bless them now: they deal with HRTBs and miss errors that NLLs emit. We're currently trying to see if we need chalk to deal with HRTB errors (as we thought we would have to) but during the recent sprint, we discovered that we may be able to detect some of these errors in a way that resembles subset errors: - `ui/hrtb/hrtb-just-for-static.rs` -> 3 errors in NLL, 2 in polonius: a missing error about HRTB + needing to outlive 'static - `ui/issues/issue-26217.rs` -> missing HRTB that makes the test compile instead of emitting an error We'll keep talking about this at the next sprint as well. cc `@rust-lang/wg-polonius` r? `@nikomatsakis`
2021-08-16Use note to point at bound introducing requirementEsteban Küber-11/+17
2021-08-15Report nicer errors for HRTB NLL errors from queriesMatthew Jasper-14/+35
2021-08-15Report mismatched type errors for bound region errors in NLLMatthew Jasper-2/+6
2021-08-11Modify structured suggestion outputEsteban Küber-3/+3
* On suggestions that include deletions, use a diff inspired output format * When suggesting addition, use `+` as underline * Color highlight modified span
2021-08-03bless `hrtb-perfect-forwarding` under poloniusRémy Rakic-17/+19
Only some simple diagnostic changes happened, and rustfmt-ing.
2021-04-06Point at `impl` and type defs introducing requirements on E0277Esteban Küber-1/+5