Skip to content

Commit 0f1b082

Browse files
authored
Merge pull request swiftlang#67519 from kavon/more-moveonly-diags
noncopyable diagnostics fix to correct error message wording
2 parents b9fef33 + da4951b commit 0f1b082

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ void DiagnosticEmitter::emitObjectDiagnosticsForPartialApplyUses(
547547
static bool isClosureCapture(MarkMustCheckInst *markedValue) {
548548
SILValue val = markedValue->getOperand();
549549

550+
// Sometimes we've mark-must-check'd a begin_access.
551+
val = stripAccessMarkers(val);
552+
550553
// look past any project-box
551554
if (auto *pbi = dyn_cast<ProjectBoxInst>(val))
552555
val = pbi->getOperand();

test/SILOptimizer/moveonly_addresschecker_diagnostics.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,6 +3862,22 @@ func blackHoleKlassTestCase2(_ k: consuming Klass) {
38623862
// expected-note @-1 {{consumed again here}}
38633863
}
38643864

3865+
// rdar://109908383
3866+
struct NonCopyableStruct: ~Copyable {}
3867+
var globFn: () -> () = {}
3868+
func forceEscaping(_ esc: @escaping () -> ()) {
3869+
globFn = esc
3870+
}
3871+
func closureDiagnosticsSimple() {
3872+
var s = NonCopyableStruct()
3873+
let f = {
3874+
_ = consume s // expected-error {{missing reinitialization of closure capture 's' after consume}} // expected-note {{consumed here}}
3875+
s = NonCopyableStruct()
3876+
}
3877+
forceEscaping(f)
3878+
f()
3879+
}
3880+
38653881
///////////////////////////////////////
38663882
// Copyable Type in a Move Only Type //
38673883
///////////////////////////////////////

0 commit comments

Comments
 (0)