Commit Graph

96 Commits

Author SHA1 Message Date
Michael Goulet 305524d1d6 Anonymize binders for refining_impl_trait check 2023-09-26 18:11:12 +00:00
Michael Goulet 8568121996 Need to use hybrid param-env to make sure implication is not circular 2023-09-22 19:04:37 +00:00
Michael Goulet b5a904a9d4 Use placeholders to prevent using inferred RPITIT types to imply their own WF-ness 2023-09-22 18:55:44 +00:00
Michael Goulet 7714db873e Add note 2023-09-07 01:31:33 +00:00
Michael Goulet 4d05da46e7 Don't emit refining_impl_trait for private items 2023-09-07 01:31:32 +00:00
Michael Goulet 4745d34bc3 Use self instead of the actual self ty 2023-09-07 00:49:09 +00:00
Michael Goulet e10262ca0a Implement refinement lint for RPITIT 2023-09-07 00:49:09 +00:00
Michael Goulet 07fc644132 Do not require associated types with Self: Sized to uphold bounds when confirming object candidate 2023-09-02 05:08:38 +00:00
Michael Goulet 7a6b52bf0d RPITITs are considered object-safe, they're always on Self:Sized methods 2023-09-02 04:58:23 +00:00
Michael Goulet f1679f7dd6 Capture lifetimes for associated type bounds destined to be lowered to opaques 2023-08-30 00:31:00 +00:00
bors 4e78abb437 Auto merge of #115326 - matthiaskrgr:rollup-qsoa8ar, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #115164 (MIR validation: reject in-place argument/return for packed fields)
 - #115240 (codegen_llvm/llvm_type: avoid matching on the Rust type)
 - #115294 (More precisely detect cycle errors from type_of on opaque)
 - #115310 (Document panic behavior across editions, and improve xrefs)
 - #115311 (Revert "Suggest using `Arc` on `!Send`/`!Sync` types")
 - #115317 (Devacationize oli-obk)
 - #115319 (don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead)
 - #115322 (Tweak output of `to_pretty_impl_header` involving only anon lifetimes)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-08-28 19:57:32 +00:00
David Tolnay 823bacb6e3
Revert "Suggest using `Arc` on `!Send`/`!Sync` types"
This reverts commit 9de1a472b6.
2023-08-28 03:16:48 -07:00
Michael Goulet f8e0dcbf56 Better error message for object type with GAT 2023-08-28 01:05:34 +00:00
Michael Goulet 690bcc6619 Test variances of opaque captures 2023-08-28 01:05:34 +00:00
Michael Goulet 32a9565223 Bless tests 2023-08-28 01:05:34 +00:00
Michael Goulet 13d3e57237 RPITITs capture all their lifetimes 2023-08-28 01:05:34 +00:00
Esteban Kuber 9de1a472b6 Suggest using `Arc` on `!Send`/`!Sync` types 2023-08-09 14:04:10 +00:00
Michael Goulet 07695178f8 Remove dangling tests 2023-08-08 20:41:53 +00:00
Michael Goulet 420ee167a8 Install bidirectional outlives predicates for RPITITs (and RPITs) correctly 2023-08-08 09:39:42 +00:00
Matthias Krüger f338a1f7ee
Rollup merge of #114301 - compiler-errors:dont-error-on-missing-region-outlives, r=spastorino
Don't check unnecessarily that impl trait is RPIT

We have this random `return_type_impl_trait` function to detect if a function returns an RPIT which is used in outlives suggestions, but removing it doesn't actually change any diagnostics. Let's just remove it.

Also, suppress a spurious outlives error from a ReError.

Fixes #114274
2023-08-02 06:22:48 +02:00
Michael Goulet 1c35634efe Suppress unnecessary outlives 2023-08-01 17:16:47 +00:00
Michael Goulet 9295817bad Don't check unnecessarily that impl trait is RPIT 2023-07-31 18:13:48 +00:00
Matthias Krüger 692d764e53
Rollup merge of #114267 - compiler-errors:rpitit-opaque-bounds, r=spastorino
Map RPITIT's opaque type bounds back from projections to opaques

An RPITIT in a program's AST is eventually translated into both a projection GAT and an opaque. The opaque is used for default trait methods, like:

```
trait Foo {
  fn bar() -> impl Sized { 0i32 }
}
```

The item bounds for both the projection and opaque are identical, and both have a *projection* self ty. This is mostly okay, since we can normalize this projection within the default trait method body to the opaque, but it does two things:
1. it leads to bugs in places where we don't normalize item bounds, like `deduce_future_output_from_obligations`
2. it leads to extra match arms that are both suspicious looking and also easy to miss

This PR maps the opaque type bounds of the RPITIT's *opaque* back to the opaque's self type to avoid this quirk. Then we can fix the UI test for #108304 (1.) and also remove a bunch of match arms (2.).

Fixes #108304

r? `@spastorino`
2023-07-31 16:57:55 +02:00
Michael Goulet 0f0ab89feb Don't install default projection bound for RPITITs 2023-07-30 21:46:29 +00:00
Michael Goulet 23776619a8 Remap explicit item bounds of RPITIT's opaque back to ty::Opaque 2023-07-30 20:31:27 +00:00
Michael Goulet 744e770939 some nits, bless test 2023-07-29 21:29:03 +00:00
Michael Goulet 50d21091ee Implement assumed_wf_types for RPITITs' implementations 2023-07-29 21:19:33 +00:00
Michael Goulet 349a2372ed Take RPITITs inherit the assumed_wf_types of their parent fn 2023-07-29 21:19:33 +00:00
Matthias Krüger 76f0a8c30c
Rollup merge of #114147 - compiler-errors:missing-rpitits, r=spastorino
Insert RPITITs that were shadowed by missing ADTs that resolve to [type error]

Comment inline explains how this can happen.

Fixes #113903
2023-07-28 19:51:16 +02:00
Michael Goulet ea2f8b346b Add additional test 2023-07-27 22:50:40 +00:00
Michael Goulet a4ac773f62 Insert RPITITs that were shadowed by missing ADTs that resolve to type error 2023-07-27 22:32:58 +00:00
Michael Goulet bf38111ac1 tighten span slightly for synthetic item 2023-07-27 22:20:32 +00:00
Michael Goulet 0ae0643a53 Skip reporting item name when checking RPITIT GAT's associated type bounds hold 2023-07-27 22:09:44 +00:00
Santiago Pastorino 20429af7a3
Replace RPITIT current impl with new strategy that lowers as a GAT 2023-07-08 18:21:34 -03:00
Santiago Pastorino 6d80879ab9
Add regression test for RPITITs 2023-07-07 15:58:25 -03:00
bors 0130c3a06e Auto merge of #113215 - compiler-errors:rpitit-predicates-tweaks, r=spastorino
Make RPITITs assume/require their parent method's predicates

Removes a FIXME from the `param_env` query where we were manually adding the parent function's predicates to the RPITIT's assumptions.

r? `@spastorino`
2023-07-04 04:24:24 +00:00
Matthias Krüger ca7e27a71c
Rollup merge of #113182 - compiler-errors:rpit-stricter-captures, r=oli-obk
Error when RPITITs' hidden types capture more lifetimes than their trait definitions

This implements a stricter set of captures rules for RPITITs. They now may only capture:
1. Lifetimes from the impl header (both the self type and any trait substs -- we may want to restrict just to the self type's lifetimes, but the PR makes that easy to do, too)
2. Lifetimes mentioned by the `impl Trait` in the trait method's definition.

Namely, they may not mention lifetimes from the method (early or late) that are not mentioned in the `impl Trait`.

cc #105258 which I think was trying to do this too, though I'm not super familiar with what exactly differs from that or why that one was broken.
cc #112194 (doesn't fix this issue per se, because it's still an open question, but I think this is objectively better than the status quo, and gets us closer to resolving that issue.)

Technically is a fix for the ICE in #108580, but it turns that issue into an error now. We can decide separately whether or not nested RPITITs should capture lifetimes from their parents.

r? ``@oli-obk``
2023-07-01 13:46:01 +02:00
Michael Goulet b0ab37eb08 Additional wf test 2023-06-30 20:28:34 +00:00
Michael Goulet a14285ca7e RPITITs inherit method predicates 2023-06-30 20:08:56 +00:00
Matthias Krüger 38e6bba9c1
Rollup merge of #113171 - spastorino:new-rpitit-25, r=compiler-errors
Properly implement variances_of for RPITIT GAT

This fixes some of the issues found by crater run in https://github.com/rust-lang/rust/pull/112988#issuecomment-1610019572

r? ``@compiler-errors``
2023-06-30 08:01:14 +02:00
Michael Goulet 8ad5ea7b01 Adapt tests from #105258 2023-06-30 02:39:07 +00:00
Michael Goulet 473c88dfb6 Flip the order of binder instantiation for better diagnostics 2023-06-30 02:17:07 +00:00
Michael Goulet d567e4f8b6 Error for RPITIT hidden tys that capture more than their trait defn 2023-06-30 02:17:07 +00:00
Santiago Pastorino a10406318e
Properly implement variances_of for RPITIT GAT 2023-06-29 23:08:32 -03:00
Michael Goulet 0506250f8c Encode item bounds for DefKind::ImplTraitPlaceholder 2023-06-29 16:37:13 +00:00
Michael Goulet 7563909a28 Liberate bound vars properly when suggesting missing AFIT 2023-06-21 16:32:26 +00:00
Michael Goulet be68e9e336
Rollup merge of #112596 - compiler-errors:missing-sig-with-rpitit, r=b-naber
Suggest correct signature on missing fn returning RPITIT/AFIT

Add `async` and unpeel the future's output type if the function is async

Fixes #108195
2023-06-19 17:53:34 -07:00
Michael Goulet bc78d0cbf1 Error on unconstrained lifetime in RPITIT 2023-06-14 05:20:31 +00:00
Michael Goulet dbee24d949 Suggest correct signature on missing fn returning RPITIT/AFIT 2023-06-13 20:41:15 +00:00
Michael Goulet 14bf909e71 Note base types of coercion 2023-05-12 00:10:52 +00:00