Commit Graph

14 Commits

Author SHA1 Message Date
Michael Goulet
1e96d7a553 Consider param-env for fast path 2025-07-20 17:45:01 +00:00
León Orell Valerian Liehr
82a02aefe0 HIR ty lowering: Validate PointeeSized bounds 2025-07-18 12:25:24 +02:00
León Orell Valerian Liehr
879f62bb3c Reword diagnostic about relaxing non-Sized bound
* The phrasing "only does something for" made sense back when this
  diagnostic was a (hard) warning. Now however, it's simply a hard
  error and thus completely rules out "doing something".
* The primary message was way too long
* The new wording more closely mirrors the wording we use for applying
  other bound modifiers (like `const` and `async`) to incompatible
  traits.
* "all other traits are not bound by default" is no longer accurate
  under Sized Hierarchy. E.g., traits and assoc tys are (currently)
  bounded by `MetaSized` by default but can't be relaxed using
  `?MetaSized` (instead, you relax it by adding `PointeeSized`).
* I've decided against adding any diagnositic notes or suggestions
  for now like "trait `Trait` can't be relaxed as it's not bound by
  default" which would be incorrect for `MetaSized` and assoc tys
  as mentioned above) or "consider changing `?MetaSized` to
  `PointeeSized`" as the Sized Hierarchy impl is still WIP)
2025-07-18 12:13:30 +02:00
León Orell Valerian Liehr
84ed70b69d Reword diagnostics about relaxed bounds in invalid contexts 2025-07-18 12:13:19 +02:00
León Orell Valerian Liehr
1df99f22d3 AST lowering: More robustly deal with relaxed bounds 2025-07-18 03:13:21 +02:00
David Wood
8d64937dc2 trait_sel: MetaSized always holds temporarily
As a temporary measure while a proper fix for
`tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs`
is implemented, make `MetaSized` obligations always hold. In effect,
temporarily reverting the `sized_hierarchy` feature. This is a small
change that can be backported.
2025-07-16 12:35:44 +00:00
Michael Goulet
2516c33982 Remove support for dyn* 2025-07-01 19:00:21 +00:00
David Wood
2057423506 hir_analysis: prohibit dyn PointeeSized 2025-06-27 17:01:47 +00:00
David Wood
607eb322a8 trait_sel: skip elaboration of sizedness supertrait
As a performance optimization, skip elaborating the supertraits of
`Sized`, and if a `MetaSized` obligation is being checked, then look for
a `Sized` predicate in the parameter environment. This makes the
`ParamEnv` smaller which should improve compiler performance as it avoids
all the iteration over the larger `ParamEnv`.
2025-06-16 23:04:36 +00:00
David Wood
5d17987d71 tests: add overflow test
This test case is a reduction from the `hwc` crate on GitHub, following a
crater run. It passes with the next solver but fails on the current
solver due to a known limitation of the current solver. It starts fails
on the current solver with the `sized_hierarchy` changes because `?Sized`
is now a proper bound.
2025-06-16 23:04:35 +00:00
David Wood
118d4e62c3 middle: print {Meta,Pointee}Sized in opaques
When `sized_hierarchy` is enabled, rustc should print `MetaSized` or
`PointeeSized` instead of `?Sized` in opaques.
2025-06-16 23:04:34 +00:00
David Wood
9044b78c0d trait_sel: print {Meta,Pointee}Sized impl headers
When printing impl headers in a diagnostic, the compiler has to account
for `?Sized` implying `MetaSized` and new `MetaSized` and `PointeeSized`
bounds.
2025-06-16 23:04:34 +00:00
David Wood
86ab2b60cd hir_analysis: add {Meta,Pointee}Sized bounds
Opting-out of `Sized` with `?Sized` is now equivalent to adding a
`MetaSized` bound, and adding a `MetaSized` or `PointeeSized` bound
is equivalent to removing the default `Sized` bound - this commit
implements this change in `rustc_hir_analysis::hir_ty_lowering`.

`MetaSized` is also added as a supertrait of all traits, as this is
necessary to preserve backwards compatibility.

Unfortunately, non-global where clauses being preferred over item bounds
(where `PointeeSized` bounds would be proven) - which can result in
errors when a `PointeeSized` supertrait/bound/predicate is added to some
items. Rather than `PointeeSized` being a bound on everything, it can
be the absence of a bound on everything, as `?Sized` was.
2025-06-16 23:04:33 +00:00
David Wood
3b0e1c17d2 trait_sel: {Meta,Pointee}Sized on ?Sized types
Expand the automatic implementation of `MetaSized` and `PointeeSized` so
that it is also implemented on non-`Sized` types, just not `ty::Foreign`
(extern type).
2025-06-16 15:00:22 +00:00