Skip to content

Commit 44df09e

Browse files
authored
Merge pull request #65156 from gottesmm/pr-924cb03a9a1df41bcebcfd08f8d25d5a1551ec88
[move-only] Change the destructure through deinit error to lookup the deinit at the AST level rather than the SIL level.
2 parents 2c084d8 + 8118240 commit 44df09e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ checkForDestructureThroughDeinit(MarkMustCheckInst *rootAddress, Operand *use,
13331333
// cannot contain non-copyable types and that our parent root type must be
13341334
// an enum, tuple, or struct.
13351335
if (auto *nom = iterType.getNominalOrBoundGenericNominal()) {
1336-
if (mod.lookUpMoveOnlyDeinitFunction(nom)) {
1336+
if (nom->getValueTypeDestructor()) {
13371337
// If we find one, emit an error since we are going to have to extract
13381338
// through the deinit. Emit a nice error saying what it is. Since we
13391339
// are emitting an error, we do a bit more work and construct the

lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,4 +774,6 @@ void DiagnosticEmitter::emitCannotDestructureDeinitNominalError(
774774
}
775775
diagnose(astContext, consumingUser,
776776
diag::sil_moveonlychecker_consuming_use_here);
777+
astContext.Diags.diagnose(deinitedNominal->getValueTypeDestructor(),
778+
diag::sil_moveonlychecker_deinit_here);
777779
}

test/SILOptimizer/moveonly_addresschecker_destructure_through_deinit_diagnostics.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ struct DeinitStruct {
5959
var fifth: MoveOnlyKlass
6060

6161
deinit {}
62+
// expected-note @-1 {{deinit declared here}}
63+
// expected-note @-2 {{deinit declared here}}
64+
// expected-note @-3 {{deinit declared here}}
65+
// expected-note @-4 {{deinit declared here}}
66+
// expected-note @-5 {{deinit declared here}}
67+
// expected-note @-6 {{deinit declared here}}
68+
// expected-note @-7 {{deinit declared here}}
69+
// expected-note @-8 {{deinit declared here}}
70+
// expected-note @-9 {{deinit declared here}}
71+
// expected-note @-10 {{deinit declared here}}
6272
}
6373

6474
func testConsumeCopyable(_ x: consuming DeinitStruct) {

0 commit comments

Comments
 (0)