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 test for bad cast with deferred projection equality #108287

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

compiler-errors
Copy link
Member

  1. Unification during coercion (Coerce::unify) needs to consider deferred projection obligations (at least pass over them with predicate_may_hold or something, to disqualify any totally wrong unifications) -- otherwise, we'll shallowly consider <u8 as Add>::Output and char as coercible during FnCtxt::try_coerce, which will fail later when the nested obligations are registered and processed.

  2. Cast checking needs to be able to structurally normalize types so it sees u8 instead of <u8 as Add>::Output. Otherwise it'll always consider the latter as part of a non-primitive cast. Currently FnCtxt::normalize doesn't do anything useful here, interestingly.

I tried looking into both of these and it's not immediately clear where to refactor existing typeck code to fix this (at least the latter), but I'm gonna commit a test for it at least so we don't forget. This is one of the issues that's keeping us from building larger projects.

@compiler-errors compiler-errors added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Feb 20, 2023
@compiler-errors compiler-errors self-assigned this Feb 20, 2023
@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 Feb 20, 2023
@compiler-errors compiler-errors removed their assignment Feb 20, 2023
@compiler-errors
Copy link
Member Author

r? types

@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 23, 2023

📌 Commit eb1f9ba has been approved by spastorino

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 23, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 23, 2023
…t, r=spastorino

Add test for bad cast with deferred projection equality

1. Unification during coercion (`Coerce::unify`) needs to consider deferred projection obligations (at least pass over them with `predicate_may_hold` or something, to disqualify any totally wrong unifications) -- otherwise, we'll shallowly consider `<u8 as Add>::Output` and `char` as coercible during `FnCtxt::try_coerce`, which will fail later when the nested obligations are registered and processed.

2. Cast checking needs to be able to structurally normalize types so it sees `u8` instead of `<u8 as Add>::Output`. Otherwise it'll always consider the latter as part of a non-primitive cast. Currently `FnCtxt::normalize` doesn't do anything useful here, interestingly.

I tried looking into both of these and it's not immediately clear where to refactor existing typeck code to fix this (at least the latter), but I'm gonna commit a test for it at least so we don't forget. This is one of the issues that's keeping us from building larger projects.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 24, 2023
Rollup of 10 pull requests

Successful merges:

 - rust-lang#106541 (implement const iterator using `rustc_do_not_const_check`)
 - rust-lang#106918 (Rebuild BinaryHeap on unwind from retain)
 - rust-lang#106923 (Restore behavior when primary bundle is missing)
 - rust-lang#108169 (Make query keys `Copy`)
 - rust-lang#108287 (Add test for bad cast with deferred projection equality)
 - rust-lang#108370 (std: time: Avoid to use "was created" in elapsed() description)
 - rust-lang#108377 (Fix ICE in 'duplicate diagnostic item' diagnostic)
 - rust-lang#108388 (parser: provide better suggestions and errors on closures with braces missing)
 - rust-lang#108391 (Fix `is_terminal`'s handling of long paths on Windows.)
 - rust-lang#108401 (diagnostics: remove inconsistent English article "this" from E0107)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 251293e into rust-lang:master Feb 24, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 24, 2023
@compiler-errors compiler-errors deleted the new-solver-bad-cast branch August 11, 2023 20:08
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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants