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

emit ConstEquate in TypeRelating<D> #107434

Merged
merged 1 commit into from
Feb 5, 2023
Merged

Conversation

BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Jan 29, 2023

emitting ConstEquate during mir typeck is useful since it can help catch bugs in hir typeck incase our impl of ConstEquate is wrong.

doing this did actually catch a bug, when relating Expr::Call we == the types of all the argument consts which spuriously returns false if the type contains const projections/aliases which causes us to fall through to the expected_found error arm.
Generally its an ICE if the Const's Tys arent equal but ConstKind::Expr is kind of special since they are sort of like const items that are const CALL<F: const Fn(...), const N: F> though we dont actually explicitly represent the F type param explicitly in Expr::Call so I just made us relate the Const's ty field to avoid getting ICEs from the tests I added and the following existing test:

// tests/ui/const-generics/generic_const_exprs/different-fn.rs
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

use std::mem::size_of;
use std::marker::PhantomData;

struct Foo<T>(PhantomData<T>);

fn test<T>() -> [u8; size_of::<T>()] {
    [0; size_of::<Foo<T>>()]
    //~^ ERROR unconstrained generic constant
    //~| ERROR mismatched types
}

fn main() {
    test::<u32>();
}

which has us relate two ConstKind::Value one for the fn item of size_of::<Foo<T>> and one for the fn item of size_of::<T>(), these only differ by their Ty and if we don't relate the Ty we'll end up getting an ICE from the checks that ensure the ty fields always match.

In theory Expr::UnOp has the same problem so I added a call to relate for the ty's, although I was unable to create a repro test.

@rustbot
Copy link
Collaborator

rustbot commented Jan 29, 2023

r? @lcnr

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

@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 Jan 29, 2023
@BoxyUwU BoxyUwU added the A-const-generics Area: const generics (parameters and arguments) label Jan 29, 2023
@BoxyUwU
Copy link
Member Author

BoxyUwU commented Jan 29, 2023

r? compiler-contributors

@compiler-errors
Copy link
Member

r? @compiler-errors @bors r+

yeet

@bors
Copy link
Contributor

bors commented Feb 2, 2023

📌 Commit f2c24afe0fd510f8c592e737a5c06a42c6109ca1 has been approved by compiler-errors

It is now in the queue for this repository.

@rustbot rustbot assigned compiler-errors and unassigned bjorn3 Feb 2, 2023
@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 2, 2023
@bors
Copy link
Contributor

bors commented Feb 3, 2023

⌛ Testing commit f2c24afe0fd510f8c592e737a5c06a42c6109ca1 with merge 90c1e6c689773c8d55031328f01ca276da9d157d...

@bors
Copy link
Contributor

bors commented Feb 3, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 3, 2023
@compiler-errors
Copy link
Member

@bors retry spurious

@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 3, 2023
@bors
Copy link
Contributor

bors commented Feb 4, 2023

⌛ Testing commit f2c24afe0fd510f8c592e737a5c06a42c6109ca1 with merge c907399ed72f3a206817be8ac1085d06741f7c78...

@bors
Copy link
Contributor

bors commented Feb 4, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 4, 2023
@BoxyUwU
Copy link
Member Author

BoxyUwU commented Feb 4, 2023

@bors retry

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Feb 4, 2023

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Feb 4, 2023

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: Do not deaggregate MIR #107267

@bors
Copy link
Contributor

bors commented Feb 4, 2023

📌 Commit f2c24afe0fd510f8c592e737a5c06a42c6109ca1 has been approved by compiler-errors

It is now in the queue for this repository.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Feb 4, 2023

@bors retry

@bors
Copy link
Contributor

bors commented Feb 5, 2023

⌛ Testing commit f2c24afe0fd510f8c592e737a5c06a42c6109ca1 with merge 6ebe0f75c272d590ed38cbb30d1cde018f65c95b...

@bors
Copy link
Contributor

bors commented Feb 5, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 5, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Feb 5, 2023

@bors r=compiler-errors

maybe rebasing will fix everything magically

@bors
Copy link
Contributor

bors commented Feb 5, 2023

📌 Commit d85d906 has been approved by compiler-errors

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 Feb 5, 2023
@bors
Copy link
Contributor

bors commented Feb 5, 2023

⌛ Testing commit d85d906 with merge 2a6ff72...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 5, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 2a6ff72 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 5, 2023
@bors bors merged commit 2a6ff72 into rust-lang:master Feb 5, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 5, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2a6ff72): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.3%] 2
Improvements ✅
(secondary)
-0.8% [-1.3%, -0.2%] 10
All ❌✅ (primary) -0.4% [-0.4%, -0.3%] 2

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)
2.6% [2.0%, 2.8%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.1% [-2.3%, -1.7%] 3
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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [2.4%, 2.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

@rust-log-analyzer

This comment has been minimized.

@michael-swan
Copy link

This introduces an ICE. See #107898

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) 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.

9 participants