Skip to content

Commit adcb92b

Browse files
authored
Merge pull request #71667 from kavon/ncgenerics-test-fixes-kavon-v15a
2 parents 905a655 + 08b71e0 commit adcb92b

34 files changed

+56
-59
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,6 @@ ERROR(serialization_target_too_new_repl,none,
869869
"deployment target of %0 %3: %4",
870870
(StringRef, llvm::VersionTuple, Identifier, llvm::VersionTuple,
871871
StringRef))
872-
ERROR(serialization_noncopyable_generics_mismatch,none,
873-
"module %0 was not compiled with NoncopyableGenerics",
874-
(Identifier))
875872

876873
ERROR(serialization_fatal,Fatal,
877874
"fatal error encountered while reading from module '%0'; "

include/swift/Serialization/Validation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ enum class Status {
8484
/// to build the client.
8585
SDKMismatch,
8686

87-
/// The module file was not built with support for NoncopyableGenerics,
88-
/// yet that is required to by this compiler.
89-
NotUsingNoncopyableGenerics,
87+
/// The module file was built with a different NoncopyableGenerics feature
88+
/// mode than the compiler loading it.
89+
NoncopyableGenericsMismatch,
9090
};
9191

9292
/// Returns the string for the Status enum.

lib/AST/Builtins.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ struct CollectGenericParams {
299299
// If it's an invertible protocol and NoncopyableGenerics is disabled
300300
// then skip the requirement.
301301
if (req.getProtocolDecl()->getInvertibleProtocolKind())
302-
if (!(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS ||
303-
SC.Context.LangOpts.hasFeature(Feature::NoncopyableGenerics)))
302+
if (!SC.Context.LangOpts.hasFeature(Feature::NoncopyableGenerics))
304303
return;
305304

306305
AddedRequirements.push_back(req);
@@ -736,8 +735,7 @@ namespace {
736735
// If it's an invertible protocol and NoncopyableGenerics is disabled
737736
// then skip the requirement.
738737
if (req.getProtocolDecl()->getInvertibleProtocolKind())
739-
if (!(SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS ||
740-
Context.LangOpts.hasFeature(Feature::NoncopyableGenerics)))
738+
if (!Context.LangOpts.hasFeature(Feature::NoncopyableGenerics))
741739
return;
742740

743741
addedRequirements.push_back(req);

lib/AST/GenericSignature.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,7 @@ Type GenericSignatureImpl::getUpperBound(Type type,
714714
// we didn't have a superclass or require AnyObject.
715715
InvertibleProtocolSet inverses;
716716

717-
if (SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS ||
718-
ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
717+
if (ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
719718
if (!superclass && !hasExplicitAnyObject) {
720719
for (auto ip : InvertibleProtocolSet::full()) {
721720
auto *kp = ctx.getProtocol(::getKnownProtocolKind(ip));
@@ -726,8 +725,7 @@ Type GenericSignatureImpl::getUpperBound(Type type,
726725
}
727726

728727
for (auto *proto : getRequiredProtocols(type)) {
729-
if (SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS ||
730-
ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
728+
if (ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
731729
// Don't add invertible protocols to the composition, because we recorded
732730
// their absence above.
733731
if (proto->getInvertibleProtocolKind())
@@ -1298,8 +1296,7 @@ void GenericSignatureImpl::getRequirementsWithInverses(
12981296
SmallVector<InverseRequirement, 2> &inverses) const {
12991297
auto &ctx = getASTContext();
13001298

1301-
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS &&
1302-
!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
1299+
if (!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
13031300
reqs.append(getRequirements().begin(), getRequirements().end());
13041301
return;
13051302
}
@@ -1342,8 +1339,7 @@ void RequirementSignature::getRequirementsWithInverses(
13421339
SmallVector<InverseRequirement, 2> &inverses) const {
13431340
auto &ctx = owner->getASTContext();
13441341

1345-
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS &&
1346-
!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
1342+
if (!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
13471343
reqs.append(getRequirements().begin(), getRequirements().end());
13481344
return;
13491345
}

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ struct ModuleRebuildInfo {
318318
return "compiled with a different version of the compiler";
319319
case Status::NotInOSSA:
320320
return "module was not built with OSSA";
321-
case Status::NotUsingNoncopyableGenerics:
322-
return "module was not built with NoncopyableGenerics";
321+
case Status::NoncopyableGenericsMismatch:
322+
return "module was not built with matching NoncopyableGenerics feature";
323323
case Status::MissingDependency:
324324
return "missing dependency";
325325
case Status::MissingUnderlyingModule:
@@ -869,7 +869,10 @@ class ModuleInterfaceLoaderImpl {
869869
loadMode == ModuleLoadingMode::PreferSerialized &&
870870
!version::isCurrentCompilerTagged() &&
871871
rebuildInfo.getOrInsertCandidateModule(adjacentMod).serializationStatus !=
872-
serialization::Status::SDKMismatch) {
872+
serialization::Status::SDKMismatch &&
873+
// FIXME(kavon): temporary while we bootstrap NoncopyableGenerics.
874+
rebuildInfo.getOrInsertCandidateModule(adjacentMod).serializationStatus !=
875+
serialization::Status::NoncopyableGenericsMismatch) {
873876
// Special-case here: If we're loading a .swiftmodule from the resource
874877
// dir adjacent to the compiler, defer to the serialized loader instead
875878
// of falling back. This is to support local development of Swift,
@@ -1933,7 +1936,13 @@ InterfaceSubContextDelegateImpl::getCacheHash(StringRef useInterfacePath,
19331936
//
19341937
// If OSSA modules are enabled, we use a separate namespace of modules to
19351938
// ensure that we compile all swift interface files with the option set.
1936-
unsigned(genericSubInvocation.getSILOptions().EnableOSSAModules));
1939+
unsigned(genericSubInvocation.getSILOptions().EnableOSSAModules),
1940+
1941+
// Whether or not NoncopyableGenerics are enabled, as that influences
1942+
// many things like generic signatures and conformances.
1943+
unsigned(genericSubInvocation.getLangOptions()
1944+
.hasFeature(Feature::NoncopyableGenerics))
1945+
);
19371946

19381947
return llvm::toString(llvm::APInt(64, H), 36, /*Signed=*/false);
19391948
}

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3985,7 +3985,7 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
39853985
return getTypeMatchAmbiguous();
39863986
}
39873987

3988-
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS) {
3988+
if (!getASTContext().LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
39893989
// move-only types (and their metatypes) cannot match with existential types.
39903990
if (type1->getMetatypeInstanceType()->isNoncopyable()) {
39913991
// tailor error message
@@ -8494,7 +8494,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
84948494

84958495
// FIXME: This is already handled by tuple conformance lookup path and
84968496
// should be removed once non-copyable generics are enabled by default.
8497-
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS) {
8497+
if (!getASTContext().LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
84988498
// Copyable is checked structurally, so for better performance, split apart
84998499
// this constraint into individual Copyable constraints on each tuple
85008500
// element.

lib/Serialization/ModuleFileSharedCore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ static ValidationInfo validateControlBlock(
426426
}
427427
case control_block::HAS_NONCOPYABLE_GENERICS: {
428428
auto hasNoncopyableGenerics = scratch[0];
429-
if (requiresNoncopyableGenerics && !hasNoncopyableGenerics)
430-
result.status = Status::NotUsingNoncopyableGenerics;
429+
if (requiresNoncopyableGenerics != hasNoncopyableGenerics)
430+
result.status = Status::NoncopyableGenericsMismatch;
431431
break;
432432
}
433433
default:
@@ -533,8 +533,8 @@ std::string serialization::StatusToString(Status S) {
533533
case Status::FormatTooNew: return "FormatTooNew";
534534
case Status::RevisionIncompatible: return "RevisionIncompatible";
535535
case Status::NotInOSSA: return "NotInOSSA";
536-
case Status::NotUsingNoncopyableGenerics:
537-
return "NotUsingNoncopyableGenerics";
536+
case Status::NoncopyableGenericsMismatch:
537+
return "NoncopyableGenericsMismatch";
538538
case Status::MissingDependency: return "MissingDependency";
539539
case Status::MissingUnderlyingModule: return "MissingUnderlyingModule";
540540
case Status::CircularDependency: return "CircularDependency";

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,10 +1064,8 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
10641064
Ctx.Diags.diagnose(diagLoc, diag::serialization_module_too_old, ModuleName,
10651065
moduleBufferID);
10661066
break;
1067-
case serialization::Status::NotUsingNoncopyableGenerics:
1068-
Ctx.Diags.diagnose(diagLoc,
1069-
diag::serialization_noncopyable_generics_mismatch,
1070-
ModuleName);
1067+
case serialization::Status::NoncopyableGenericsMismatch:
1068+
// Ignore; the module should get rebuilt from its interface.
10711069
break;
10721070
case serialization::Status::NotInOSSA:
10731071
// soft reject, silently ignore.
@@ -1161,7 +1159,7 @@ void swift::serialization::diagnoseSerializedASTLoadFailureTransitive(
11611159
case serialization::Status::FormatTooNew:
11621160
case serialization::Status::FormatTooOld:
11631161
case serialization::Status::NotInOSSA:
1164-
case serialization::Status::NotUsingNoncopyableGenerics:
1162+
case serialization::Status::NoncopyableGenericsMismatch:
11651163
case serialization::Status::RevisionIncompatible:
11661164
case serialization::Status::Malformed:
11671165
case serialization::Status::MalformedDocumentation:

test/Generics/inverse_generics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NoncopyableGenerics -enable-experimental-feature NonescapableTypes
22

3-
// REQUIRES: noncopyable_generics
3+
44

55
// Check support for explicit conditional conformance
66
public struct ExplicitCond<T: ~Copyable>: ~Copyable {}

test/Generics/inverse_generics_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %target-typecheck-verify-swift -parse-stdlib -module-name Swift -enable-experimental-feature BuiltinModule -enable-experimental-feature NoncopyableGenerics -enable-experimental-feature NonescapableTypes
22

3-
// REQUIRES: noncopyable_generics
3+
44

55
/// This test specifically covers constructs that are only valid in the stdlib.
66

0 commit comments

Comments
 (0)