mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 01:40:02 +00:00
Add more context to dyn-compatibility diagnostic for receiver-less associated functions Fixes rust-lang/rust#159492 Expands the two suggestion messages for the "no `self` parameter" dyn-compatibility violation to explain *why* each fix works, per the issue. Before: help: consider turning `create` into a method by giving it a `&self` argument help: alternatively, consider constraining `create` so it does not apply to trait objects After: help: consider turning `create` into a method by giving it a `&self` argument, so that it is accessible through the trait object's vtable help: alternatively, consider constraining `create` so it is explicitly marked as not applying to trait objects Only the two strings in `DynCompatibilityViolationSolution::add_to` (rustc_middle/src/traits/mod.rs) changed — no logic, applicability, or span changes. Added a regression test using the issue's exact example (tests/ui/dyn-compatibility/static-constructor-prevents-dyn-no-api-guidance.rs). Verified against a locally-built rustc; full `tests/ui` suite passes (21643 passed, 0 failed). Note: `next-solver` compare-mode has pre-existing, unrelated failures on 3 tests in this directory, confirmed present on `main` without this diff.