Skip to content

Allow comparing Boxes with different allocators - #112628

Merged
bors merged 1 commit into
rust-lang:masterfrom
gootorov:box_alloc_partialeq
Jun 28, 2023
Merged

Allow comparing Boxes with different allocators#112628
bors merged 1 commit into
rust-lang:masterfrom
gootorov:box_alloc_partialeq

Conversation

@gootorov

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

r? @joshtriplett

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

@rustbotrustbot 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
Comment threadlibrary/alloc/tests/boxed.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@gootorov
gootorovforce-pushed the box_alloc_partialeq branch from 9598a11 to 5ca1a6aCompareJune 14, 2023 17:37
Comment threadlibrary/alloc/src/boxed.rs Outdated
@gootorov
gootorovforce-pushed the box_alloc_partialeq branch from 3d3c6cd to 001b081CompareJune 18, 2023 03:22
@gootorov

Copy link
Copy Markdown
ContributorAuthor

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

@joshtriplett

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented Jun 27, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit 001b081 has been approved by joshtriplett

It is now in the queue for this repository.

@borsbors 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:masterJun 28, 2023
@rustbotrustbot 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

smoelius commented Jul 2, 2023

Copy link
Copy Markdown
Contributor

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

#[derive(Debug,PartialEq)]structExpr;#[allow(dead_code)]fnfrom_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 trailofbits/necessist that referenced this pull request Jul 3, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant 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

@gootorov@rustbot@rust-log-analyzer@joshtriplett@bors@smoelius@Noratrieb