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 fmt::Display for TIR structures without requiring Env #882

Merged
merged 7 commits into from
Jul 5, 2023

Conversation

kontheocharis
Copy link
Collaborator

Pretty self explanatory. Closes #816. There is only one problem: when ModDefs are printed, ones which correspond to source files, the formatter needs access to the SourceMap in order to resolve the path from the SourceId. However, the map is not static, and since the Display implementations no longer have access to Env, this is a problem. @feds01 thoughts on how to deal with this? One option is to make the SourceMap static, not sure if it is a good idea or not.

@kontheocharis kontheocharis added the type-system Issues related with typechecking sub-system. label Jun 29, 2023
@kontheocharis kontheocharis self-assigned this Jun 29, 2023
feds01
feds01 previously approved these changes Jun 29, 2023
Comment on lines 855 to 857
let LayoutShape::Aggregate { fields: ref offsets, .. } = variant_layout.shape
else {
panic!("layout of enum variant is non-aggregate");
Copy link
Contributor

Choose a reason for hiding this comment

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

this is pretty weird formatting, is this from rustfmt?

Copy link
Collaborator Author

@kontheocharis kontheocharis Jul 5, 2023

Choose a reason for hiding this comment

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

Yes. I think that's the intended formatting.

@@ -53,7 +53,7 @@ impl AstVisitor for AstTreeGenerator {
"entry",
name.map(|t| TreeNode::branch("name", vec![t]))
.into_iter()
.chain(ty.map(|t| TreeNode::branch("type", vec![t])).into_iter())
.chain(ty.map(|t| TreeNode::branch("type", vec![t])))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that changes like this should be in their own PR in the future. If there is some PR unrelated fmt or clippy change, then I think the policy should be to make a separate PR for it and merge it before your main PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've made #883 to fix all the clippy and fmt issues, maybe we should merge this first and then rebase?

Copy link
Collaborator Author

@kontheocharis kontheocharis Jul 5, 2023

Choose a reason for hiding this comment

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

I think that changes like this should be in their own PR in the future. If there is some PR unrelated fmt or clippy change, then I think the policy should be to make a separate PR for it and merge it before your main PR.

Yeah sounds reasonable but sometimes can be really annoying.. I think we don't have to be so dogmatic (not yet at least..) On second thought maybe it's worth it now that the compiler is getting so big.

@feds01
Copy link
Contributor

feds01 commented Jul 3, 2023

In regards to clippy barfing, there seems to be some work being done to fix it (rust-lang/rust-clippy#11098). For now, we can disable the unnecessary_literal_unwrap lint for hash-codegen-llvm until the issue is fixed. This should be done probably in a separate PR with the other fmt and clippy changes.

@y21
Copy link

y21 commented Jul 3, 2023

👋 coming from clippy. Interesting ICE you found. Just wanted to say that the linked PR doesn't fix this, but I've created an issue with a small repro: rust-lang/rust-clippy#11099

@feds01
Copy link
Contributor

feds01 commented Jul 4, 2023

Also, this PR doesn't update tc_panic! macros in hash_semantics::panic. Should they be removed or moved elsewhere since they aren't really being used?

@kontheocharis
Copy link
Collaborator Author

kontheocharis commented Jul 5, 2023

I wonder if this issue is also relevant to the clippy crash rust-lang/rust-clippy#11064. Different line number but same rule.

@kontheocharis
Copy link
Collaborator Author

Also, this PR doesn't update tc_panic! macros in hash_semantics::panic. Should they be removed or moved elsewhere since they aren't really being used?

Will tackle this in this PR and then we can merge?

@feds01
Copy link
Contributor

feds01 commented Jul 5, 2023

Rebase and we're good to go

@kontheocharis kontheocharis merged commit 4c91a19 into main Jul 5, 2023
@kontheocharis kontheocharis deleted the stores-display branch July 5, 2023 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-system Issues related with typechecking sub-system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider turning some stores into statics rather than passing them around within contexts
3 participants