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

Int and float inference variables are trivially copy #102695

Merged
merged 2 commits into from
Oct 14, 2022

Conversation

compiler-errors
Copy link
Member

Fixes #102645

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

r? @cjgillot

(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 Oct 5, 2022
@lcnr
Copy link
Contributor

lcnr commented Oct 6, 2022

r? @lcnr
r=me on the change

Though I don't like that this change fixes an ICE. This code shouldn't ICE without that change as well, as it feels like there's probably a bigger underlying issue here.

@rust-highfive rust-highfive assigned lcnr and unassigned cjgillot Oct 6, 2022
@compiler-errors
Copy link
Member Author

compiler-errors commented Oct 10, 2022

@lcnr, yeah, sorry, I forgot to comment on this.

There is a bigger underlying issue here, specifically using a raw type query on a type that hasn't been fully resolved. Ideally we'd be canonicalizing the types that we pass into this query and dealing with them more responsibly within a new infer ctxt, like we do when we check if a type is copy or sized.

Luckily, the only type of inference variables that can leak into the queries at that point are region variables, which are erased, and int/float inference variables, which are fixed by this ICE. Unresolved type variables don't make it this far into generators I think.

I'll leave a note near the ty.needs_drop call in any case.

@compiler-errors compiler-errors 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 Oct 10, 2022
@cjgillot
Copy link
Contributor

using a raw type query on a type that hasn't been fully resolved.

I wonder if we should just plainly disallow stable-hashing of inference variables. This would get rid of this hazard by a preemptive panic.

@lcnr
Copy link
Contributor

lcnr commented Oct 12, 2022

Luckily, the only type of inference variables that can leak into the queries at that point are region variables, which are erased, and int/float inference variables, which are fixed by this ICE. Unresolved type variables don't make it this far into generators I think.

surprising that int/float infer still exists here then, I feel like these also shouldn't appear during borrowck. Will look at this once I am back home next week.

Leaving a note there seems good enough for me 👍

@compiler-errors
Copy link
Member Author

I feel like these also shouldn't appear during borrowck.

this isn't during borrowck, this is in generator interior analysis during typeck, so I don't think we've done fallback on the integer variables at this point.

@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Oct 14, 2022

📌 Commit 42321b0 has been approved by lcnr

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 Oct 14, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 14, 2022
…ial-copy, r=lcnr

Int and float inference variables are trivially copy

Fixes rust-lang#102645
@bors
Copy link
Contributor

bors commented Oct 14, 2022

⌛ Testing commit 42321b0 with merge 3271760...

@bors
Copy link
Contributor

bors commented Oct 14, 2022

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 3271760 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 14, 2022
@bors bors merged commit 3271760 into rust-lang:master Oct 14, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 14, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3271760): 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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 1
All ❌✅ (primary) - - 0

Cycles

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.

mean1 range count2
Regressions ❌
(primary)
2.1% [2.1%, 2.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.2%, -2.2%] 1
Improvements ✅
(secondary)
-3.9% [-3.9%, -3.9%] 1
All ❌✅ (primary) -0.1% [-2.2%, 2.1%] 2

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 20, 2022
Deny hashing ty/re/ct inference variables

cc `@cjgillot` and rust-lang#102695 (comment)
r? `@lcnr`

best reviewed one commit at a time, mostly because the second commit that fixes `ClosureOutlivesRequirement` is mostly noise because of losing its `<'tcx>` lifetime parameter.
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Oct 21, 2022
Deny hashing ty/re/ct inference variables

cc `@cjgillot` and rust-lang/rust#102695 (comment)
r? `@lcnr`

best reviewed one commit at a time, mostly because the second commit that fixes `ClosureOutlivesRequirement` is mostly noise because of losing its `<'tcx>` lifetime parameter.
@compiler-errors compiler-errors deleted the int-and-float-trivial-copy branch November 2, 2022 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

ICE: index out of bounds: the len is 0 but the index is 0 -Zdrop-tracking, generators
7 participants