about summary refs log tree commit diff
path: root/src/test/ui/range
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-1254/+0
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-3/+0
available
2022-12-10Introduce `with_forced_trimmed_paths`Esteban Küber-5/+5
2022-11-13Ensure codegen_fn_attrs during collection.Camille GILLOT-16/+28
2022-10-01bless ui testsMaybe Waffle-4/+4
2022-08-21Point at struct field if possibleMichael Goulet-1/+1
2022-08-18Reword "Required because of the requirements on the impl of ..."Andy Wang-2/+2
2022-04-16Implementation for 65853Jack Huey-104/+260
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-04Mention implementers of unsatisfied traitEsteban Kuber-0/+10
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-12-29Fix whitespace in pretty printed PatKind::RangeDavid Tolnay-3/+3
2021-11-20Do not mention associated items when they introduce an obligationEsteban Kuber-65/+0
2021-08-16Use note to point at bound introducing requirementEsteban Küber-4/+4
2021-08-09Link to edition guide instead of issues for 2021 lints.Mara Bos-2/+2
2021-08-04Remove trailing whitespace from error messagesFabian Wolff-1/+1
2021-07-19Various diagnostics clean ups/tweaksEsteban Küber-13/+101
* 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-06-25Address PR feedbackRyan Levick-5/+5
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-5/+5
2021-05-12Show macro name in 'this error originates in macro' messageAaron Hill-15/+15
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
2021-04-16Fix testsRyan Levick-4/+11
2021-04-08Update BARE_TRAIT_OBJECT and ELLIPSIS_INCLUSIVE_RANGE_PATTERNS to errors in ↵Ryan Levick-0/+41
Rust 2021
2021-02-09./x.py test --blessTomasz Miąsko-275/+11
2021-01-13Update code to account for extern ABI requirementMark Rousskov-1/+1
2020-10-06Fix tests from rebaseMatthew Jasper-1/+3
2020-10-06Separate bounds and predicates for associated/opaque typesMatthew Jasper-1/+1
2020-09-02pretty: trim paths of unique symbolsDan Aloni-90/+90
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-08-27Abort when catch_unwind catches a foreign exceptionAmanieu d'Antras-6/+9
2020-08-16hir: simplify `is_range_literal`David Wood-1/+5
This commit simplifies `is_range_literal` by checking for `QPath::LangItem` containing range-related lang items, rather than using a heuristic. Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-07-14Remove `Sized` `on_unimplemented` noteEsteban Küber-1/+0
2020-07-02Audit uses of `span_suggestion_short`Yuki Okushi-32/+65
2020-06-22Change heuristic for determining range literalAyaz Hafiz-0/+43
Currently, rustc uses a heuristic to determine if a range expression is not a literal based on whether the expression looks like a function call or struct initialization. This fails for range literals whose lower/upper bounds are the results of function calls. A possibly-better heuristic is to check if the expression contains `..`, required in range literals. Of course, this is also not perfect; for example, if the range expression is a struct which includes some text with `..` this will fail, but in general I believe it is a better heuristic. A better alternative altogether is to add the `QPath::LangItem` enum variant suggested in #60607. I would be happy to do this as a precursor to this patch if someone is able to provide general suggestions on how usages of `QPath` need to be changed later in the compiler with the `LangItem` variant. Closes #73553
2020-04-11rustc: Add a warning count upon completionRoccoDev-1/+1
2020-03-05Remove eh_unwind_resume lang itemAmanieu d'Antras-10/+6
2020-02-06rustc_macros: don't limit the -Zmacro-backtrace suggestion to extern macros.Eduard-Mihai Burtescu-0/+42
2020-01-24Normalise notes with the/isvarkor-1/+1
2020-01-09Update testsVadim Petrochenkov-11/+251
2019-11-18Surround types with backticks in type errorsEsteban Küber-1/+1
2019-11-18Specific labels when referring to "expected" and "found" typesEsteban Küber-48/+48
2019-07-03Migrate compile-pass annotations to build-passYuki Okushi-3/+3
2019-04-22Remove double trailing newlinesvarkor-6/+0
2019-04-18hide `--explain` hint if error has no extended infoAndy Russell-1/+1
2019-03-11Update testsVadim Petrochenkov-3/+3
2019-01-01Fix broken links to second edition TRPL.Corey Farwell-1/+1
Fixes https://github.com/rust-lang/rust/issues/57104.
2018-12-25Remove licensesMark Rousskov-113/+23
2018-11-15Rollup merge of #55852 - varkor:dotdotequals-lint, r=zackmdavisPietro Albini-2/+2
Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint Fixes https://github.com/rust-lang/rust/issues/51043.
2018-11-10Use non-short suggestion for parenthesised ..=varkor-1/+1
2018-11-10Rewrite `...` as `..=` as a MachineApplicable 2018 idiom lintvarkor-2/+2
2018-11-10Auto merge of #55626 - nikic:update-emscripten, r=alexcrichtonbors-1/+1
Update emscripten This updates emscripten to 1.38.15, which is based on LLVM 6.0.1 and would allow us to drop code for handling LLVM 4. The main issue I ran into is that exporting statics through `EXPORTED_FUNCTIONS` no longer works. As far as I understand exporting non-functions doesn't really make sense under emscripten anyway, so I've modified the symbol export code to not even try. Closes #52323.
2018-11-08Fix some tests for wasm32-unknown-emscriptenNikita Popov-1/+1
2018-11-07Removed `#[rustc_error]` from tests that are all `// compile-pass`.Felix S. Klock II-33/+9
I also added `// skip-codegen` to each one, to address potential concerns that this change would otherwise slow down our test suite spending time generating code for files that are really just meant to be checks of compiler diagnostics. (However, I will say: My preference is to not use `// skip-codegen` if one can avoid it. We can use all the testing of how we drive LLVM that we can get...) (Updated post rebase.)
2018-10-09Fix test for windows osPaweł Romanowski-6/+10