Skip to content

Conversation

compiler-errors
Copy link
Member

Introduce a new Trait candidate kind for the ImplTraitInTrait projection candidate, which just projects an RPITIT down to its opaque type form.

This is a hack until we lower RPITITs to regular associated types, after which we will need to rework how these default bodies are type-checked, so comments are left in a few places for us to clean up later.

Fixes #101665

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 11, 2022
@rust-highfive
Copy link
Contributor

r? @jackh726

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 11, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 11, 2022
…1-dead

Only encode return-position `impl Trait` in trait when parent function has a default body

Semi-blocked on rust-lang#101679, because I can't currently write a test for when we _should_ encode the type of the return-position `impl Trait` in trait, which is when a trait has a default function body, like so:

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

Though this can land even without rust-lang#101679, since it does prevent ICEs from occuring any time you use `#![feature(return_position_impl_trait_in_trait)]` in a library, which is kind annoying.
@compiler-errors compiler-errors added the F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` label Sep 12, 2022
@bors
Copy link
Collaborator

bors commented Sep 24, 2022

☔ The latest upstream changes (presumably #102223) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

r=me, but needs rebase

@bors
Copy link
Collaborator

bors commented Oct 3, 2022

☔ The latest upstream changes (presumably #102627) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member Author

compiler-errors commented Oct 5, 2022

  1. I added 7a1f25e0569c6ca5fb3d3c8fa05aa3202235d36d which actually makes sure the default body satisfies the RPIT bounds, and doesn't normalize unless there's a default body.
  2. I added a test for default-body async fn in trait with impl Trait return fails to compile #102688 which fails to compile even with this PR. That requires #![feature(return_position_impl_trait_in_trait)], so I still want to land this since it fixes the AFIT case which we're more likely to stabilize sooner.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 12, 2022

📌 Commit 0eeeea9 has been approved by nikomatsakis

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 12, 2022
@bors
Copy link
Collaborator

bors commented Oct 12, 2022

⌛ Testing commit 0eeeea9 with merge 0938e16...

@bors
Copy link
Collaborator

bors commented Oct 13, 2022

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 0938e16 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 13, 2022
@bors bors merged commit 0938e16 into rust-lang:master Oct 13, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 13, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0938e16): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-0.9%, -0.6%] 6
Improvements ✅
(secondary)
-0.6% [-0.8%, -0.3%] 3
All ❌✅ (primary) -0.7% [-0.9%, -0.6%] 6

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@Mark-Simulacrum
Copy link
Member

Improvements look to be at least mostly driven by diesel, which is in its (new) noise range. Can likely be ignored.

@compiler-errors compiler-errors deleted the rpitit-default-body branch November 2, 2022 02:58
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
… r=nikomatsakis

Support default-body trait functions with return-position `impl Trait` in traits

Introduce a new `Trait` candidate kind for the `ImplTraitInTrait` projection candidate, which just projects an RPITIT down to its opaque type form.

This is a hack until we lower RPITITs to regular associated types, after which we will need to rework how these default bodies are type-checked, so comments are left in a few places for us to clean up later.

Fixes rust-lang#101665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-return_position_impl_trait_in_trait `#![feature(return_position_impl_trait_in_trait)]` merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE in RPITIT trait methods with default bodies
9 participants