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

remove TyS::same_type #93290

Merged
merged 1 commit into from
Feb 1, 2022
Merged

remove TyS::same_type #93290

merged 1 commit into from
Feb 1, 2022

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Jan 25, 2022

This function ignored regions and constants in adts, but didn't do so for references or any other types. cc #93148 (comment)

@rust-highfive
Copy link
Collaborator

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 25, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 25, 2022
@lcnr
Copy link
Contributor Author

lcnr commented Jan 25, 2022

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 25, 2022
@bors
Copy link
Contributor

bors commented Jan 25, 2022

⌛ Trying commit 59d14bf0136a0093c3678a664a2f30d876722e2b with merge 5102db108540f7012ca2dec4d07b61ac376df6ce...

@lcnr lcnr mentioned this pull request Jan 25, 2022
@bors
Copy link
Contributor

bors commented Jan 25, 2022

☀️ Try build successful - checks-actions
Build commit: 5102db108540f7012ca2dec4d07b61ac376df6ce (5102db108540f7012ca2dec4d07b61ac376df6ce)

@rust-timer
Copy link
Collaborator

Queued 5102db108540f7012ca2dec4d07b61ac376df6ce with parent e7825f2, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5102db108540f7012ca2dec4d07b61ac376df6ce): comparison url.

Summary: This benchmark run did not return any relevant changes.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 25, 2022
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

This overall seems good to me -- definitely a confusing function that seems likely to be at least partially wrong in many use cases.

It looks like the majority of the clippy users arose as a result of rust-lang/rust-clippy#5528, which seems like it's under the impression that this function was intentional -- but I admit I am not fully following the conversation there. Maybe worth considering whether we need to provide a lightweight alternative that does whatever clippy was going for? cc @phansch @flip1995

The uses in this PR seem like they are probably OK with the "full" equality proposed by this PR, but it's hard to be sure. I guess tests are passing (including Clippy tests), though. I think it'd be good to get another set of eyes on these changes (particularly those in Clippy) before merging -- maybe r? @jackh726

@@ -2833,7 +2833,7 @@ impl ClashingExternDeclarations {
return true;
}
let tcx = cx.tcx;
if a == b || rustc_middle::ty::TyS::same_type(a, b) {
if a == b {
// All nominally-same types are structurally same, too.
Copy link
Member

Choose a reason for hiding this comment

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

nit: "nominally" here is potentially confusing, maybe good to adjust this to say "literally the same type" or similar?

@camsteffen
Copy link
Contributor

I think for Clippy what we nearly always want is "equal ignoring regions". We sometimes use normalize_erasing_regions. Should we just use erase_regions_ty? We also have a same_types_and_consts util inspired by same_types. That should probably be removed or replaced with something named eq_erase_regions.

@jackh726
Copy link
Member

jackh726 commented Feb 1, 2022

I agree that this PR looks fine.

I didn't look much at the clippy changes - there's a lot of background there that I don't know what each of these instances are supposed to do.

I think there are maybe two ways to go forward with this: 1) Move this function into clippy itself, so there isn't a behavior change (then later that can be amended to an erasing regions version) 2) just land this; I would feel better getting a sign off from a clippy maintainer first. But as @Mark-Simulacrum said, the tests are passing so this is probably fine

If you go with option 1, then r=me with that changed. If you with option 2, r=me with clippy maintainer signoff.

it ignored regions and constants in adts,
but didn't do so for references or any other types.
This seemed quite weird
@lcnr
Copy link
Contributor Author

lcnr commented Feb 1, 2022

I think for Clippy what we nearly always want is "equal ignoring regions". We sometimes use normalize_erasing_regions. Should we just use erase_regions_ty? We also have a same_types_and_consts util inspired by same_types. That should probably be removed or replaced with something named eq_erase_regions.

Yeah, using normalize_erasing_regions and then == seems good to me 👍

2, r=me with clippy maintainer signoff.

I am interpreting the ":+1:" by @flip1995 on #93290 (comment) as approval 😆 feel free to r- in case there are still some questions/issues here.

@bors r=@jackh726 rollup

@bors
Copy link
Contributor

bors commented Feb 1, 2022

📌 Commit 7ebd48d has been approved by jackh726

@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 Feb 1, 2022
@flip1995
Copy link
Member

flip1995 commented Feb 1, 2022

I am interpreting the "+1" by @flip1995 on #93290 (comment) as approval

Yes. Since there are no test changes in Clippy, it doesn't seem like this introduced any regressions in Clippy. With "trivial" changes like this I usually just leave my 👍 and unsubscribe from the PR 😄

I think for Clippy what we nearly always want is "equal ignoring regions". We sometimes use normalize_erasing_regions. Should we just use erase_regions_ty? We also have a same_types_and_consts util inspired by same_types. That should probably be removed or replaced with something named eq_erase_regions.

This is a good question, to which I don't have the answer to. But I don't think this is something that should block this PR.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 1, 2022
remove `TyS::same_type`

This function ignored regions and constants in adts, but didn't do so for references or any other types. cc rust-lang#93148 (comment)
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2022
…askrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#86374 (Enable combining `+crt-static` and `relocation-model=pic` on `x86_64-unknown-linux-gnu`)
 - rust-lang#91828 (Implement `RawWaker` and `Waker` getters for underlying pointers)
 - rust-lang#92021 (Eliminate duplicate codes of is_single_fp_element)
 - rust-lang#92584 (add rustc lint, warning when iterating over hashmaps 2)
 - rust-lang#93267 (implement a lint for suspicious auto trait impls)
 - rust-lang#93290 (remove `TyS::same_type`)
 - rust-lang#93436 (Update compiler_builtins to fix duplicate symbols in `armv7-linux-androideabi` rlib)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 724ce37 into rust-lang:master Feb 1, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 1, 2022
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 10, 2022
remove `TyS::same_type`

This function ignored regions and constants in adts, but didn't do so for references or any other types. cc rust-lang#93148 (comment)
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.

None yet

9 participants