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 HashStable_NoContext to simplify HashStable implementations in rustc_type_ir #117580

Merged

Conversation

compiler-errors
Copy link
Member

adds derive(HashStable_NoContext) which is a derived HashStable implementation that has no HashStableContext bound, and which adds where bounds for HashStable based off of fields and not generics.

This means we can derive(HashStable_NoContext) in more places in rustc_type_ir rather than having to hand-roll implementations.

@rustbot
Copy link
Collaborator

rustbot commented Nov 4, 2023

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Nov 4, 2023
@cjgillot
Copy link
Contributor

cjgillot commented Nov 4, 2023

Should we use this implementation everywhere as HashStable_Generic? Or does this break stuff?

@compiler-errors
Copy link
Member Author

@cjgillot: I tried it, and it breaks stuff, I think where generating where clauses based on fields may lead to coinductive cycles. I could come up with an example if you're curious, but I think it's already explored generally in Niko's blog post about perfect derive.

@bors
Copy link
Contributor

bors commented Nov 6, 2023

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

@rust-cloud-vms rust-cloud-vms bot force-pushed the hash-stable-simplify-rustc_type_ir branch from b94f779 to 740635f Compare November 6, 2023 23:50
@compiler-errors
Copy link
Member Author

r? @jackh726

@rustbot rustbot assigned jackh726 and unassigned wesleywiser Nov 9, 2023
@bors
Copy link
Contributor

bors commented Nov 13, 2023

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

@compiler-errors compiler-errors force-pushed the hash-stable-simplify-rustc_type_ir branch from 740635f to 003e1ee Compare November 13, 2023 18:49
@rust-log-analyzer

This comment has been minimized.

@compiler-errors compiler-errors force-pushed the hash-stable-simplify-rustc_type_ir branch from 003e1ee to 0cfdedb Compare November 13, 2023 18:54
@jackh726
Copy link
Member

I'll get to this soon (and the other)

@bors
Copy link
Contributor

bors commented Nov 14, 2023

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

@compiler-errors compiler-errors force-pushed the hash-stable-simplify-rustc_type_ir branch from 0cfdedb to 543d9d3 Compare November 17, 2023 17:15
Comment on lines 73 to 75
let body = s.each(|bi| {
let attrs = parse_attributes(bi.ast());
if attrs.ignore {
quote! {}
} else if let Some(project) = attrs.project {
quote! {
(&#bi.#project).hash_stable(__hcx, __hasher);
}
} else {
quote! {
#bi.hash_stable(__hcx, __hasher);
}
}
});

let discriminant = match s.ast().data {
syn::Data::Enum(_) => quote! {
::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
},
syn::Data::Struct(_) => quote! {},
syn::Data::Union(_) => panic!("cannot derive on union"),
};
Copy link
Member

Choose a reason for hiding this comment

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

Can these use the functions below? I don't see how they're different?

@@ -64,6 +64,50 @@ pub(crate) fn hash_stable_generic_derive(
)
}

pub(crate) fn hash_stable_no_context_derive(
Copy link
Member

Choose a reason for hiding this comment

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

Can we have an inner function with a bool to indicate whether to add the where clause or not, then just delegate these two derives to that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

Copy link
Member

Choose a reason for hiding this comment

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

Cool, r=me with that change.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 19, 2023
@compiler-errors compiler-errors force-pushed the hash-stable-simplify-rustc_type_ir branch 2 times, most recently from b9eab51 to efee297 Compare November 20, 2023 17:26
@compiler-errors
Copy link
Member Author

compiler-errors commented Nov 20, 2023

@bors r=jackh726

Rebased, unified all the HashStable implementations, and made sure it continues to build with/without feature = "nightly".

@bors
Copy link
Contributor

bors commented Nov 20, 2023

📌 Commit efee297 has been approved by jackh726

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 20, 2023
@bors
Copy link
Contributor

bors commented Nov 21, 2023

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout hash-stable-simplify-rustc_type_ir (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self hash-stable-simplify-rustc_type_ir --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging compiler/rustc_type_ir/src/ty_kind.rs
CONFLICT (content): Merge conflict in compiler/rustc_type_ir/src/ty_kind.rs
Auto-merging compiler/rustc_type_ir/src/const_kind.rs
CONFLICT (content): Merge conflict in compiler/rustc_type_ir/src/const_kind.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 21, 2023
@bors
Copy link
Contributor

bors commented Nov 21, 2023

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

@compiler-errors compiler-errors force-pushed the hash-stable-simplify-rustc_type_ir branch from efee297 to c9143ea Compare November 21, 2023 05:53
@compiler-errors
Copy link
Member Author

@bors r=jackh726

@bors
Copy link
Contributor

bors commented Nov 21, 2023

📌 Commit c9143ea has been approved by jackh726

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 21, 2023
@bors
Copy link
Contributor

bors commented Nov 21, 2023

⌛ Testing commit c9143ea with merge 7bd385d...

@bors
Copy link
Contributor

bors commented Nov 21, 2023

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing 7bd385d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 21, 2023
@bors bors merged commit 7bd385d into rust-lang:master Nov 21, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 21, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 22, 2023
…, r=jackh726

Uplift `CanonicalVarInfo` and friends into `rustc_type_ir`

Depends on rust-lang#117580 and rust-lang#117578

Uplift `CanonicalVarInfo` and friends into `rustc_type_ir` so they can be consumed by an interner-agnostic `Canonicalizer` implementation for the new trait solver ❤️

r? `@ghost`
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7bd385d): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.7%, -2.1%] 2
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 674.399s -> 674.8s (0.06%)
Artifact size: 313.75 MiB -> 313.76 MiB (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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.

8 participants