Enable conversions to value-or-ref to use value_of_initializer (#6309)

As a byproduct, the only test that exercised the "address of a temporary
object" diagnostic now trigers the "address of a non-reference
expression" diagnostic. We could restore it by using a type that doesn't
support `value_of_initializer`, but it seems better to remove the
diagnostic altogether: not only does it simplify the code, I'd also
argue "non-reference expression" is more accurate as a user-facing
description of the operand.
This commit is contained in:
Geoff Romer
2025-11-04 16:29:31 +00:00
committed by GitHub
parent 1324fad32b
commit 114ecda725
5 changed files with 17 additions and 29 deletions
@@ -53,7 +53,7 @@ fn AddressOfOperator() {
// CHECK:STDERR: ^
// CHECK:STDERR:
&(true and false);
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of a temporary object [AddrOfEphemeralRef]
// CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+4]]:3: error: cannot take the address of non-reference expression [AddrOfNonRef]
// CHECK:STDERR: &H().a;
// CHECK:STDERR: ^
// CHECK:STDERR: