about summary refs log tree commit diff
path: root/tests/ui/methods
AgeCommit message (Collapse)AuthorLines
2025-08-19bless tests with new lint messagesKarol Zwolak-5/+5
2025-08-17Rehome tests/ui/issues/ tests [5/?]Oneirical-0/+28
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-15/+21
`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
2025-08-07Rollup merge of #137831 - estebank:auto-trait-err, r=compiler-errorsStuart Cook-1/+1
Tweak auto trait errors Make suggestions to remove params and super traits verbose and make spans more accurate. ``` error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds ``` ``` error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | fn method(&self) { | ^^^^^^ ```
2025-08-04Rehome tests/ui/issues/ tests [3/?]Oneirical-0/+30
2025-08-04Tweak auto trait errorsEsteban Küber-1/+1
Make suggestions to remove params and super traits tool-only, and make the suggestion span more accurate. ``` error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds ``` ``` error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | fn method(&self) { | ^^^^^^ ```
2025-07-24Rehome tests/ui/issues/ tests [1/?]Oneirical-0/+28
2025-07-17fix: fix issue 143740, Wrong messages from compiler confusing methods with ↵codedump-13/+67
the same name from different traits
2025-06-30Use predicate spans instead of whole item spansOli Scherer-29/+16
2025-06-29Rollup merge of #142417 - Kivooeo:tf12, r=jieyouxuGuillaume Gomez-55/+69
`tests/ui`: A New Order [12/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895. r? `@jieyouxu`
2025-06-28cleaned up some testsKivooeo-55/+69
2025-06-24Make missing lifetime suggestion verboseMichael Goulet-5/+11
2025-06-22Implement DesugaringKind::FormatLiteralmejrs-4/+2
2025-06-14Rollup merge of #141811 - mejrs:bye_locals, r=compiler-errorsMatthias Krüger-21/+11
Unimplement unsized_locals Implements https://github.com/rust-lang/compiler-team/issues/630 Tracking issue here: https://github.com/rust-lang/rust/issues/111942 Note that this just removes the feature, not the implementation, and does not touch `unsized_fn_params`. This is because it is required to support `Box<dyn FnOnce()>: FnOnce()`. There may be more that should be removed (possibly in follow up prs) - the `forget_unsized` function and `forget` intrinsic. - the `unsized_locals` test directory; I've just fixed up the tests for now - various codegen support for unsized values and allocas cc ``@JakobDegen`` ``@oli-obk`` ``@Noratrieb`` ``@programmerjake`` ``@bjorn3`` ``@rustbot`` label F-unsized_locals Fixes rust-lang/rust#79409
2025-06-13Unimplement unsized_localsmejrs-21/+11
2025-06-12Rollup merge of #142034 - estebank:issue-141258, r=davidtwcoMatthias Krüger-0/+97
Detect method not being present that is present in other tuple types When a method is not present because of a trait bound not being met, and that trait bound is on a tuple, we check if making the tuple have no borrowed types makes the method to be found and highlight it if it does. This is a common problem for Bevy in particular and ORMs in general. <img width="1166" alt="Screenshot 2025-06-04 at 10 38 24 AM" src="https://github.com/user-attachments/assets/d257c9ea-c2d7-42e7-8473-8b93aa54b8e0" /> Address rust-lang/rust#141258. I believe that more combination of cases in the tuple types should be handled (like adding borrows and checking when a specific type needs to not be a borrow while the rest stay the same), but for now this handles the most common case.
2025-06-11cleaned up some testsKivooeo-0/+28
2025-06-04Detect method not being present that is present in other tuple typesEsteban Küber-0/+97
When a method is not present because of a trait bound not being met, and that trait bound is on a tuple, we check if making the tuple have no borrowed types makes the method to be found and highlight it if it does. This is a common problem for Bevy in particular and ORMs in general.
2025-05-31cleaned up some testsKivooeo-0/+83
2025-05-24Avoid extra path trimming in method not found errorNoratrieb-3/+23
Method errors have an extra check that force trim paths whenever the normal string is longer than 10 characters, which can be quite unhelpful when multiple items have the same name (for example an `Error`). A user reported this force trimming as being quite unhelpful when they had a method error where the precise path of the `Error` mattered. The code uses `tcx.short_string` already to get the normal path, which tries to be clever around trimming paths if necessary, so there is no reason for this extra force trimming.
2025-05-05Do not gather local all together at the beginning of typeckMichael Goulet-77/+77
2025-04-30Auto merge of #140503 - matthiaskrgr:rollup-n7zigts, r=matthiaskrgrbors-15/+43
Rollup of 11 pull requests Successful merges: - #136160 (Remove backticks from `ShouldPanic::YesWithMessage`'s `TrFailedMsg`) - #139059 (uses_power_alignment: wording tweaks) - #139192 (mention provenance in the pointer::wrapping_offset docs) - #140312 (Improve pretty-printing of braces) - #140404 (rm `TypeVistable` impls for `Canonical`) - #140437 (enable msa feature for mips in codegen tests) - #140438 (Add `rust.debug-assertions-tools` option) - #140439 (miri: algebraic intrinsics: bring back float non-determinism) - #140445 (Treat ManuallyDrop as ~const Destruct) - #140446 (chore: fix some tests) - #140448 (Rename `rustc_query_append!` to `rustc_with_all_queries!`) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-23/+27
2025-04-29Coalesce duplicate missing clone testsmejrs-15/+43
2025-04-25Cleaned up 5 tests in `tests/ui`reddevilmidzy-0/+35
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-3/+3
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-0/+2
2025-03-06Rollup merge of #137565 - compiler-errors:macro-ex, r=estebankMichael Goulet-0/+39
Try to point of macro expansion from resolver and method errors if it involves macro var In the case that a macro caller passes an identifier into a macro generating a path or method expression, point out that identifier in the context of the *macro* so it's a bit more clear how the macro is involved in causing the error. r? ``````````@estebank`````````` or reassign
2025-03-03Point of macro expansion from call expr if it involves macro varMichael Goulet-0/+39
2025-03-04tests: remove explicit long type filename hash normalization from some ui tests许杰友 Jieyou Xu (Joe)-6/+4
2025-02-21More sophisticated span trimmingMichael Goulet-9/+6
2025-02-14Trim suggestion parts to the subset that is purely additiveMichael Goulet-2/+2
2025-02-14Use underline suggestions for purely 'additive' replacementsMichael Goulet-6/+4
2025-02-14fallout :skull_emoji:lcnr-5/+8
2025-02-13Implement lint for definition site item shadowing tooMichael Goulet-19/+172
2025-02-13Add more testsMichael Goulet-0/+172
2025-02-13Rework collapse method to work correctly with more complex supertrait graphsMichael Goulet-0/+219
2025-02-13Implement shadowing lintMichael Goulet-0/+100
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-120/+180
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
2025-02-05When displaying a parameter mismatch error, only highlight the mismatched ↵Jason Newcomb-1/+1
parameters when showing the definition.
2025-02-03Check for generic parameter mismatches on trait functions.Jason Newcomb-1/+1
2025-01-03Do not ICE when encountering predicates from other items in method error ↵Michael Goulet-0/+72
reporting
2024-12-27Remove the `-test` suffix from normalize directivesZalathar-1/+1
2024-12-11Arbitrary self types v2: use Receiver traitAdrian Taylor-0/+101
In this new version of Arbitrary Self Types, we no longer use the Deref trait exclusively when working out which self types are valid. Instead, we follow a chain of Receiver traits. This enables methods to be called on smart pointer types which fundamentally cannot support Deref (for instance because they are wrappers for pointers that don't follow Rust's aliasing rules). This includes: * Changes to tests appropriately * New tests for: * The basics of the feature * Ensuring lifetime elision works properly * Generic Receivers * A copy of the method subst test enhanced with Receiver This is really the heart of the 'arbitrary self types v2' feature, and is the most critical commit in the current PR. Subsequent commits are focused on: * Detecting "shadowing" problems, where a smart pointer type can hide methods in the pointee. * Diagnostics and cleanup. Naming: in this commit, the "Autoderef" type is modified so that it no longer solely focuses on the "Deref" trait, but can now consider the "Receiver" trait instead. Should it be renamed, to something like "TraitFollower"? This was considered, but rejected, because * even in the Receiver case, it still considers built-in derefs * the name Autoderef is short and snappy.
2024-12-07Mention type parameter in more cases and don't suggest ~const bound already ↵Esteban Küber-4/+4
there
2024-12-07Use trait name instead of full constraint in suggestion messageEsteban Küber-4/+4
``` help: consider restricting type parameter `T` with traits `Copy` and `Trait` | LL | fn duplicate_custom<T: Copy + Trait>(t: S<T>) -> (S<T>, S<T>) { | ++++++++++++++ ``` ``` help: consider restricting type parameter `V` with trait `Copy` | LL | fn index<'a, K, V: std::marker::Copy>(map: &'a HashMap<K, V>, k: K) -> &'a V { | +++++++++++++++++++ ```
2024-12-07reword trait bound suggestion message to include the boundsEsteban Küber-4/+4
2024-11-26tests: remove `//@ pretty-expanded` usages许杰友 Jieyou Xu (Joe)-6/+2
Done with ```bash sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs ``` and ``` sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs ```
2024-09-29Don't give method suggestions when method probe fails due to bad impl of DerefMichael Goulet-0/+25
2024-09-20Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errorsbors-0/+6
Disallow hidden references to mutable static Closes #123060 Tracking: - https://github.com/rust-lang/rust/issues/123758