{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreifptyd43op6bggzidqcrowxnm52ge3smju2cxwz2k2jfyxmcqdb6u",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mhmjsjnqen62"
},
"path": "/t/idea-borrowck-transparent-function-calls/24103#post_15",
"publishedAt": "2026-03-20T17:47:42.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=b3fc0ce0ebc6c302bd2befd4f35b8522"
],
"textContent": "josh:\n\n> we could support writing something like `&mut{_} self` to get a compiler error with a suggestion\n\nI was kinda hoping we could write nothing, actually, and have it get filled in.\n\nLike today (example inspired from the other thread) if you have https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=b3fc0ce0ebc6c302bd2befd4f35b8522\n\n\n fn foo(a: &i32, b: &i32, c: &i32) -> &i32 {\n if *c > 0 { a } else { b }\n }\n\n\nThen the error you get is\n\n\n = help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `a`, `b`, or `c`\n help: consider introducing a named lifetime parameter\n |\n 1 | fn foo<'a>(a: &'a i32, b: &'a i32, c: &'a i32) -> &'a i32 {\n | ++++ ++ ++ ++ ++\n\n\nbut ideally we could use the MIR borrow-check results to suggest\n\n\n fn foo<'a>(a: &'a i32, b: &'a i32, c: &i32) -> &'a i32 {\n\n\nwith a note that that's what the body is currently doing.\n\n* * *\n\nThough having typed all that I guess that's largely irrelevant to the \"view type\" part, which yeah, might need a way to say \"intentionally wrong; please fix\".\n\nThat might just be an empty list, though. `&mut{} self` is probably not actually going to compile, and the error message can tell you which things to put in there that the current implementation needs, with the structured suggestion.",
"title": "Idea: Borrowck Transparent Function Calls"
}