Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat types in unnormalized function signatures as well-formed #88312

Merged
merged 1 commit into from
Aug 29, 2021

Conversation

jackh726
Copy link
Member

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2021
@@ -271,9 +274,9 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
canonicalized_query: None,
}
});
let constraints2 = self.add_implied_bounds(ty);
let constraints_implied_2 = self.add_implied_bounds(ty);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need this set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principle, it should be a subset of the other, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure. I'm thinking of some variation of

trait Foo {
  type Bar<'a> where Self: 'a;
  fn foo(_: Self::Bar<'a>);
}
struct S<T> { ... }
impl<T> Foo for S<T> {
  type Bar<'a> where Self: 'a = &'a T;
  fn foo(_: Self::Bar<'a>) {}
}

and trying to imagining if we could somehow run into a situation where T: 'a. But I suppose we would get that from Self: 'a

I can try to remove this (and other places where we add normalized inputs to WF tys list) and see if anything breaks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so we can't remove this, because of cases like

trait Foo {
  type Bar;
  fn foo(&self) -> &Self::Bar;
}
impl Foo for () {
  type Bar = ();
  fn foo(&self) ->&() {}
}

unsafe fn as_inner(&mut self) -> &mut S {
fails, for example.

There might be some combination of reverting the changes here that allow things to work fine, but for consistency, I think it's better to treat these all the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. That example makes sense. I really want to do that "how do WF rules in a formal sense" write up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I would say -- the example makes sense, but really it points to a shortcoming elsewhere in our system. That is, in some sense, we ought to be able to in the assumption that Self::Source: 'a and then normalize that assumption to get that S: 'a. I expect this is largely equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment with this example?

@nikomatsakis
Copy link
Contributor

r=me with comment

@jackh726
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 26, 2021

📌 Commit 97bf80d has been approved by nikomatsakis

@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 Aug 26, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Aug 27, 2021
Treat types in unnormalized function signatures as well-formed

Fixes rust-lang#87748

r? `@nikomatsakis`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Aug 27, 2021
Treat types in unnormalized function signatures as well-formed

Fixes rust-lang#87748

r? ``@nikomatsakis``
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Aug 27, 2021
Treat types in unnormalized function signatures as well-formed

Fixes rust-lang#87748

r? ```@nikomatsakis```
@bors
Copy link
Contributor

bors commented Aug 29, 2021

⌛ Testing commit 97bf80d with merge 59ce765...

@bors
Copy link
Contributor

bors commented Aug 29, 2021

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 59ce765 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 29, 2021
@bors bors merged commit 59ce765 into rust-lang:master Aug 29, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 29, 2021
@jackh726 jackh726 deleted the issue-87748 branch August 29, 2021 13:04
@rylev
Copy link
Member

rylev commented Sep 1, 2021

@nikomatsakis @jackh726 This change lead to large regressions in instruction counts in many real world crates. The query affected by this seems to be additional calls to implied_outlives_bounds which I believe would be impacted by this change. Any thoughts on why this might be?

As part of the performance triage process, I'm marking this as a performance regression. If you believe this performance regression to be justifiable or once you have an issue or PR that addresses this regression, please mark this PR with the label perf-regression-triaged.

@rustbot label +perf-regression

@rustbot rustbot added the perf-regression Performance regression. label Sep 1, 2021
@nikomatsakis
Copy link
Contributor

This change certainly added more implied bounds, so there may just be more to sort through, but there may also be some oversights, like failure to remove duplicates. Merits more investigation for sure.

@jackh726
Copy link
Member Author

jackh726 commented Sep 1, 2021

I'll do some experiments to see if I can fix the perf regressions.

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2021
Use FxHashSet instead of Vec for well formed tys

Trying to recover perf from rust-lang#88312

r? `@ghost`
@jackh726
Copy link
Member Author

We won back perf in #88771. It's not 100% of what we lost, but about the best that can be done probably.

@jackh726 jackh726 added the perf-regression-triaged The performance regression has been triaged. label Sep 12, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 29, 2021
Don't treat unnormalized function arguments as well-formed

Partial revert of rust-lang#88312

r? `@pnkfelix`
cc `@nikomatsakis`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 30, 2021
Don't treat unnormalized function arguments as well-formed

Partial revert of rust-lang#88312

r? `@pnkfelix`
cc `@nikomatsakis`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 30, 2021
Don't treat unnormalized function arguments as well-formed

Partial revert of rust-lang#88312

r? ``@pnkfelix``
cc ``@nikomatsakis``
@jackh726 jackh726 restored the issue-87748 branch March 12, 2022 18:30
@jackh726 jackh726 deleted the issue-87748 branch March 12, 2022 18:35
@jackh726 jackh726 restored the issue-87748 branch March 12, 2022 18:42
@jackh726 jackh726 deleted the issue-87748 branch March 12, 2022 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GAT: lifetime mismatch when requiring lifetime bounds despite type not using the lifetimes at all
6 participants