about summary refs log tree commit diff
path: root/src/test/ui/coercion
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-1575/+0
2022-11-19Use `type_ascribe!` in many UI testsNilstrieb-61/+61
Use it in all UI tests that are about the semantics and not the syntax of type ascription.
2022-10-30Rollup merge of #103124 - ldm0:nohard_tests, r=Mark-SimulacrumMatthias Krüger-0/+149
Add tests for autoderef on block tail ref: https://github.com/rust-lang/rust/pull/83850#issuecomment-1270598506
2022-10-27add test for issue 36007Rageking8-0/+20
2022-10-17Add tests for autoderef on block tailbogon-right-0/+149
2022-10-04slightly improve no return for returning function errorRageking8-2/+2
2022-08-27SadMichael Goulet-0/+16
2022-08-12Point out a single arg if we have a single arg incompatibilityMichael Goulet-6/+6
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-1/+1
2022-07-27use check_region_obligations_and_report_errors in more places to avoid ICEsMichael Goulet-0/+27
2022-07-07Shorten span for closures.Camille GILLOT-3/+3
2022-06-28Note concrete type being coerced into objectMichael Goulet-4/+4
2022-05-08Auto merge of #96302 - Serial-ATA:more-diagnostic-items, r=manishearthbors-40/+0
Add more diagnostic items This just adds a handful diagnostic items I noticed were missing. Would it be worth doing this for all of the remaining types? I'm willing to do it if it'd be helpful.
2022-05-06Resolve vars in note_type_errJack Huey-2/+2
2022-04-28Update ui testsSerial-40/+0
2022-04-26Fix the filename in the expected error message.Dan Gohman-2/+2
2022-04-26Add `only-windows` versions of the coerce-issue-49593-box-never test.Dan Gohman-0/+97
2022-04-19Update line numbers in the expected output.Dan Gohman-2/+2
2022-04-19Add ignore-windows to a test.Dan Gohman-0/+1
This test has an expected stderr containing text like this: ``` help: the following other types implement trait `std::error::Error`: ... and 43 others ``` However, the number 43 is platform-specific; on Windows, there are two additional types, `InvalidHandleError` and `NullHandleError`, and the number of 45. So for now, disable this test on Windows.
2022-04-18Update the expected stderr for coerce-issue-49593-box-never.Dan Gohman-2/+2
2022-04-18Update the expected stderr for coerce-issue-49593-box-never.Dan Gohman-2/+2
This test's expected stderr now includes a count of the number of types that implment `Error`. This PR introduces two new types, so increment the number by two.
2022-04-16Implementation for 65853Jack Huey-9/+58
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-10only suggest removing semicolon when expr implements traitMichael Goulet-2/+2
2022-04-08Add ThinBox type for 1 stack pointer sized heap allocated trait objectsJane Lusby-2/+2
Relevant commit messages from squashed history in order: Add initial version of ThinBox update test to actually capture failure swap to middle ptr impl based on matthieu-m's design Fix stack overflow in debug impl The previous version would take a `&ThinBox<T>` and deref it once, which resulted in a no-op and the same type, which it would then print causing an endless recursion. I've switched to calling `deref` by name to let method resolution handle deref the correct number of times. I've also updated the Drop impl for good measure since it seemed like it could be falling prey to the same bug, and I'll be adding some tests to verify that the drop is happening correctly. add test to verify drop is behaving add doc examples and remove unnecessary Pointee bounds ThinBox: use NonNull ThinBox: tests for size Apply suggestions from code review Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com> use handle_alloc_error and fix drop signature update niche and size tests add cfg for allocating APIs check null before calculating offset add test for zst and trial usage prevent optimizer induced ub in drop and cleanup metadata gathering account for arbitrary size and alignment metadata Thank you nika and thomcc! Update library/alloc/src/boxed/thin.rs Co-authored-by: Josh Triplett <josh@joshtriplett.org> Update library/alloc/src/boxed/thin.rs Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-04-04Mention implementers of unsatisfied traitEsteban Kuber-0/+20
When encountering an unsatisfied trait bound, if there are no other suggestions, mention all the types that *do* implement that trait: ``` error[E0277]: the trait bound `f32: Foo` is not satisfied --> $DIR/impl_wf.rs:22:6 | LL | impl Baz<f32> for f32 { } | ^^^^^^^^ the trait `Foo` is not implemented for `f32` | = help: the following other types implement trait `Foo`: Option<T> i32 str note: required by a bound in `Baz` --> $DIR/impl_wf.rs:18:31 | LL | trait Baz<U: ?Sized> where U: Foo { } | ^^^ required by this bound in `Baz` ``` Mention implementers of traits in `ImplObligation`s. Do not mention other `impl`s for closures, ranges and `?`.
2021-11-18Move some tests to more reasonable directoriesCaio-0/+37
2021-11-14Move some tests to more reasonable directoriesCaio-0/+17
2021-11-06Move some tests to more reasonable directoriesCaio-0/+79
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-1/+0
2021-09-17Add nofallback testsMark Rousskov-2/+27
2021-08-19Fix non-capturing closure return type coercionFabian Wolff-0/+31
2021-06-30Move some UI tests to more suitable subdirsYuki Okushi-0/+37
2021-02-06path trimming: ignore type aliasesDan Aloni-2/+2
2020-09-02pretty: trim paths of unique symbolsDan Aloni-26/+26
If a symbol name can only be imported from one place for a type, and as long as it was not glob-imported anywhere in the current crate, we can trim its printed path and print only the name. This has wide implications on error messages with types, for example, shortening `std::vec::Vec` to just `Vec`, as long as there is no other `Vec` importable anywhere. This adds a new '-Z trim-diagnostic-paths=false' option to control this feature. On the good path, with no diagnosis printed, we should try to avoid issuing this query, so we need to prevent trimmed_def_paths query on several cases. This change also relies on a previous commit that differentiates between `Debug` and `Display` on various rustc types, where the latter is trimmed and presented to the user and the former is not.
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-2/+20
2020-06-19coerce reborrow multi arg testBastian Kauschke-0/+27
2020-06-19merge coercion test foldersBastian Kauschke-29/+420
2020-06-18Rollup merge of #73361 - estebank:non-primitive-cast, r=davidtwcoManish Goregaokar-6/+2
Tweak "non-primitive cast" error - Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-15Tweak "non-primitive cast" errorEsteban Küber-6/+2
- Suggest borrowing expression if it would allow cast to work. - Suggest using `<Type>::from(<expr>)` when appropriate. - Minor tweak to `;` typo suggestion. Partily address #47136.
2020-06-09Relate existential associated types with variance InvariantSantiago Pastorino-1/+1
2020-01-16review commentsEsteban Küber-7/+7
2019-12-14Revert "Remove `#![feature(never_type)]` from tests."Niko Matsakis-13/+17
This reverts commit 8f6197f39f7d468dfc5b2bd41dae4769992a2f83.
2019-11-21Point at type in `let` assignment on type errorsEsteban Küber-5/+8
2019-11-21Auto merge of #66389 - estebank:type-err-labels, r=petrochenkovbors-71/+64
Specific labels when referring to "expected" and "found" types
2019-11-21Gate fallback via `#![feature(never_type_fallback)]`.Mazdak Farrokhzad-1/+1
2019-11-21Remove `#![feature(never_type)]` from tests.Mazdak Farrokhzad-17/+12
Also remove `never_type` the feature-gate test.
2019-11-18Surround types with backticks in type errorsEsteban Küber-21/+21
2019-11-18Remove E0308 note when primary label has all infoEsteban Küber-16/+9
2019-11-18review comments: tweak prefix stringsEsteban Küber-4/+4
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-38/+38