Skip to content

Commit b2988f6

Browse files
committed
[diags][cxx-interop] Update diagnostic for 'begin' to suggest using a for-loop instead.
Does not fix the fix-it. The current fix it will be left as a stop-gap solution and we can hopefully update this fix it in the near future to actually plop in a for loop (too much work for this PR though).
1 parent e4a0b9e commit b2988f6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ NOTE(mark_safe_to_import, none, "annotate method '%0' with 'SWIFT_RETURNS_INDEPE
195195
NOTE(at_to_subscript, none, "do you want to replace it with a call "
196196
"to the subscript operator?",
197197
())
198-
NOTE(get_swift_iterator, none, "do you want to make a Swift iterator instead?",
198+
NOTE(use_collection_apis, none, "do you want to use a for-loop instead?",
199199
())
200200
NOTE(replace_with_nil, none, "do you want to compare against 'nil' instead?",
201201
())

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3877,7 +3877,7 @@ void MissingMemberFailure::diagnoseUnsafeCxxMethod(SourceLoc loc,
38773877
if (conformsToRACollection(baseType)) {
38783878
ctx.Diags.diagnose(loc, diag::iterator_method_unavailable,
38793879
name.getBaseIdentifier().str());
3880-
ctx.Diags.diagnose(loc, diag::get_swift_iterator)
3880+
ctx.Diags.diagnose(loc, diag::use_collection_apis)
38813881
.fixItReplaceChars(
38823882
loc, loc.getAdvancedLoc(name.getBaseIdentifier().str().size()),
38833883
"makeIterator");

test/Interop/Cxx/class/fixits-for-std-vector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import CxxStdlib
2222

2323
public func test(v: V) {
2424
// CHECK: note: C++ method 'begin' that returns an iterator is unavailable
25-
// CHECK: note: do you want to make a Swift iterator instead?
25+
// CHECK: note: do you want to use a for-loop instead?
2626
// CHECK: ^~~~~
2727
// CHECK: makeIterator
2828
_ = v.begin()

0 commit comments

Comments
 (0)