mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Allow non-ephemeral diag to refer to argument labels
Use getArgDescription to improve the diagnostic for invalid temporary pointer conversions.
This commit is contained in:
@@ -5680,13 +5680,16 @@ bool NonEphemeralConversionFailure::diagnoseAsError() {
|
||||
return true;
|
||||
|
||||
// Otherwise, emit a more general diagnostic.
|
||||
SmallString<8> scratch;
|
||||
auto argDesc = getArgDescription(scratch);
|
||||
|
||||
auto *argExpr = getArgExpr();
|
||||
if (isa<InOutExpr>(argExpr)) {
|
||||
auto diagID = DowngradeToWarning
|
||||
? diag::cannot_use_inout_non_ephemeral_warning
|
||||
: diag::cannot_use_inout_non_ephemeral;
|
||||
|
||||
emitDiagnostic(argExpr->getLoc(), diagID, getArgPosition(), getCallee(),
|
||||
emitDiagnostic(argExpr->getLoc(), diagID, argDesc, getCallee(),
|
||||
getCalleeFullName())
|
||||
.highlight(argExpr->getSourceRange());
|
||||
} else {
|
||||
@@ -5694,7 +5697,7 @@ bool NonEphemeralConversionFailure::diagnoseAsError() {
|
||||
? diag::cannot_pass_type_to_non_ephemeral_warning
|
||||
: diag::cannot_pass_type_to_non_ephemeral;
|
||||
|
||||
emitDiagnostic(argExpr->getLoc(), diagID, getArgType(), getArgPosition(),
|
||||
emitDiagnostic(argExpr->getLoc(), diagID, getArgType(), argDesc,
|
||||
getCallee(), getCalleeFullName())
|
||||
.highlight(argExpr->getSourceRange());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user