Files
rust/tests/ui/parallel-rustc
Jonathan Brouwer 1ca55fb5e2 Rollup merge of #160428 - xyz-harshal:fix-dyn-compat-diagnostic-159492, r=khyperia
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.
2026-08-24 08:06:14 +02:00
..