Skip to content

Commit 8db0af4

Browse files
authored
Merge pull request #71352 from slavapestov/remove-redundant-requirements
Remove -warn-redundant-requirements flag
2 parents bda514c + d2f1362 commit 8db0af4

File tree

95 files changed

+392
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+392
-916
lines changed

include/swift/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "swift/AST/ASTAllocated.h"
2121
#include "swift/AST/Availability.h"
2222
#include "swift/AST/Evaluator.h"
23-
#include "swift/AST/GenericSignature.h"
2423
#include "swift/AST/Identifier.h"
2524
#include "swift/AST/Import.h"
2625
#include "swift/AST/SILOptions.h"
@@ -87,6 +86,7 @@ namespace swift {
8786
class ForeignRepresentationInfo;
8887
class FuncDecl;
8988
class GenericContext;
89+
class GenericSignature;
9090
class InFlightDiagnostic;
9191
class IterableDeclContext;
9292
class LazyContextData;

include/swift/AST/Attr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "swift/AST/MacroDeclaration.h"
2828
#include "swift/AST/Ownership.h"
2929
#include "swift/AST/PlatformKind.h"
30-
#include "swift/AST/Requirement.h"
3130
#include "swift/AST/StorageImpl.h"
3231
#include "swift/Basic/Debug.h"
3332
#include "swift/Basic/EnumTraits.h"

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,8 +3194,6 @@ ERROR(recursive_superclass_constraint,none,
31943194
"superclass constraint %0 : %1 is recursive", (Type, Type))
31953195
ERROR(requires_same_concrete_type,none,
31963196
"generic signature requires types %0 and %1 to be the same", (Type, Type))
3197-
WARNING(redundant_conformance_constraint,none,
3198-
"redundant conformance constraint %0 : %1", (Type, Type))
31993197

32003198
WARNING(missing_protocol_refinement, none,
32013199
"protocol %0 should be declared to refine %1 due to a same-type constraint on 'Self'",
@@ -3204,17 +3202,9 @@ WARNING(missing_protocol_refinement, none,
32043202
ERROR(requirement_conflict,none,
32053203
"no type for %0 can satisfy both %1",
32063204
(Type, StringRef))
3207-
WARNING(redundant_same_type_to_concrete,none,
3208-
"redundant same-type constraint %0 == %1", (Type, Type))
32093205
ERROR(conflicting_superclass_constraints,none,
32103206
"type %0 cannot be a subclass of both %1 and %2",
32113207
(Type, Type, Type))
3212-
WARNING(redundant_superclass_constraint,none,
3213-
"redundant superclass constraint %0 : %1", (Type, Type))
3214-
3215-
WARNING(redundant_layout_constraint,none,
3216-
"redundant constraint %0 : %1",
3217-
(Type, LayoutConstraint))
32183208

32193209
WARNING(redundant_same_type_constraint,none,
32203210
"redundant same-type constraint %0 == %1", (Type, Type))
@@ -7578,8 +7568,6 @@ ERROR(inverse_but_also_conforms, none,
75787568
ERROR(inverse_generic_but_also_conforms, none,
75797569
"%0 required to be '%1' but is marked with '~%1'",
75807570
(Type, StringRef))
7581-
WARNING(redundant_inverse_constraint,none,
7582-
"redundant constraint %0 : '~%1'", (Type, StringRef))
75837571
ERROR(inverse_on_class, none,
75847572
"classes cannot be '~%0'",
75857573
(StringRef))

include/swift/AST/ProtocolConformanceRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define SWIFT_AST_PROTOCOLCONFORMANCEREF_H
1818

1919
#include "swift/AST/ProtocolConformanceRef.h"
20-
#include "swift/AST/Requirement.h"
2120
#include "swift/AST/Type.h"
2221
#include "swift/AST/TypeAlignments.h"
2322
#include "swift/Basic/Debug.h"
@@ -36,6 +35,7 @@ class BuiltinProtocolConformance;
3635
class ConcreteDeclRef;
3736
class PackConformance;
3837
class ProtocolConformance;
38+
class Requirement;
3939
enum class EffectKind : uint8_t;
4040

4141
/// A ProtocolConformanceRef is a handle to a protocol conformance which

include/swift/AST/Requirement.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,24 +233,11 @@ CheckRequirementsResult checkRequirements(
233233
/// A requirement as written in source, together with a source location. See
234234
/// ProtocolDecl::getStructuralRequirements().
235235
struct StructuralRequirement {
236-
/// The actual requirement, where the types were resolved with the
237-
/// 'Structural' type resolution stage.
236+
/// A requirement with resolved in the structural resolution stage.
238237
Requirement req;
239238

240-
/// The source location where the requirement is written, used for redundancy
241-
/// and conflict diagnostics.
239+
/// The source location where the requirement is written, for diagnostics.
242240
SourceLoc loc;
243-
244-
/// A flag indicating whether the requirement was inferred from the
245-
/// application of a type constructor. Also used for diagnostics, because
246-
/// an inferred requirement made redundant by an explicit requirement is not
247-
/// diagnosed as redundant, since we want to give users the option of
248-
/// spelling out these requirements explicitly.
249-
bool inferred = false;
250-
251-
/// A flag indicating whether this requirement was produced via the expansion
252-
/// of default conformances to invertible protocols.
253-
bool fromDefault = false;
254241
};
255242

256243
/// An "anti-conformance" requirement `Subject: ~Protocol`.

include/swift/AST/Types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "swift/AST/KnownProtocols.h"
2828
#include "swift/AST/Ownership.h"
2929
#include "swift/AST/ProtocolConformanceRef.h"
30-
#include "swift/AST/Requirement.h"
3130
#include "swift/AST/SubstitutionMap.h"
3231
#include "swift/AST/Type.h"
3332
#include "swift/AST/TypeAlignments.h"

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,6 @@ namespace swift {
553553
/// rewrite system.
554554
bool EnableRequirementMachineOpaqueArchetypes = false;
555555

556-
/// Enable warnings for redundant requirements in generic signatures.
557-
bool WarnRedundantRequirements = false;
558-
559556
/// Enable experimental associated type inference improvements.
560557
bool EnableExperimentalAssociatedTypeInference = false;
561558

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,6 @@ def disable_requirement_machine_reuse : Flag<["-"], "disable-requirement-machine
425425
def enable_requirement_machine_opaque_archetypes : Flag<["-"], "enable-requirement-machine-opaque-archetypes">,
426426
HelpText<"Enable more correct opaque archetype support, which is off by default because it might fail to produce a convergent rewrite system">;
427427

428-
def warn_redundant_requirements : Flag<["-"], "warn-redundant-requirements">,
429-
HelpText<"Emit warnings for redundant requirements in generic signatures">;
430-
431428
def dump_type_witness_systems : Flag<["-"], "dump-type-witness-systems">,
432429
HelpText<"Enables dumping type witness systems from associated type inference">;
433430

lib/AST/Requirement.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,7 @@ void InverseRequirement::expandDefaults(
362362

363363
auto protoTy = proto->getDeclaredInterfaceType();
364364
result.push_back({{RequirementKind::Conformance, gp, protoTy},
365-
SourceLoc(),
366-
/*inferred=*/true,
367-
/*default=*/true,
368-
});
365+
SourceLoc()});
369366
}
370367
}
371368
}

lib/AST/RequirementMachine/ConcreteContraction.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -691,32 +691,15 @@ bool ConcreteContraction::performConcreteContraction(
691691
// requirement where the left hand side is not a type parameter.
692692
SmallVector<Requirement, 4> reqs;
693693
SmallVector<InverseRequirement, 4> ignoreInverses;
694-
if (req.inferred) {
695-
// Discard errors from desugaring a substituted requirement that
696-
// was inferred. For example, if we have something like
697-
//
698-
// <T, U where T == Int, U == Set<T>>
699-
//
700-
// The inferred requirement 'T : Hashable' from 'Set<>' will
701-
// be substituted with 'T == Int' to get 'Int : Hashable'.
702-
//
703-
// Desugaring will diagnose a redundant conformance requirement,
704-
// but we want to ignore that, since the user did not explicitly
705-
// write 'Int : Hashable' (or 'T : Hashable') anywhere.
706-
SmallVector<RequirementError, 4> discardErrors;
707-
desugarRequirement(substReq, SourceLoc(), reqs,
708-
ignoreInverses, discardErrors);
709-
} else {
710-
desugarRequirement(substReq, req.loc, reqs, ignoreInverses, errors);
711-
}
694+
desugarRequirement(substReq, req.loc, reqs, ignoreInverses, errors);
712695

713696
for (auto desugaredReq : reqs) {
714697
if (Debug) {
715698
llvm::dbgs() << "@@ Desugared requirement: ";
716699
desugaredReq.dump(llvm::dbgs());
717700
llvm::dbgs() << "\n";
718701
}
719-
result.push_back({desugaredReq, req.loc, req.inferred});
702+
result.push_back({desugaredReq, req.loc});
720703
}
721704

722705
if (preserveSameTypeRequirement(req.req) &&
@@ -730,7 +713,7 @@ bool ConcreteContraction::performConcreteContraction(
730713

731714
// Make the duplicated requirement 'inferred' so that we don't diagnose
732715
// it as redundant.
733-
result.push_back({req.req, SourceLoc(), /*inferred=*/true});
716+
result.push_back({req.req, SourceLoc()});
734717
}
735718
}
736719

0 commit comments

Comments
 (0)