profile
viewpoint

Ask questionsDo NRVO when type of returned local does not match return type

#72205 will fail to fire for code such as the following:

fn foo(x: &mut i32) -> &i32 { x }

This is because, by the time we get to the RenameReturnPlace pass, the reborrow has been optimized away and we have MIR like:

_0: &i32 = _1: &mut i32

To merge these locals, we need to pick a type for the unified LocalDecl. However, I wasn't sure how or if codegen makes use of the types of locals, so for now #72205 just doesn't run if the locals have different type. We should come up with a solution here.

rust-lang/rust

Answer questions ecstatic-morse

Worth noting that an initial perf run of #72205 was a bit faster than the one for the version that was merged. This issue is one plausible explanation, although there was also an LLVM upgrade in between.

useful!

Related questions

Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 3
using 'cargo install xsv' on windows 10 triggers rustc internal error hot 2
under latest MinGW, cannot link with C code using stdout hot 2
Archive all nightlies hot 2
chain() make collect very slow hot 1
if/while Some(n) = &mut foo sugar will leak a temporary mutable borrow to current scope in particular situation hot 1
build an empty project failed (undefined reference to `__onexitbegin') hot 1
Invalid collision with TryFrom implementation? hot 1
Crater runs for Rust 1.38.0 hot 1
Spurious NaNs produced by trig functions with valid inputs on Windows GNU toolchains hot 1
Building LLVM with Clang fails hot 1
Internal compiler error: can't buffer lints after HIR lowering hot 1
E0373 help suggests `move async` but the correct syntax is `async move` hot 1
Tracking issue for `Option::contains` and `Result::contains` hot 1
async fn + rustfmt don't "just work" inside of RLS hot 1
source:https://uonfu.com/
Github User Rank List