about summary refs log tree commit diff
path: root/src/test/ui/methods
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-3405/+0
2023-01-09Consider method return type for various method suggestionsMichael Goulet-0/+45
2023-01-05Tweak wording of fn call with wrong number of argsEsteban Küber-9/+9
2022-12-30Suppress errors due to TypeError not coercing with inference variablesMichael Goulet-14/+2
2022-12-27fix #105788, Remove unreasonable help message for auto traityukang-14/+5
2022-12-16Rollup merge of #105747 - chenyukang:yukang/fix-105732-auto-trait, ↵Matthias Krüger-0/+41
r=compiler-errors Fix ICE calling method on auto trait Fixes #105732 r? `@compiler-errors`
2022-12-16fix #105732, Fix ICE calling method on auto traityukang-0/+41
2022-12-15Trim paths in E0599Esteban Küber-1/+1
2022-12-13Inform the user which trait is meant in the diagnostic itself instead of ↵Oli Scherer-1/+1
relying on the span making it obvious
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-7/+2
available
2022-12-10Introduce `with_forced_trimmed_paths`Esteban Küber-5/+5
2022-11-24Change how suggested lifetime args are computed.Camille GILLOT-4/+4
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-6/+6
2022-10-17Rollup merge of #102454 - chenyukang:fix-102396-missing-parentheses, r=lcnrMatthias Krüger-10/+267
Suggest parentheses for possible range method calling Fixes #102396
2022-10-17trivial fix for comments feedbackyukang-10/+10
2022-10-13Report duplicate definition in impls with overlap check.Camille GILLOT-4/+4
2022-10-04find the correct lang item for rangesyukang-33/+61
2022-10-04fix #102396, suggest parentheses for possible range methodsyukang-10/+239
2022-10-01bless ui testsMaybe Waffle-6/+6
2022-09-03Shrink suggestion span of argument mismatch errorMichael Goulet-4/+4
2022-08-27use smaller span for suggestionsTakayuki Maeda-4/+4
2022-08-12Point out a single arg if we have a single arg incompatibilityMichael Goulet-4/+4
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-3/+3
2022-07-19feat: omit suffixes in const generics (e.g. `1_i32`)Artur Sinila-11/+11
Closes #99255
2022-07-17use rustc_hir_pretty::qpath_to_string to avoid span_to_snippet when ↵Michael Goulet-3/+3
rendering path
2022-07-11Use fake substs to check for `Self: Sized` predicates on method receiversMichael Goulet-0/+59
2022-07-08Auto merge of #98816 - estebank:implicit-sized, r=oli-obkbors-9/+9
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-9/+9
Suggest adding a `?Sized` bound if appropriate on E0599 by inspecting the HIR Generics. (Fix #98539)
2022-07-07Shorten span for closures.Camille GILLOT-2/+2
2022-07-04resolve vars in node substslcnr-1/+5
2022-07-01Shorten def_span for more items.Camille GILLOT-9/+3
2022-06-29Rollup merge of #97542 - compiler-errors:arg-mismatch, r=jackh726Dylan DPC-1/+1
Use typed indices in argument mismatch algorithm I kinda went overboard with the renames, but in general, "arg" is renamed to "expected", and "input" is renamed to "provided", and we use new typed indices to make sure we're indexing into the right sized array. Other drive-by changes: 1. Factor this logic into a new function, so we don't need to `break 'label` to escape it. 1. Factored out dependence on `final_arg_types`, which is never populated for arguments greater than the number of expected args. Instead, we just grab the final coerced expression type from `in_progress_typeck_results`. 1. Adjust the criteria we use to print (provided) type names, before we didn't suggest anything that had infer vars, but now we suggest thing that have infer vars but aren't `_`. ~Also, sorry in advance, I kinda want to backport this but I know I have folded in a lot of unnecessary drive-by changes that might discourage that. I would be open to brainstorming how to get some of these changes on beta at least.~ edit: Minimized the ICE-fixing changes to #97557 cc `@jackh726` as author of #92364, and `@estebank` as reviewer of the PR. fixes #97484
2022-06-28Auto merge of #98396 - cjgillot:iwfchir, r=petrochenkovbors-2/+2
Do not access HIR to check impl wf. r? `@ghost`
2022-06-27Use typed indices in argument mismatch algorithmMichael Goulet-1/+1
2022-06-25Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, ↵Matthias Krüger-9/+9
r=compiler-errors Point to type parameter definition when not finding variant, method and associated item fixes #77391
2022-06-24Bless ui tests.Camille GILLOT-2/+2
2022-06-22point to type param definition when not finding variant, method and assoc typeTakayuki Maeda-9/+9
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-19Make missing argument placeholder more obvious that it's a placeholderMichael Goulet-6/+6
2022-06-02add new `emit_inference_failure_err`lcnr-4/+7
2022-06-01Mention filename in suggestion when it differs from primary spanEsteban Küber-0/+1
2022-04-24diagnostics: regression test for <usize as Iterator>::revMichael Howell-0/+20
Closes #90315
2022-04-17Bless tests.Camille GILLOT-2/+20
2022-04-16Implementation for 65853Jack Huey-17/+39
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-03-11Add regression test for `<i32 as Iterator>::count`Michael Howell-0/+17
Fixes #84495
2022-03-09diagnostics: use rustc_on_unimplemented to recommend `[].iter()`Michael Howell-3/+25
To make this work, the `#[rustc_on_unimplemented]` data needs to be used to report method resolution errors, which is most of what this commit does. Fixes #94581
2022-02-24Remove in-band lifetimesMichael Goulet-2/+0
2021-12-10manually implement `Hash` for `DefId`Andre Bogus-6/+6
This also reorders the fields to reduce the assembly operations for hashing and changes two UI tests that depended on the former ordering because of hashmap iteration order.
2021-10-24Point at overlapping impls when type annotations are neededEsteban Kuber-3/+18
2021-10-05Consider unfulfilled obligations in binop errorsEsteban Kuber-0/+11
When encountering a binop where the types would have been accepted, if all the predicates had been fulfilled, include information about the predicates and suggest appropriate `#[derive]`s if possible. Point at trait(s) that needs to be `impl`emented.
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.