Skip to content

Conversation

@scottmcm
Copy link
Member

@scottmcm scottmcm commented Nov 9, 2025

As discussed in rust-lang/rfcs#3721 (comment), update the try in nightly to match the RFC as a way to experiment.

This addresses the following unresolved issue from #31436

Address issues with type inference (try { expr? }? currently requires an explicit type annotation somewhere).

@rustbot rustbot added O-unix Operating system: Unix-like 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
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

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the experiment-new-try-block-v3 branch from 88085e3 to cfbecaf Compare November 9, 2025 05:03
@scottmcm scottmcm force-pushed the experiment-new-try-block-v3 branch from cfbecaf to 86c3ba7 Compare November 9, 2025 12:19
@rustbot
Copy link
Collaborator

rustbot commented Nov 9, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@scottmcm scottmcm force-pushed the experiment-new-try-block-v3 branch from 8b90701 to cc7f844 Compare November 12, 2025 07:12
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 12, 2025

bb3: {
_0 = <Option<Infallible> as Residual<u32>>::into_try_type(const Option::<Infallible>::None) -> [return: bb4, unwind unreachable];
_0 = <Option<u32> as FromResidual<Option<Infallible>>>::from_residual(const Option::<Infallible>::None) -> [return: bb4, unwind unreachable];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the rustc_force_inline this is no longer different, as it's always MIR-inlined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or maybe not because rustc_force_inline doesn't work in CI #148915

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does in work locally but not on CI? Very strange.
I'd expect this error to happen because residual_into_try_type is not marked as reachable from other crates for some reason (I thought lang items were always assumed to be reachable). What happens if it's publicly reexported?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it all built just fine locally, though admittedly I didn't run all the tests so I might have missed something.

Making it exported-but-unstable is a good idea; I'll give that a shot and see! Thanks.

@scottmcm scottmcm 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 Nov 13, 2025
@rust-log-analyzer
Copy link
Collaborator

The job pr-check-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] rustc_demangle test:false 0.697
error: `ops::try_trait::residual_into_try_type` could not be inlined into `Box::<T>::try_map` but is required to be inlined
   --> library/alloc/src/boxed.rs:462:21
    |
462 |                     f(value)?,
    |                     ^^^^^^^^^ ...`ops::try_trait::residual_into_try_type` called here
    |
    = note: could not be inlined due to: implementation limitation -- MIR unavailable

error: `ops::try_trait::residual_into_try_type` could not be inlined into `Box::<T>::try_map` but is required to be inlined
   --> library/alloc/src/boxed.rs:466:28
    |
466 |             try { Box::new(f(*this)?) }
    |                            ^^^^^^^^^ ...`ops::try_trait::residual_into_try_type` called here
    |
    = note: could not be inlined due to: implementation limitation -- MIR unavailable

error: `ops::try_trait::residual_into_try_type` could not be inlined into `Rc::<T>::try_map` but is required to be inlined
   --> library/alloc/src/rc.rs:728:27
    |
728 |             try { Rc::new(f(&*this)?) }
    |                           ^^^^^^^^^^ ...`ops::try_trait::residual_into_try_type` called here
    |
    = note: could not be inlined due to: implementation limitation -- MIR unavailable

error: `ops::try_trait::residual_into_try_type` could not be inlined into `UniqueRc::<T>::try_map` but is required to be inlined
    --> library/alloc/src/rc.rs:4172:33
     |
4172 |             try { UniqueRc::new(f(UniqueRc::unwrap(this))?) }
     |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...`ops::try_trait::residual_into_try_type` called here
     |
     = note: could not be inlined due to: implementation limitation -- MIR unavailable

error: `ops::try_trait::residual_into_try_type` could not be inlined into `Arc::<T>::try_map` but is required to be inlined
   --> library/alloc/src/sync.rs:741:28
    |
741 |             try { Arc::new(f(&*this)?) }
    |                            ^^^^^^^^^^ ...`ops::try_trait::residual_into_try_type` called here
    |
    = note: could not be inlined due to: implementation limitation -- MIR unavailable

error: `ops::try_trait::residual_into_try_type` could not be inlined into `UniqueArc::<T>::try_map` but is required to be inlined
    --> library/alloc/src/sync.rs:4586:34
     |
4586 |             try { UniqueArc::new(f(UniqueArc::unwrap(this))?) }
     |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...`ops::try_trait::residual_into_try_type` called here
     |
     = note: could not be inlined due to: implementation limitation -- MIR unavailable

[RUSTC-TIMING] alloc test:false 5.510
error: could not compile `alloc` (lib) due to 6 previous errors

@petrochenkov
Copy link
Contributor

error: ops::try_trait::residual_into_try_type could not be inlined into Box::<T>::try_map but is required to be inlined
note: could not be inlined due to: implementation limitation -- MIR unavailable

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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