Commit Graph

37 Commits

Author SHA1 Message Date
Michael Goulet ea9a253ff1 Properly report error when object type param default references self 2025-01-24 04:07:10 +00:00
Taylor Cramer d00d4dfe0d Refactor dyn-compatibility error and suggestions
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-22 09:20:57 -08:00
Michael Goulet 824a867e82 Rework trait expansion to happen once explicitly 2025-01-15 01:26:24 +00:00
Michael Goulet 0465f71d60 Stop being so bail-y in candidate assembly 2024-11-21 01:35:34 +00:00
Ruihan Li 781bff0499 Never emit vptr for empty/auto traits 2024-10-18 12:34:56 +08:00
Matthias Krüger fa3dff3e24 Rollup merge of #131475 - fmease:compiler-mv-obj-safe-dyn-compat-2, r=jieyouxu
Compiler & its UI tests: Rename remaining occurrences of "object safe" to "dyn compatible"

Follow-up to #130826.
Part of #130852.

1. 1st commit: Fix stupid oversights. Should've been part of #130826.
2. 2nd commit: Rename the unstable feature `object_safe_for_dispatch` to `dyn_compatible_for_dispatch`. Might not be worth the churn, you decide.
3. 3rd commit: Apply the renaming to all UI tests (contents and paths).
2024-10-10 22:00:50 +02:00
León Orell Valerian Liehr 20cebae312 UI tests: Rename "object safe" to "dyn compatible" 2024-10-10 01:13:29 +02:00
Michael Goulet fd7ee484f9 Elaborate supertrait span correctly to label the error better 2024-10-04 17:15:28 -04:00
Michael Goulet ae5f58d906 Check elaborated projections from dyn don't mention unconstrained late bound lifetimes 2024-10-04 17:15:28 -04:00
León Orell Valerian Liehr 01a063f9df Compiler: Rename "object safe" to "dyn compatible" 2024-09-25 13:26:48 +02:00
León Orell Valerian Liehr 080c2ca2dc Pretty-print own args of existential projections 2024-08-22 06:22:36 +02:00
Michael Goulet ac56007ea7 Revert "Rollup merge of #125572 - mu001999-contrib:dead/enhance, r=pnkfelix"
This reverts commit 13314df21b, reversing
changes made to 6e534c73c3.
2024-08-03 07:57:31 -04:00
Esteban Küber 921de9d8ea Revert suggestion verbosity change 2024-07-22 22:51:53 +00:00
Esteban Küber b30fdec5fb On generic and lifetime removal suggestion, do not leave behind stray , 2024-07-22 22:04:49 +00:00
Esteban Küber 5c2b36a21c Change suggestion message wording 2024-07-22 22:04:49 +00:00
Esteban Küber c807ac0340 Use verbose suggestion for "wrong # of generics" 2024-07-22 22:04:49 +00:00
r0cky 35130d7233 Detect pub structs never constructed and unused associated constants in traits 2024-06-05 23:20:09 +08:00
Kalle Wachsmuth 188c46a65e regression test for #103626 2024-03-23 17:48:57 +01:00
许杰友 Jieyou Xu (Joe) ec2cc761bc [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Lukas Markeffsky c636c7ae2c address review comments and add more tests 2024-02-07 20:58:05 +01:00
Lukas Markeffsky 18e5bbfad6 improve pretty printing for trait objects 2024-02-07 16:09:46 +01:00
Lukas Markeffsky fd9202109b add test for pretty printing trait objects 2024-02-07 12:51:31 +01:00
Oli Scherer 0978f6e010 Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
Jake Goulding 53eca9fa87 Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
bjorn3 ba82056a14 Use the actual computed crate name for -Zprint-vtable-sizes 2023-11-05 16:29:15 +00:00
bors a395214a3a Auto merge of #116405 - estebank:issue-103155, r=davidtwco
Detect object safety errors when assoc type is missing

When an associated type with GATs isn't specified in a `dyn Trait`, emit an object safety error instead of only complaining about the missing associated type, as it will lead the user down a path of three different errors before letting them know that what they were trying to do is impossible to begin with.

Fix #103155.
2023-10-30 22:47:48 +00:00
Esteban Küber 8c5577283c Add test 2023-10-30 22:12:07 +00:00
Esteban Küber 17a6ae2df3 Detect object safety errors when assoc type is missing
When an associated type with GATs isn't specified in a `dyn Trait`, emit
an object safety error instead of only complaining about the missing
associated type, as it will lead the user down a path of three different
errors before letting them know that what they were trying to do is
impossible to begin with.

Fix #103155.
2023-10-30 22:12:07 +00:00
Esteban Küber 8c04999226 On object safety error, mention new enum as alternative
When we encounter a `dyn Trait` that isn't object safe, look for its
implementors. If there's one, mention using it directly If there are
less than 9, mention the possibility of creating a new enum and using
that instead.

Account for object unsafe `impl Trait on dyn Trait {}`.  Make a
distinction between public and sealed traits.

Fix #80194.
2023-10-29 23:55:46 +00:00
Michael Goulet 3bf3dadbc0 Ensure that dyn trait bounds stay sorted 2023-09-07 06:57:08 +00:00
Maybe Waffle 1f02c75718 Don't emit useless vptrs for marker traits 2023-07-19 12:06:31 +00:00
Maybe Waffle af4631ad6e Add a test for -Zprint-vtable-sizes 2023-06-13 15:16:48 +00:00
Michael Goulet 14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00
Michael Howell a5b639dc01 diagnostics: remove inconsistent English article "this" from E0107
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-23 10:27:06 -07:00
Michael Goulet a58682d7cc Specify what 'this' actually is 2023-02-21 05:21:07 +00:00
Albert Larsan cf2dff2b1e Move /src/test to /tests 2023-01-11 09:32:08 +00:00