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

std: add assert_equiv!() macro, and update StrBuf tests #14120

Closed
wants to merge 1 commit into from

Conversation

erickt
Copy link
Contributor

@erickt erickt commented May 12, 2014

This adds an assert_equiv!() macro that allows two items that are not of the same time, but implement the Equiv trait to see if they are equivalent. This simplifies comparing StrBuf and &str types. Along with this patch, it implements Equiv for StrBuf, and rewrites some of the tests to use assert_equiv!().

@alexcrichton
Copy link
Member

We ended up removing the semi-similar cousin assert_approx_eq awhile back. How far do we want to go with the assert_xxx macros?

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to reopen with a rebase!

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 13, 2023
internal: Revert castable expectation and simplify

Unfixes rust-lang/rust-analyzer#11571, the PR for that introduced some regressions (tried fixing them but doing what rustc does there specifically does not help, probably because something else affects it as well there)
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 7, 2023
Properly infer types with type casts

This PR reenables `Expectation::Castable` (previous attempt at rust-lang#14104, reverted by rust-lang#14120) and implements type cast checks, which enable us to infer a bit more.

Castable expectations are relatively weak -- they only influence the inference if we cannot infer the types by other means. Therefore, we need to defer possible type unification with the casted type until we type check all expressions of the body. This PR adds a struct and slots in `InferenceContext` for the deferred cast checks (c.f. [`CastCheck`] in `rustc_hir_typeck`).

I only implemented the bits that affect the inference result. It should be possible to return type adjustments for well-formed casts and report diagnostics for invalid casts, but I'm leaving them for future work for now.

Fixes rust-lang#11571
Fixes rust-lang#15246

[`CastCheck`]: https://github.com/rust-lang/rust/blob/da1d099f91ea387a2814a6244dd875a2048b486f/compiler/rustc_hir_typeck/src/cast.rs#L55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants