about summary refs log tree commit diff
path: root/tests/ui/self
AgeCommit message (Collapse)AuthorLines
2025-08-23Use unnamed lifetime spans as primary spans for MISMATCHED_LIFETIME_SYNTAXESMichael Goulet-12/+12
2025-08-19bless tests with new lint messagesKarol Zwolak-1/+1
2025-08-07Use `tcx.short_string()` in more diagnosticsEsteban Küber-5/+5
`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-07-25Update ui tests with new macro early erroringGuillaume Gomez-15/+21
2025-07-14Reword mismatched-lifetime-syntaxes text based on feedbackJake Goulding-30/+36
Key changes include: - Removal of the word "syntax" from the lint message. More accurately, it could have been something like "syntax group" or "syntax category", but avoiding it completely is easier. - The primary lint message now reflects exactly which mismatch is occurring, instead of trying to be general. A new `help` line is general across the mismatch kinds. - Suggestions have been reduced to be more minimal, no longer also changing non-idiomatic but unrelated aspects. - Suggestion text no longer mentions changes when those changes don't occur in that specific suggestion.
2025-07-10Rework borrowing suggestions to use `Expr` instead of just `Span`Esteban Küber-8/+8
In the suggestion machinery for borrowing expressions and types, always use the available obligation `Span` to find the appropriate `Expr` to perform appropriateness checks no the `ExprKind` instead of on the textual snippet corresponding to the `Span`. Unify the logic for the case where `&` *and* `&mut` are appropriate with the logic for only one of those cases. Handle the case when `S::foo()` should have been `<&S>::foo()` (instead of suggesting the prior `&S::foo()`.
2025-06-30Replace `ItemCtxt::report_placeholder_type_error` `match` with a call to ↵Guillaume Gomez-4/+4
`TyCtxt::def_descr`
2025-06-27Report infer ty errors during hir ty loweringOli Scherer-12/+0
This centralizes the placeholder type error reporting in one location, but it also exposes the granularity at which we convert things from hir to ty more. E.g. previously infer types in where bounds were errored together with the function signature, but now they are independent.
2025-06-13Unimplement unsized_localsmejrs-4/+0
2025-06-12Rollup merge of #142066 - ferrocene:lw/edition-2015-tests, r=compiler-errorsMatthias Krüger-1/+1
More simple 2015 edition test decoupling This should be the last of these PRs for now. The remaining tests that do not work on other editions than 2015 either need the range support (so blocked on the MCP), need normalization rules (which needs discussions first/same MCP) or revisions. r? compiler-errors
2025-06-05Use non-2015 edition paths in tests that do not test for their resolutionLukas Wirth-1/+1
2025-06-04Replace `elided_named_lifetimes` with `mismatched_lifetime_syntaxes`Jake Goulding-33/+68
2025-05-27Use more detailed spans in dyn compat errors within bodiesOli Scherer-2/+2
2025-05-26Deduplicate dyn compatibility violations due to coercionMichael Goulet-22/+1
2025-05-23Do not try to confirm non-dyn compatible methodMichael Goulet-0/+67
2025-05-06Preserve generic args in suggestions for ambiguous associated itemsLeón Orell Valerian Liehr-2/+14
Most notably, this preserves the `(..)` of ambiguous RTN paths.
2025-04-08UI tests: add missing diagnostic kinds where possibleVadim Petrochenkov-8/+8
2025-03-30Do not mix normalized and unnormalized caller bounds when constructing ↵Michael Goulet-0/+26
param-env for receiver_is_dispatchable
2025-03-12Rollup merge of #138174 - compiler-errors:elaborate-unsize-self-pred, r=BoxyUwUMatthias Krüger-0/+76
Elaborate trait assumption in `receiver_is_dispatchable` Fixes #138172. See comment on the linked test. Probably not a fix for the general problem, bc I think this may still be incomplete for other weird `where` clauses on the receiver. But 🤷, supertraits seems like an obvious one to fix.
2025-03-11Elaborate param-env built for checking DispatchFromDyn for dyn compatMichael Goulet-0/+76
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-5/+6
2025-02-24Rollup merge of #137289 - compiler-errors:coerce-unsized-errors, r=oli-obkMichael Goulet-10/+20
Consolidate and improve error messaging for `CoerceUnsized` and `DispatchFromDyn` Firstly, this PR consolidates and reworks the error diagnostics for `CoercePointee` and `DispatchFromDyn`. There was a ton of duplication for no reason -- this reworks both the errors and also the error codes, since they can be shared between both traits since they report the same thing. Secondly, when encountering a struct with multiple fields that must be coerced, point out the field spans, rather than mentioning the fields by name. This makes the error message clearer, but also means that we don't mention the `__S` dummy parameter for `derive(CoercePointee)`. Thirdly, emit a custom error message when we encounter a trait error that comes from the recursive field `CoerceUnsized`/`DispatchFromDyn` trait check. **Note:** This is the only one I'm not too satisfied with -- I think it could use some more refinement, but ideally it explains that the field must be an unsize-able pointer... Feedback welcome. Finally, don't emit `DispatchFromDyn` validity errors if we detect `CoerceUnsized` validity errors from an impl of the same ADT. This is best reviewed per commit. r? `@oli-obk` perhaps? cc `@dingxiangfei2009` -- sorry for making my own attempt at this PR, but I wanted to see if I could implement a fix for #136796 in a less complicated way, since communicating over github review comments can be a bit slow. I'll leave comments inline to explain my thinking about the diagnostics changes.
2025-02-24Consolidate and rework CoercePointee and DispatchFromDyn errorsMichael Goulet-10/+20
2025-02-24Remove dyn_compatible_for_dispatchMichael Goulet-30/+44
2025-02-21More sophisticated span trimmingMichael Goulet-3/+2
2025-02-11Auto merge of #136845 - matthiaskrgr:rollup-ol4np4z, r=matthiaskrgrbors-0/+32
Rollup of 7 pull requests Successful merges: - #136107 (Introduce CoercePointeeWellformed for coherence checks at typeck stage) - #136155 (Enable sanitizers on MSVC CI jobs) - #136524 (Delay bug when method confirmation cannot upcast object pick of self) - #136584 (Prevent generic pattern types from being used in libstd) - #136603 (compiler: gate `extern "{abi}"` in ast_lowering) - #136821 (assign marcoieni and jdno to infra-ci PRs) - #136825 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-11Rollup merge of #136524 - compiler-errors:bad-pick, r=BoxyUwUMatthias Krüger-0/+32
Delay bug when method confirmation cannot upcast object pick of self Justification is on the test comment. Simply delays a bug that we were previously ICEing on. cc ``@adetaylor`` since this is a `arbitrary_self_types` ICE.
2025-02-10Show diff suggestion format on verbose replacementEsteban Küber-12/+18
``` 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-07Rollup merge of #135179 - compiler-errors:arbitrary-self-types-object, r=BoxyUwUMatthias Krüger-0/+33
Make sure to use `Receiver` trait when extracting object method candidate In method confirmation, the `extract_existential_trait_ref` function re-extracts the object type by derefing until it reaches an object. If we're assembling methods via the `Receiver` trait, make sure we re-do our work also using the receiver trait. Fixes #135155 cc ``@adetaylor``
2025-02-05Rollup merge of #136567 - adetaylor:test-for-recursion, r=oli-obk许杰友 Jieyou Xu (Joe)-0/+71
Arbitrary self types v2: recursion test Add a test for infinite recursion of an arbitrary self type. These diagnostics aren't perfect (especially the repetition of the statement that there's too much recursion) but for now at least let's add a test to confirm that such diagnostics are emitted. As suggested by ```@oli-obk``` Relates to #44874 r? ```@wesleywiser```
2025-02-05Arbitrary self types v2: recursion testAdrian Taylor-0/+71
Add a test for infinite recursion of an arbitrary self type. These diagnostics aren't perfect (especially the repetition of the statement that there's too much recursion) but for now at least let's add a test to confirm that such diagnostics are emitted.
2025-02-04Delay bug when method confirmation cannot upcast object pick of selfMichael Goulet-0/+32
2025-02-04Remove unnecessary layout assertions for object-safe receiversMichael Goulet-0/+50
2025-01-31Rollup merge of #135860 - fmease:compiler-mv-obj-save-dyn-compat-ii, r=jieyouxuMatthias Krüger-3/+3
Compiler: Finalize dyn compatibility renaming Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME. Follow-up to #130826. Part of #130852. ~~Blocking it on #133372.~~ (merged) r? ghost
2025-01-27Arbitrary self types v2: explain test.Adrian Taylor-1/+23
The purpose of this test wasn't obvious. Add a comment.
2025-01-26Compiler: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-3/+3
2025-01-24Rollup merge of #135749 - compiler-errors:param-ordering, r=davidtwcoMatthias Krüger-3/+3
Do not assume const params are printed after type params Fixes #135737
2025-01-24Do not assume const params are printed after type paramsMichael Goulet-3/+3
2025-01-22Refactor dyn-compatibility error and suggestionsTaylor Cramer-15/+18
This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
2025-01-14Rollup merge of #135425 - compiler-errors:not-conditionally-const, r=RalfJungJubilee-7/+4
Do not consider traits that have unsatisfied const conditions to be conditionally const This will improve error messages as we continue to constify traits, since we don't want to start calling things "conditionally const" if they aren't implemented with a const impl anyways. The only case that this affects today is `Deref` since that's one of the only constified traits in the standard library :) r? RalfJung
2025-01-14Rollup merge of #135228 - compiler-errors:normalizes-ur-dispatch, r=BoxyUwUJubilee-0/+116
Improve `DispatchFromDyn` and `CoerceUnsized` impl validation * Disallow arbitrary 1-ZST fields in `DispatchFromDyn` -- only `PhantomData`, and 1-ZSTs that mention no params (which is needed to support, e.g., the `Global` alloctor in `Box<T, U = Global>`). * Don't allow coercing between non-ZSTs to ZSTs (since the previous check wasn't actually checking the field tys were the same before checking the layout...) * Normalize the field before checking it's `PhantomData`. Fixes #135215 Fixes #135214 Fixes #135220 r? ```@BoxyUwU``` or reassign
2025-01-14Do not consider traits that have unsatisfied const conditions to be ↵Michael Goulet-7/+4
conditionally const
2025-01-14Normalize field before checking PhantomData in coerce/dispatch impl validationMichael Goulet-0/+25
2025-01-13Assert that Instance::try_resolve is only used on body-like thingsMichael Goulet-2/+3
2025-01-09Unify conditional and non const call error reportingMichael Goulet-1/+1
2025-01-09Add note back to conditionally-const error messageMichael Goulet-0/+1
2025-01-08Don't allow DispatchFromDyn impls that transmute ZST to non-ZSTMichael Goulet-0/+41
2025-01-08Don't allow transmuting ZSTs in dispatch_from_dyn implMichael Goulet-0/+50
2025-01-07Make sure to use Receiver trait when extracting object method candidateMichael Goulet-0/+33
2024-12-21Rollup merge of #134524 - adetaylor:getref, r=compiler-errorsMatthias Krüger-0/+41
Arbitrary self types v2: no deshadow pre feature. The arbitrary self types v2 work introduces a check for shadowed methods, whereby a method in some "outer" smart pointer type may called in preference to a method in the inner referent. This is bad if the outer pointer adds a method later, as it may change behavior, so we ensure we error in this circumstance. It was intended that this new shadowing detection system only comes into play for users who enable the `arbitrary_self_types` feature (or of course everyone later if it's stabilized). It was believed that the new deshadowing code couldn't be reached without building the custom smart pointers that `arbitrary_self_types` enables, and therefore there was no risk of this code impacting existing users. However, it turns out that cunning use of `Pin::get_ref` can cause this type of shadowing error to be emitted now. This commit adds a test for this case. As we want this test to pass without arbitrary_self_types, but fail with it, I've split it into two files (one with run-pass and one without). If there's a better way I can amend it. Part of #44874 r? ```@wesleywiser```