summary refs log tree commit diff
path: root/tests/ui/methods
AgeCommit message (Collapse)AuthorLines
2024-04-04Make sure to insert Sized bound first into clauses listMichael Goulet-0/+30
(cherry picked from commit f2fd2d8c7080f7a7d770b3e3d27e525250c182dc)
2024-03-05Rollup merge of #121826 - estebank:e0277-root-obligation-2, r=oli-obkMatthias Krüger-10/+18
Use root obligation on E0277 for some cases When encountering trait bound errors that satisfy some heuristics that tell us that the relevant trait for the user comes from the root obligation and not the current obligation, we use the root predicate for the main message. This allows to talk about "X doesn't implement Pattern<'_>" over the most specific case that just happened to fail, like "char doesn't implement Fn(&mut char)" in `tests/ui/traits/suggest-dereferences/root-obligation.rs` The heuristics are: - the type of the leaf predicate is (roughly) the same as the type from the root predicate, as a proxy for "we care about the root" - the leaf trait and the root trait are different, so as to avoid talking about `&mut T: Trait` and instead remain talking about `T: Trait` instead - the root trait is not `Unsize`, as to avoid talking about it in `tests/ui/coercion/coerce-issue-49593-box-never.rs`. ``` error[E0277]: the trait bound `&char: Pattern<'_>` is not satisfied --> $DIR/root-obligation.rs:6:38 | LL | .filter(|c| "aeiou".contains(c)) | -------- ^ the trait `Fn<(char,)>` is not implemented for `&char`, which is required by `&char: Pattern<'_>` | | | required by a bound introduced by this call | = note: required for `&char` to implement `FnOnce<(char,)>` = note: required for `&char` to implement `Pattern<'_>` note: required by a bound in `core::str::<impl str>::contains` --> $SRC_DIR/core/src/str/mod.rs:LL:COL help: consider dereferencing here | LL | .filter(|c| "aeiou".contains(*c)) | + ``` Fix #79359, fix #119983, fix #118779, cc #118415 (the suggestion needs to change), cc #121398 (doesn't fix the underlying issue).
2024-03-03Move testsCaio-0/+32
2024-03-03Be more lax in `.into_iter()` suggestion when encountering `Iterator` ↵Esteban Küber-10/+18
methods on non-`Iterator` ``` error[E0599]: no method named `map` found for struct `Vec<bool>` in the current scope --> $DIR/vec-on-unimplemented.rs:3:23 | LL | vec![true, false].map(|v| !v).collect::<Vec<_>>(); | ^^^ `Vec<bool>` is not an iterator | help: call `.into_iter()` first | LL | vec![true, false].into_iter().map(|v| !v).collect::<Vec<_>>(); | ++++++++++++ ``` We used to provide some help through `rustc_on_unimplemented` on non-`impl Trait` and non-type-params, but this lets us get rid of some otherwise unnecessary conditions in the annotation on `Iterator`.
2024-02-22Deduplicate some logic and reword outputEsteban Küber-2/+2
2024-02-22Make confusable suggestions `verbose`Esteban Küber-2/+12
2024-02-18macro_rules: Preserve all metavariable spans in a global side tableVadim Petrochenkov-2/+2
2024-02-16[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives许杰友 Jieyou Xu (Joe)-62/+62
2024-02-08Continue to borrowck even if there were previous errorsOli Scherer-1/+1
2024-02-07Update testsr0cky-3/+36
2024-02-06Rollup merge of #120507 - estebank:issue-108428, r=davidtwcoMatthias Krüger-2/+3
Account for non-overlapping unmet trait bounds in suggestion When a method not found on a type parameter could have been provided by any of multiple traits, suggest each trait individually, instead of a single suggestion to restrict the type parameter with *all* of them. Before: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` help: consider restricting the type parameters to satisfy the trait bounds | LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord { | +++++++++++++++++++++++++ ``` After: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering { | +++++ LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ ``` Fix #108428. Follow up to #120396, only last commit is relevant.
2024-02-01review comment: change wordingEsteban Küber-1/+1
2024-02-01On E0277 be clearer about implicit `Sized` bounds on type params and assoc typesEsteban Küber-2/+2
``` error[E0277]: the size for values of type `[i32]` cannot be known at compilation time --> f100.rs:2:33 | 2 | let _ = std::mem::size_of::<[i32]>(); | ^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i32]` note: required by an implicit `Sized` bound in `std::mem::size_of` --> /home/gh-estebank/rust/library/core/src/mem/mod.rs:312:22 | 312 | pub const fn size_of<T>() -> usize { | ^ required by the implicit `Sized` requirement on this bound in `size_of` ``` Fix #120178.
2024-01-30Account for non-overlapping unmet trait bounds in suggestionEsteban Küber-2/+3
When a method not found on a type parameter could have been provided by any of multiple traits, suggest each trait individually, instead of a single suggestion to restrict the type parameter with *all* of them. Before: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` help: consider restricting the type parameters to satisfy the trait bounds | LL | fn g<T>(a: T, b: T) -> std::cmp::Ordering where T: Iterator, T: Ord { | +++++++++++++++++++++++++ ``` After: ``` error[E0599]: the method `cmp` exists for reference `&T`, but its trait bounds were not satisfied --> $DIR/method-on-unbounded-type-param.rs:5:10 | LL | (&a).cmp(&b) | ^^^ method cannot be called on `&T` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `T: Ord` which is required by `&T: Ord` `&T: Iterator` which is required by `&mut &T: Iterator` `T: Iterator` which is required by `&mut T: Iterator` = help: items from traits can only be used if the type parameter is bounded by the trait help: the following traits define an item `cmp`, perhaps you need to restrict type parameter `T` with one of them: | LL | fn g<T: Ord>(a: T, b: T) -> std::cmp::Ordering { | +++++ LL | fn g<T: Iterator>(a: T, b: T) -> std::cmp::Ordering { | ++++++++++ ``` Fix #108428.
2024-01-30Rollup merge of #120400 - estebank:bound-error-cleanup, r=oli-obkGuillaume Gomez-4/+1
Bound errors span label cleanup Consolidate span labels for "this type doesn't satisfy a bound" for more compact diagnostic output.
2024-01-26Use single label for method not found due to unmet boundEsteban Küber-4/+1
2024-01-24On E0308 involving `dyn Trait`, mention trait objectsEsteban Küber-0/+1
When encountering a type mismatch error involving `dyn Trait`, mention the existence of boxed trait objects if the other type involved implements `Trait`. Partially addresses #102629.
2024-01-05macro_rules: Add more tests for using `tt` in addition to `ident`Vadim Petrochenkov-6/+24
Generally, `tt` and `ident` should behave identically, modulo the latter accepting only a subset of token trees.
2024-01-02Adjust compiler tests for unused_tuple_struct_fields -> dead_codeJake Goulding-3/+3
2023-12-27fix broken CI and code reviewYoung-Flash-6/+53
2023-12-16test: add test case for `disambiguate the associated function` diagnosticYoung-Flash-0/+69
2023-11-24Show number in error message even for one errorNilstrieb-15/+15
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-12Don't expect a rcvr in print_disambiguation_helpMichael Goulet-0/+46
2023-11-07Rework print_disambiguation_helpMichael Goulet-36/+36
2023-10-17Unify suggestion wordingEsteban Küber-74/+45
2023-10-17review comments + more testsEsteban Küber-12/+412
2023-10-17Properly account for self ty in method disambiguation suggestionEsteban Küber-0/+109
Fix #116703.
2023-10-04Reorder fullfillment errors to keep more interesting ones firstEsteban Küber-1/+1
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed` and coercion errors to the end of the list. The pre-existing deduplication logic eliminates redundant errors better that way, keeping the resulting output with fewer errors than before, while also having more detail.
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-1/+1
2023-08-28Move testsCaio-0/+37
2023-08-26More accurately point at argumentsEsteban Küber-2/+2
2023-07-27Adjust spans correctly for fn -> method suggestionMichael Goulet-0/+21
2023-07-25write-long-types-to-disk: update testsMahdi Dibaiee-7/+5
2023-07-24new unstable option: -Zwrite-long-types-to-diskMahdi Dibaiee-4/+5
This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-2/+2
2023-05-26improve error message for calling a method on a raw pointer with an unknown ↵asquared31415-0/+55
pointee, and add some tests
2023-05-08Tweak borrow suggestionMichael Goulet-4/+6
2023-04-26Make method-not-found-generic-arg-elision.rs error message not path dependentMichael Goulet-5/+5
2023-04-10Do not use ImplDerivedObligationCause for inherent impl method error reportingMichael Goulet-0/+87
2023-03-07Error code E0794 for late-bound lifetime parameter error.Christopher Acosta-17/+19
2023-03-01Highlight whole expression for E0599clubby789-7/+10
2023-02-26Rollup merge of #108456 - clubby789:ast-passes-diag-migrate, r=compiler-errorsMatthias Krüger-1/+1
Complete migrating `ast_passes` to derive diagnostics cc #100717 ```@rustbot``` label +A-translation
2023-02-25Complete migrating `ast_passes` to derive diagnosticsclubby789-1/+1
2023-02-23diagnostics: remove inconsistent English article "this" from E0107Michael Howell-8/+8
Consider `tests/ui/const-generics/generic_const_exprs/issue-102768.stderr`, the error message where it gives additional notes about where the associated type is defined, and how the dead code lint doesn't have an article, like in `tests/ui/lint/dead-code/issue-85255.stderr`. They don't have articles, so it seems unnecessary to have one here.
2023-02-22diagnostics: update test cases to refer to assoc fn with `self` as methodMichael Howell-30/+30
2023-02-16Rollup merge of #106347 - estebank:removal-suggestion, r=TaKO8KiMatthias Krüger-5/+4
More accurate spans for arg removal suggestion Partially address #106304.
2023-02-16Remove save-analysis.Nicholas Nethercote-4/+3
Most tests involving save-analysis were removed, but I kept a few where the `-Zsave-analysis` was an add-on to the main thing being tested, rather than the main thing being tested. For `x.py install`, the `rust-analysis` target has been removed. For `x.py dist`, the `rust-analysis` target has been kept in a degenerate form: it just produces a single file `reduced.json` indicating that save-analysis has been removed. This is necessary for rustup to keep working. Closes #43606.
2023-02-14Make removal suggestion not verboseEsteban Küber-6/+4
2023-02-14rebase and review commentsEsteban Küber-1/+1
2023-02-14More accurate spans for arg removal suggestionEsteban Küber-2/+3