Skip to content

WIP: smart pointer (try_)map #144420

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Qelxiros
Copy link
Contributor

@Qelxiros Qelxiros commented Jul 24, 2025

Tracking issue: #144419

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 24, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui/privacy/suggest-box-new.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/privacy/suggest-box-new.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/privacy/suggest-box-new" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap`
##[error]  --> /checkout/tests/ui/privacy/suggest-box-new.rs:14:13
   |
---
   |
LL -     let _ = std::collections::HashMap();
LL +     let _ = std::collections::HashMap::with_hasher(_);
   |
LL -     let _ = std::collections::HashMap();
LL +     let _ = std::collections::HashMap::with_capacity_and_hasher(_, _);
   |
help: consider using the `Default` trait
   |
LL |     let _ = <std::collections::HashMap as std::default::Default>::default();
   |             +                          ++++++++++++++++++++++++++++++++++

error[E0423]: cannot initialize a tuple struct which contains private fields
##[error]  --> /checkout/tests/ui/privacy/suggest-box-new.rs:8:19
   |
LL |         wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields
   |                   ^^^
   |
note: constructor is not visible here due to private fields
  --> /rustc/FAKE_PREFIX/library/alloc/src/boxed.rs:234:14
   |
   = note: private field
   |
   = note: private field
help: you might have meant to use an associated function to build this type
   |
LL -         wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields
LL -             wtf: None,
LL -             x: (),
LL -         })),
LL +         wtf: Some(Box::new(_)),
   |
LL -         wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields
LL -             wtf: None,
LL -             x: (),
LL -         })),
LL +         wtf: Some(Box::new_uninit()),
   |
LL -         wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields
LL -             wtf: None,
LL -             x: (),
LL -         })),
LL +         wtf: Some(Box::new_zeroed()),
   |
LL -         wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields
LL -             wtf: None,
LL -             x: (),
LL -         })),
LL +         wtf: Some(Box::new_in(_, _)),
   |
   = and 13 other candidates
help: consider using the `Default` trait
   |
LL -         wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields
LL +         wtf: Some(<Box as std::default::Default>::default()),
   |

error: cannot construct `HashMap<_, _, _>` with struct literal syntax due to private fields
##[error]  --> /checkout/tests/ui/privacy/suggest-box-new.rs:16:13
   |
---
   |
LL -     let _ = std::collections::HashMap {};
LL +     let _ = std::collections::HashMap::with_hasher(_);
   |
LL -     let _ = std::collections::HashMap {};
LL +     let _ = std::collections::HashMap::with_capacity_and_hasher(_, _);
   |
help: consider using the `Default` trait
   |
LL -     let _ = std::collections::HashMap {};
LL +     let _ = <std::collections::HashMap as std::default::Default>::default();

@Qelxiros Qelxiros marked this pull request as ready for review July 25, 2025 00:12
@rustbot
Copy link
Collaborator

rustbot commented Jul 25, 2025

r? @thomcc

rustbot has assigned @thomcc.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 25, 2025
@Qelxiros
Copy link
Contributor Author

As far as I can tell, the ICE here is because of the function signature of Box::try_map. The return type is equivalent to ChangeOutputType<...> from the ACP, but that definition is in core, so I implemented it manually here. However, when I add the same type alias to alloc, the ICE persists. Is there a workaround here that remains in the spirit of the ACP? Is this a known compiler bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants