@@ -631,6 +631,34 @@ void swift::conformToCxxSetIfNeeded(ClangImporter::Implementation &impl,
631631 impl.addSynthesizedTypealias (decl, ctx.getIdentifier (" InsertionResult" ),
632632 insert->getResultInterfaceType ());
633633 impl.addSynthesizedProtocolAttrs (decl, {KnownProtocolKind::CxxSet});
634+
635+ // If this isn't a std::multiset, try to also synthesize the conformance to
636+ // CxxUniqueSet.
637+ if (!isStdDecl (clangDecl, {" set" , " unordered_set" }))
638+ return ;
639+
640+ ProtocolDecl *cxxIteratorProto =
641+ ctx.getProtocol (KnownProtocolKind::UnsafeCxxInputIterator);
642+ if (!cxxIteratorProto)
643+ return ;
644+
645+ auto rawMutableIteratorType =
646+ lookupDirectSingleWithoutExtensions<TypeAliasDecl>(
647+ decl, ctx.getIdentifier (" iterator" ));
648+ if (!rawMutableIteratorType)
649+ return ;
650+
651+ auto rawMutableIteratorTy = rawMutableIteratorType->getUnderlyingType ();
652+ // Check if RawMutableIterator conforms to UnsafeCxxInputIterator.
653+ ModuleDecl *module = decl->getModuleContext ();
654+ auto rawIteratorConformanceRef =
655+ module ->lookupConformance (rawMutableIteratorTy, cxxIteratorProto);
656+ if (!isConcreteAndValid (rawIteratorConformanceRef, module ))
657+ return ;
658+
659+ impl.addSynthesizedTypealias (decl, ctx.getIdentifier (" RawMutableIterator" ),
660+ rawMutableIteratorTy);
661+ impl.addSynthesizedProtocolAttrs (decl, {KnownProtocolKind::CxxUniqueSet});
634662}
635663
636664void swift::conformToCxxPairIfNeeded (ClangImporter::Implementation &impl,
0 commit comments