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

Allow comparing Boxes with different allocators #112628

Merged
merged 1 commit into from
Jun 28, 2023

Conversation

gootorov
Copy link
Contributor

Currently, comparing Boxes over different allocators is not allowed:

error[E0308]: mismatched types
  --> library/alloc/tests/boxed.rs:22:20
   |
22 |     assert_eq!(b1, b2);
   |                    ^^ expected `Box<{integer}, ConstAllocator>`, found `Box<{integer}, AnotherAllocator>`
   |
   = note: expected struct `Box<{integer}, ConstAllocator>`
              found struct `Box<{integer}, AnotherAllocator>`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `alloc` (test "collectionstests") due to previous error

This PR lifts this limitation

@rustbot
Copy link
Collaborator

rustbot commented Jun 14, 2023

r? @joshtriplett

(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-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 14, 2023
@rust-log-analyzer

This comment has been minimized.

@gootorov gootorov force-pushed the box_alloc_partialeq branch from 9598a11 to 5ca1a6a Compare June 14, 2023 17:37
@gootorov gootorov force-pushed the box_alloc_partialeq branch from 3d3c6cd to 001b081 Compare June 18, 2023 03:22
@gootorov
Copy link
Contributor Author

Corresponding ACP: rust-lang/libs-team#241

@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 27, 2023

📌 Commit 001b081 has been approved by joshtriplett

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 Jun 27, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 27, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#112207 (Add trustzone and virtualization target features for aarch32.)
 - rust-lang#112454 (Make compiletest aware of targets without dynamic linking)
 - rust-lang#112628 (Allow comparing `Box`es with different allocators)
 - rust-lang#112692 (Provide more context for `rustc +nightly -Zunstable-options` on stable)
 - rust-lang#112972 (Make `UnwindAction::Continue` explicit in MIR dump)
 - rust-lang#113020 (Add tests impl via obj unless denied)
 - rust-lang#113084 (Simplify some conditions)
 - rust-lang#113103 (Normalize types when applying uninhabited predicate.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 448d2a8 into rust-lang:master Jun 28, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 28, 2023
@gootorov gootorov deleted the box_alloc_partialeq branch June 28, 2023 06:55
@smoelius
Copy link
Contributor

smoelius commented Jul 2, 2023

This PR appears to have introduced a regression. The following program compiles before this PR, but not after:

#[derive(Debug, PartialEq)]
struct Expr;

#[allow(dead_code)]
fn from_exprs(exprs: Vec<Box<Expr>>) {
    debug_assert_ne!(exprs, vec![], "exprs must not be empty");
}

E.g.:

$ cargo clean && cargo +353dd71d73d build
   Compiling a v0.1.0 (/tmp/a)
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
$ cargo clean && cargo +448d2a84179 build
   Compiling a v0.1.0 (/tmp/a)
error[E0282]: type annotations needed
 --> src/lib.rs:6:5
  |
6 |     debug_assert_ne!(exprs, vec![], "exprs must not be empty");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: this error originates in the macro `$crate::assert_ne` which comes from the expansion of the macro `debug_assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0282`.
error: could not compile `a` (lib) due to previous error

I noticed this while trying to build swc_ecma_ast (which does not currently buiid with nightly):

error[E0282]: type annotations needed
   --> crates/swc_ecma_ast/src/expr.rs:210:9
    |
210 |         debug_assert_ne!(exprs, vec![], "exprs must not be empty");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
    |
    = note: this error originates in the macro `$crate::assert_ne` which comes from the expansion of the macro `debug_assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)

smoelius added a commit to smoelius/necessist that referenced this pull request Jul 2, 2023
smoelius added a commit to smoelius/necessist that referenced this pull request Jul 3, 2023
smoelius added a commit to trailofbits/necessist that referenced this pull request Jul 3, 2023
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-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants