Commit Graph

253 Commits

Author SHA1 Message Date
lcnr
5139facb36 add tests 2025-09-30 12:02:43 +02:00
lcnr
0f2b79c36d add tests 2025-09-29 15:28:33 +02:00
Matthias Krüger
750e902a75 Rollup merge of #146675 - Jules-Bertholet:sync-nonexclusive, r=Mark-Simulacrum
Allow shared access to `Exclusive<T>` when `T: Sync`

Addresses libs-api request in https://github.com/rust-lang/rust/issues/98407#issuecomment-3299348713.

Adds the following trait impls to `Exclusive<T>`, all bounded on `T: Sync`:

- `AsRef<T>`
- `Clone`
- `Copy`
- `PartialEq`
- `StructuralPartialEq`
- `Eq`
- `Hash`
- `PartialOrd`
- `Ord`
- `Fn`

``@rustbot`` label T-libs-api
2025-09-28 18:13:12 +02:00
lcnr
4a0c7cc730 fix cycle head usages tracking 2025-09-26 15:29:01 +02:00
lcnr
32d24f9efa allow bound regions in writeback 2025-09-24 13:08:25 +02:00
Jules Bertholet
f1d6e000b5 Bless UI tests 2025-09-21 17:26:39 -04:00
Joe Birr-Pixton
325ceef018 Fix other uses of "adaptor" 2025-09-16 11:58:12 +01:00
lcnr
14b0ba6a05 support non-defining uses in HIR typeck 2025-08-25 14:20:18 +02:00
bors
69b76df90c Auto merge of #145706 - lcnr:uniquification, r=BoxyUwU
change HIR typeck region uniquification handling approach

rust-lang/rust#144405 causes structural lookup of opaque types to not work during HIR typeck, so instead avoid uniquifying goals and instead only reprove them if MIR borrowck actually encounters an error.

This doesn't perfectly maintain the property that HIR typeck succeeding implies that MIR typeck succeeds, instead weakening this check to only guarantee that HIR typeck implies that MIR typeck succeeds modulo region uniquification. This means we still get the actually desirable ICEs if we MIR building is broken or we forget to check some property in HIR typeck, without having to deal with the fallout of uniquification in HIR typeck itself.

We report errors using the original obligation sources of HIR typeck so diagnostics aren't that negatively impacted either.

Here's the history of region uniquification while working on the new trait solver:
- rust-lang/rust#107981
- rust-lang/rust#110180
- rust-lang/rust#114117
- rust-lang/rust#130821
- rust-lang/rust#144405
- rust-lang/rust#145706 <- we're here 🎉

r? `@BoxyUwU`
2025-08-23 20:16:58 +00:00
Esteban Küber
049c32797b On E0277, point at type that doesn't implement bound
When encountering an unmet trait bound, point at local type that doesn't implement the trait:

```
error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied
  --> $DIR/issue-64855.rs:9:19
   |
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
   |                   ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
   |
help: the trait `Foo` is not implemented for `Bar<T>`
  --> $DIR/issue-64855.rs:9:1
   |
LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ;
   | ^^^^^^^^^^^^^^^^^
```
2025-08-22 17:55:15 +00:00
lcnr
17ac2fc96d change HIR typeck unification handling approach 2025-08-22 13:39:38 +02:00
lcnr
aa3691ea08 add regression test 2025-08-14 15:32:50 +02:00
lcnr
a78f92be9b add tests 2025-07-31 15:39:55 +02:00
lcnr
b6cbe33aeb handle region dependent goals due to infer vars 2025-07-30 14:01:37 +02:00
lcnr
0b323eacd4 uniquify root goals during HIR typeck 2025-07-25 12:40:01 +00:00
Michael Goulet
1e96d7a553 Consider param-env for fast path 2025-07-20 17:45:01 +00:00
Michael Goulet
42c9bfd2b9 Remove Symbol for Named LateParam/Bound variants 2025-07-04 18:14:22 +00:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00
Oli Scherer
632a921479 Move lazy type alias checks to non-hir-wfck 2025-06-30 08:45:43 +00:00
Guillaume Gomez
80f20c98f3 Rollup merge of #142671 - davidtwco:no-default-bounds-attr, r=lcnr
add #![rustc_no_implicit_bounds]

Follow-up from rust-lang/rust#137944.

Adds a new `rustc_attrs` attribute that stops rustc from adding any default bounds. Useful for tests where default bounds just add noise and make debugging harder.

After reviewing all tests with `?Sized`, these tests seem like they could probably benefit from `#![rustc_no_implicit_bounds]`.

- Skipping most of `tests/ui/unsized` as these seem to want to test `?Sized`
- Skipping tests that used `Box<T>` because it's still bound by `T: MetaSized`
- Skipping parsing or other tests that cared about `?Sized` syntactically
- Skipping tests for `derive(CoercePointee)` because this appears to check that the pointee type is relaxed with `?Sized` explicitly

r? `@lcnr`
2025-06-27 15:04:52 +02:00
David Wood
1fd13fddba tests: add #![rustc_no_implicit_bounds]
After reviewing all tests with `?Sized` and discussing with lcnr, these
tests seem like they could probably benefit from
`#![rustc_no_implicit_bounds]`.
2025-06-27 05:34:08 +00:00
Michael Goulet
250b5d204f Make missing lifetime suggestion verbose 2025-06-24 18:59:42 +00:00
David Wood
183458263b tests: bless remaining tests
These tests just need blessing, they don't have any interesting behaviour
changes.

Some of these tests have new errors because `LegacyReceiver` cannot be
proven to be implemented now that it is also testing for `MetaSized` -
but this is just a consequence of the other errors in the test.
2025-06-16 23:04:35 +00:00
Michael Goulet
cd1d84e304 Apply nested goals certainty to InspectGoals for normalizes-to 2025-06-09 17:02:09 +00:00
Michael Goulet
3418d5db3a Fast path for stalled obligations on self ty 2025-06-02 19:23:20 +00:00
Michael Goulet
2a339ce492 Structurally normalize types as needed in projection_ty_core 2025-05-29 11:16:44 +00:00
Matthias Krüger
69b13e4cab Rollup merge of #141347 - lcnr:lets-make-it-unsound-3, r=compiler-errors
incorrectly prefer builtin `dyn` impls :3

This makes #57893 slightly more exploitable with the new solver. It's still strictly better than the old solver and the underlying unsoundness persists in the new one even without this preference.

Properly fixing #57893 is something we've been looking at more deeply recently and discussed at the [Types Meetup during the All-Hands](https://hackmd.io/rz-4ghMzTb2wXOkdLKHaHw#Dyn-traits). Whatever approach we'll end up deciding on will likely require a fairly long transition period and some significant further design work. This should not block `-Znext-solver`.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/183

r? `@compiler-errors` cc `@rust-lang/types`
2025-05-21 22:14:59 +02:00
lcnr
5d9141c6c8 fix better_any breakage by making the solver more unsound 2025-05-21 13:54:19 +00:00
Matthias Krüger
9fd0ab6876 Rollup merge of #141334 - lcnr:coerce-nested-obligations, r=compiler-errors
eagerly check nested obligations when coercing fndefs

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/212

r? `@compiler-errors`
2025-05-21 15:38:12 +02:00
Matthias Krüger
ab9109ad19 Rollup merge of #141333 - compiler-errors:param-env-candidate-unnorm, r=lcnr
Use `DeepRejectCtxt` in `assemble_inherent_candidates_from_param`

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/214

We were not properly considering unnormalized param-env candidates in `assemble_inherent_candidates_from_param`.

r? lcnr
2025-05-21 15:38:12 +02:00
lcnr
196c3b3ef4 eagerly check nested obligations when coercing fndefs 2025-05-21 11:09:48 +00:00
Michael Goulet
ad59f0b6e6 Use DeepRejectCtxt in assemble_inherent_candidates_from_param 2025-05-21 10:02:54 +00:00
Michael Goulet
44a2af3068 Do not eagerly fold consts in normalize_param_env_or_error if new solver 2025-05-21 09:23:36 +00:00
Matthias Krüger
74b79aee60 Rollup merge of #140711 - compiler-errors:combine-maybes, r=lcnr
Do not discard constraints on overflow if there was candidate ambiguity

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/201.

There's a pretty chunky justification in the test.

r? lcnr
2025-05-08 08:14:18 +02:00
Michael Goulet
a910329c67 Use MaybeCause::or to allow constraints from overflows if they are combined with ambiguity 2025-05-07 17:12:15 +00:00
Michael Goulet
1f774d74b3 Only prefer param-env candidates if they remain non-global after norm 2025-05-07 16:00:21 +00:00
lcnr
431f02d531 support duplicates in the opaque_types_storage 2025-05-06 14:59:09 +00:00
Michael Goulet
12d3021ef0 Deeply normalize in the new solver in WF 2025-05-05 15:52:38 +00:00
Matthias Krüger
54eae599e0 Rollup merge of #140306 - lcnr:specialization-new, r=compiler-errors
handle specialization in the new trait solver

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/187
also fixes the regression in `plonky2_field` from https://github.com/rust-lang/trait-system-refactor-initiative/issues/188

cc https://github.com/rust-lang/rust/pull/111994

r? ```@compiler-errors```
2025-04-26 07:13:09 +02:00
Michael Goulet
31c8d10342 Track per-obligation recursion depth only if there is inference 2025-04-25 18:14:39 +00:00
lcnr
009db53e49 handle specialization in the new trait solver
uwu :3
2025-04-25 17:59:33 +00:00
lcnr
e5e3a95c1e norm nested aliases before evaluating the parent goal 2025-04-24 18:41:43 +00:00
Michael Goulet
e882ff4e7e Don't assemble non-env/bound candidates if projection is rigid 2025-04-18 01:44:06 +00:00
Matthias Krüger
da43826398 Rollup merge of #139774 - compiler-errors:supertrait-alias, r=lcnr
Fix replacing supertrait aliases in `ReplaceProjectionWith`

The new solver has a procedure called `predicates_for_object_candidate`, which elaborates the super-bounds and item-bounds that are required to hold for a dyn trait to implement something via a built-in object impl.

In that procedure, there is a folder called `ReplaceProjectionWith` which is responsible for replacing projections that reference `Self`, so that we don't encounter cycles when we then go on to normalize those projections in the process of proving these super-bounds.

That folder had a few problems: Firstly, it wasn't actually checking that this was a super bound originating from `Self`. Secondly, it only accounted for a *single* projection type def id, but trait objects can have multiple (i.e. `trait Foo<A, B>: Bar<A, Assoc = A> + Bar<B, Assoc = B>`).

To fix the first, it's simple enough to just add an equality check for the self ty. To fix the second, I implemented a matching step that's very similar to the `projection_may_match` check we have for upcasting, since on top of having multiple choices, we need to deal with both non-structural matches and ambiguity.

This probably lacks a bit of documentation, but I think it works pretty well.

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/171

r? lcnr
2025-04-17 17:40:27 +02:00
Michael Goulet
3863018d96 Fix replacing supertrait aliases in ReplaceProjectionWith 2025-04-16 20:05:55 +00:00
lcnr
48e119ef5a stepping into impls for norm is unproductive 2025-04-16 10:35:09 +02:00
Stuart Cook
e8c9dcc79e Rollup merge of #139791 - lcnr:ignore-global-where-bounds, r=compiler-errors
drop global where-bounds before merging candidates

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/172

r? ```@compiler-errors```
2025-04-15 15:47:30 +10:00
lcnr
2c2c9df653 drop global where-bounds before merging candidates 2025-04-14 12:59:22 +02:00
Nicholas Nethercote
ce2aa97cd6 Move has_self field to hir::AssocKind::Fn.
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field,
which is misplaced, because it's only relevant for associated fns, not
for associated consts or types. This commit moves it (and renames it) to
the `AssocKind::Fn` variant, where it belongs.

This requires introducing a new C-style enum, `AssocTag`, which is like
`AssocKind` but without the fields. This is because `AssocKind` values
are passed to various functions like `find_by_ident_and_kind` to
indicate what kind of associated item should be searched for, and having
to specify `has_self` isn't relevant there.

New methods:
- Predicates `AssocItem::is_fn` and `AssocItem::is_method`.
- `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`.

Removed `find_by_name_and_kinds`, which is unused.

`AssocItem::descr` can now distinguish between methods and associated
functions, which slightly improves some error messages.
2025-04-14 16:13:04 +10:00
Jieyou Xu
db6e3aa913 tests: ensure disabled tests have a reason 2025-04-12 15:24:25 +08:00