{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreia5l2irwlisgzwmtfkxu3wjr5jfja6diqjinx26caqfbogiaegqie",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3moo2oqwce572"
},
"path": "/t/err-automatic-hint-cold-path/24404#post_2",
"publishedAt": "2026-06-19T18:08:34.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"Result::branch"
],
"textContent": "It's not obvious to me that this is the right thing for the standard library to do.\n\nNotably, things like `u32::from_str` it's not obvious that the `Err` being cold is necessarily the right choice. And adding anything in `?` is at risk of a pretty bad compilation-time hit. (IIRC serde isn't using `?` because its generality and `From` made it materially slower to compile, even if it optimized away.)\n\nSo overall, I generally think that leaving this kind of thing to PGO is the better choice.\n\nI definitely don't think doing it for `Option` would be good, because things like `try { x?.foo() }` being used on stuff that happens to be `None` is pretty common when it's used as \"this property/hook/etc really is optional\". _Maybe_ it'd work in the `Err` arm for Result::branch? But that'd also make `try { x? }` no longer a no-op, which has its own consequences. You could always try making a PR for it and see what happens, though since the compiler uses PGO I doubt it'll show any improvement in the compiler perf suite.",
"title": "Err automatic hint::cold_path?"
}