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

add dynamic for smir #113969

Merged
merged 2 commits into from
Jul 24, 2023
Merged

add dynamic for smir #113969

merged 2 commits into from
Jul 24, 2023

Conversation

ericmarkmartin
Copy link
Contributor

r? spastorino

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 22, 2023
@bors
Copy link
Contributor

bors commented Jul 23, 2023

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

type T = stable_mir::ty::PolyFnSig;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use stable_mir::ty::Binder;
impl<'tcx, S, T> Stable<'tcx> for ty::Binder<'tcx, S>
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename the T here to V. I think it will be clearer because we won't have the T param and the T associated type and won't have this T = T thing that looks weird :).

use stable_mir::ty::Binder;
impl<'tcx, S, T> Stable<'tcx> for ty::Binder<'tcx, S>
where
S: Stable<'tcx, T = T> + Copy,
Copy link
Member

Choose a reason for hiding this comment

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

Unsure what's the preferred way here, if having Copy as bound, if using Deref and calling as_deref() and then implement stable for what's returned or if calling clone.
cc @oli-obk

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered using a Clone bound but I thought it might be too weak?

If there's a type with an expensive clone, I'm not sure I wanted to implicitly derive an expensive implementation of stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, isn't as_deref just an Option thing? I thought the method you get from Deref is just deref

Copy link
Member

Choose a reason for hiding this comment

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

If I'm not wrong, this works ...

diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs
index dd0d7df9ecf..b7e827dced0 100644
--- a/compiler/rustc_smir/src/rustc_smir/mod.rs
+++ b/compiler/rustc_smir/src/rustc_smir/mod.rs
@@ -581,13 +581,13 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {

 impl<'tcx, S, T> Stable<'tcx> for ty::Binder<'tcx, S>
 where
-    S: Stable<'tcx, T = T> + Copy,
+    S: Stable<'tcx, T = T>,
 {
     type T = stable_mir::ty::Binder<T>;

     fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
         stable_mir::ty::Binder {
-            value: self.skip_binder().stable(tables),
+            value: self.as_ref().skip_binder().stable(tables),
             bound_vars: self
                 .bound_vars()
                 .iter()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh as_ref not as_deref

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh ignore me I'm being dumb--binder has both

@spastorino
Copy link
Member

This looks good to me, please squash the commits. Maybe you can make a first commit with the Binder change and then the one that adds Dynamic.

@ericmarkmartin
Copy link
Contributor Author

Sure I can squash as such. I'm actually not done though, hence the PR being a draft. In particular, I think I want to handle Term properly rather than as an opaque.

@ericmarkmartin ericmarkmartin force-pushed the smir-ty-dynamic branch 3 times, most recently from 4172327 to c5ab118 Compare July 24, 2023 04:05
@ericmarkmartin ericmarkmartin marked this pull request as ready for review July 24, 2023 04:18
@rustbot
Copy link
Collaborator

rustbot commented Jul 24, 2023

This PR changes Stable MIR

cc @oli-obk, @celinval, @spastorino

@spastorino
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 24, 2023

📌 Commit badb617 has been approved by spastorino

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 Jul 24, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 24, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#113969 (add dynamic for smir)
 - rust-lang#113985 (Use erased self type when autoderefing for trait error suggestion)
 - rust-lang#113987 (Comment stuff in the new solver)
 - rust-lang#113992 (arm-none fixups)
 - rust-lang#113993 (Optimize format usage)
 - rust-lang#113994 (Optimize format usage)
 - rust-lang#114006 (Update sparc-unknown-none-elf platform README)
 - rust-lang#114021 (Add missing documentation for `Session::time`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 60a5d2d into rust-lang:master Jul 24, 2023
@rustbot rustbot added this to the 1.73.0 milestone Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants