about summary refs log tree commit diff
path: root/src/test/ui/c-variadic
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-637/+0
2023-01-05Tweak wording of fn call with wrong number of argsEsteban Küber-2/+2
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-4/+2
available
2022-11-05Adjust diagnostics, bless testsMichael Goulet-2/+2
2022-10-23Cleanup message and bless testsJack Huey-14/+14
2022-10-23Enable varargs support for calling conventions other than C or cdeclSoveu-19/+102
This patch makes it possible to use varargs for calling conventions, which are either based on C (like efiapi) or C is based on them (for example sysv64 and win64).
2022-09-03Shrink suggestion span of argument mismatch errorMichael Goulet-2/+2
2022-08-12Adjust span of fn argumentsMichael Goulet-3/+3
2022-07-25Report elision failures on the AST.Camille GILLOT-2/+2
2022-06-19Make missing argument placeholder more obvious that it's a placeholderMichael Goulet-4/+4
2022-04-16Implementation for 65853Jack Huey-6/+10
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-04Format invariance notes with backticksMichael Goulet-16/+16
2022-01-21Rollup merge of #92467 - Aaron1011:extern-local-region, r=oli-obkMatthias Krüger-1/+1
Ensure that early-bound function lifetimes are always 'local' During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2022-01-06Rollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwcoMatthias Krüger-0/+14
Some cleanups around check_argument_types Split out in ways from my rebase/continuation of #71827 Commits are mostly self-explanatory and these changes should be fairly straightforward
2021-12-31Ensure that early-bound function lifetimes are always 'local'Aaron Hill-1/+1
During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
2021-12-29Refactor variance diagnostics to work with more typesAaron Hill-0/+28
Instead of special-casing mutable pointers/references, we now support general generic types (currently, we handle `ty::Ref`, `ty::RawPtr`, and `ty::Adt`) When a `ty::Adt` is involved, we show an additional note explaining which of the type's generic parameters is invariant (e.g. the `T` in `Cell<T>`). Currently, we don't explain *why* a particular generic parameter ends up becoming invariant. In the general case, this could require printing a long 'backtrace' of types, so doing this would be more suitable for a follow-up PR. We still only handle the case where our variance switches to `ty::Invariant`.
2021-12-28Slight cleanupJack Huey-0/+14
2021-11-06Move some tests to more reasonable directoriesCaio-0/+22
2021-10-13Remove textual span from diagnostic stringOli Scherer-3/+3
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-04Remove trailing whitespace from error messagesFabian Wolff-1/+1
2021-07-06Replace per-target ABI denylist with an allowlistSimonas Kazlauskas-16/+19
It makes very little sense to maintain denylists of ABIs when, as far as non-generic ABIs are concerned, targets usually only support a small subset of the available ABIs. This has historically been a cause of bugs such as us allowing use of the platform-specific ABIs on x86 targets – these in turn would cause LLVM errors or assertions to fire. Fixes #57182 Sponsored by: standard.ai
2021-06-09Handle C-variadic arguments properly when reporting region errorsFabian Wolff-0/+140
2021-06-06Add variance-related information to lifetime error messagesAaron Hill-0/+8
2021-01-13Update tests for extern block lintingMark Rousskov-6/+6
2020-10-15ensure arguments are included in count mismatch spanAndy Russell-6/+12
2020-10-15fix off-by-one in parameter spansAndy Russell-1/+1
2020-09-02pretty: trim paths of unique symbolsDan Aloni-17/+17
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-06-04test: ui: skip tests which aren't appropriate for RISC-VTom Eccles-11/+12
2020-05-22Update testsMatthew Jasper-322/+102
2020-04-22Tweak wordingEsteban Küber-1/+1
2020-04-22Tweak `'static` suggestion codeEsteban Küber-1/+5
Fix #71196.
2020-02-11On mismatched argument count point at argumentsEsteban Küber-6/+10
2020-01-12Get rid of RegionErrorNamingContextMark Mansi-2/+2
2019-12-12More c-variadic errors as semantic restrictions.Mazdak Farrokhzad-2/+2
2019-12-03Include a span in more `expected...found` notesAaron Hill-3/+7
In most places, we use a span when emitting `expected...found` errors. However, there were a couple of places where we didn't use any span, resulting in hard-to-interpret error messages. This commit attaches the relevant span to these notes, and additionally switches over to using `note_expected_found` instead of manually formatting the message
2019-11-25Auto merge of #66682 - estebank:fn-type-err, r=davidtwcobors-4/+4
Highlight parts of fn in type errors When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each. Examples: <img width="699" alt="" src="https://user-images.githubusercontent.com/1606434/69487597-ab561600-0e11-11ea-9b4e-d4fd9e91d5dc.png"> <img width="528" alt="" src="https://user-images.githubusercontent.com/1606434/69487207-9033d800-0e0a-11ea-93e3-8c4d002411a5.png"> <img width="468" alt="" src="https://user-images.githubusercontent.com/1606434/69487208-9033d800-0e0a-11ea-92e3-2b2cee120335.png"> <img width="775" alt="" src="https://user-images.githubusercontent.com/1606434/69487209-9033d800-0e0a-11ea-9e68-7f6ed5c8cb08.png">
2019-11-23Highlight parts of fn in type errorsEsteban Küber-4/+4
When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each.
2019-11-21Point at type in `let` assignment on type errorsEsteban Küber-2/+6
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-14/+14
2019-10-11Print lifetimes with backticksYuki Okushi-1/+1
2019-10-07update ui testsGuillaume Gomez-1/+2
2019-09-28rustc: rely on c_variadic == true instead of CVarArgs in HIR/Ty fn signatures.Eduard-Mihai Burtescu-154/+100
2019-09-28rustc: don't store a lifetime in hir::TyKind::CVarArgs.Eduard-Mihai Burtescu-8/+8
2019-09-12update testsMark Mansi-9/+9
2019-08-12syntax: account for CVarArgs being in the argument list.Eduard-Mihai Burtescu-0/+14
2019-07-14Make VaListImpl<'f> invariant over the 'f lifetimeAndrei Homescu-44/+116
2019-06-17Expose `VaListImpl` as the Rust equivalent of `__va_list_tag` and implement ↵Andrei Homescu-56/+97
Clone for it.
2019-05-12Remove feature(nll) when compare mode is sufficientMatthew Jasper-104/+0
2019-05-12Change compare mode to use -Zborrowck=mirMatthew Jasper-0/+81