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

Implement trait upcasting #821

Merged
merged 7 commits into from
Jan 8, 2025
Merged

Conversation

WaffleLapkin
Copy link
Member

@WaffleLapkin WaffleLapkin commented Jan 2, 2025

This is based on #796, but with a few more changes.

cc @Veykril @lowr @jackh726

@lqd
Copy link
Member

lqd commented Jan 2, 2025

I guess this is for r-a? But jack is working on switching it to use the new solver, and has made a lot of progress already.

@WaffleLapkin
Copy link
Member Author

@lqd yes, this is for r-a. I started looking into it since it blocks stabilization of trait upcasting (rust-lang/rust#134367 (comment)).

@lqd
Copy link
Member

lqd commented Jan 2, 2025

Ah I see, it seems worthwhile to land to unblock stabilization then.

@compiler-errors
Copy link
Member

@WaffleLapkin: Can you please unset the style edition? This is both churn, and more importantly this crate needs to build on stable. The edition is not stable, so unless you want to wait until edition 2024 is stable in February to land this, then it should be reverted.

@WaffleLapkin
Copy link
Member Author

@compiler-errors forgot for a moment that 2024 edition is not stable yet, oops /_=

I undid formatting changes.

Copy link
Contributor

@davidbarsky davidbarsky left a comment

Choose a reason for hiding this comment

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

I don't know if I have merge permissions on chalk—let alone if i'm capable of understanding it—but lgtm!

@compiler-errors
Copy link
Member

Let's maybe wait for a review from someone who does understand it then 😆

I'll give this a look when I'm back from the bakery

@davidbarsky
Copy link
Contributor

heh, fair.

(not that my approvals matters much anyways, i can't merge it!)

@jackh726
Copy link
Member

jackh726 commented Jan 3, 2025

I'll take another look at this over the weekend. I've read through #796 a while ago and nothing seemed surprising at the time (just didn't put enough thought into it to feel completely confident).

One note is that I think auto releases may currently be broken, so we'll have to follow up with a manual release, I think, to fix things.

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

Looks good for the most part, but I think we need one more test case.

}
}

#[test]
Copy link
Member

@jackh726 jackh726 Jan 6, 2025

Choose a reason for hiding this comment

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

I feel like what's missing here is a test with the super trait being under a binder (e.g. trait Principal where for<'a> Self: Super<'a>. I assume we can do this without modifying any of the test parsing code - if we can't, then I think it's okay to land this with just a FIXME added.

Copy link
Member

Choose a reason for hiding this comment

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

does chalk represent dyn for<'a> Trait<'a>? I assume that forall<'a> dyn Trait + 'a is a distinct thing from dyn for<'a> Trait + 'a. If it can represent that then it would probably also be good to test dyn for<'a> Trait<'a> can be upcasted to dyn for<'a> Super<'a> given some trait Trait<'a>: Super<'a> in addition to the case of trait: for<'a> Super<'a>

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be able to (there is certainly ir for it, but I'm not sure exactly how to specify it in the parser). If you can't figure it out, I'll look at it this evening.

That's a good test to add for sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Test added: 5689335

@jackh726 jackh726 added this pull request to the merge queue Jan 8, 2025
Merged via the queue into rust-lang:master with commit d2bcd64 Jan 8, 2025
5 checks passed
@lqd lqd mentioned this pull request Jan 8, 2025
@WaffleLapkin WaffleLapkin deleted the trait_upcast branch January 8, 2025 14:52
@WaffleLapkin
Copy link
Member Author

One note is that I think auto releases may currently be broken, so we'll have to follow up with a manual release, I think, to fix things.

@jackh726 are you going to release a new version? 👀

@WaffleLapkin WaffleLapkin restored the trait_upcast branch January 13, 2025 17:26
@WaffleLapkin WaffleLapkin deleted the trait_upcast branch January 13, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants