@@ -6718,32 +6718,6 @@ ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
6718
6718
return DCC.fixupParserResult (ID);
6719
6719
}
6720
6720
6721
- static void addMoveOnlyAttrIf (SourceLoc const &parsedTildeCopyable,
6722
- ASTContext &Context,
6723
- Decl *decl) {
6724
- if (parsedTildeCopyable.isInvalid ())
6725
- return ;
6726
-
6727
- if (Context.LangOpts .hasFeature (Feature::NoncopyableGenerics))
6728
- llvm_unreachable (" unexpected use of legacy ~Copyable parsing" );
6729
-
6730
- auto &attrs = decl->getAttrs ();
6731
-
6732
- // Don't add if it's already explicitly written on the decl, but error about
6733
- // the duplication and point to the `~Copyable`.
6734
- if (auto attr = attrs.getAttribute <MoveOnlyAttr>()) {
6735
- const bool sayModifier = false ;
6736
- Context.Diags .diagnose (attr->getLocation (), diag::duplicate_attribute,
6737
- sayModifier)
6738
- .fixItRemove (attr->getRange ());
6739
- Context.Diags .diagnose (parsedTildeCopyable, diag::previous_attribute,
6740
- sayModifier);
6741
- return ;
6742
- }
6743
-
6744
- attrs.add (new (Context) MoveOnlyAttr (/* IsImplicit=*/ true ));
6745
- }
6746
-
6747
6721
// / Parse an inheritance clause.
6748
6722
// /
6749
6723
// / \verbatim
@@ -6758,14 +6732,12 @@ static void addMoveOnlyAttrIf(SourceLoc const &parsedTildeCopyable,
6758
6732
ParserStatus Parser::parseInheritance (
6759
6733
SmallVectorImpl<InheritedEntry> &Inherited,
6760
6734
bool allowClassRequirement,
6761
- bool allowAnyObject,
6762
- SourceLoc *parseTildeCopyable) {
6735
+ bool allowAnyObject) {
6763
6736
consumeToken (tok::colon);
6764
6737
6765
6738
SourceLoc classRequirementLoc;
6766
6739
6767
6740
ParserStatus Status;
6768
- SourceLoc TildeCopyableLoc;
6769
6741
SourceLoc prevComma;
6770
6742
bool HasNextType;
6771
6743
do {
@@ -6817,49 +6789,6 @@ ParserStatus Parser::parseInheritance(
6817
6789
continue ;
6818
6790
}
6819
6791
6820
- if (!canSuppressConformancesWithTilde () && Tok.isTilde ()) {
6821
- ErrorTypeRepr *error = nullptr ;
6822
- if (parseTildeCopyable) {
6823
- const auto &nextTok = peekToken (); // lookahead
6824
- if (isIdentifier (nextTok, Context.Id_Copyable .str ())) {
6825
- auto tildeLoc = consumeToken ();
6826
- consumeToken (); // the 'Copyable' token
6827
-
6828
- if (TildeCopyableLoc)
6829
- Inherited.push_back (InheritedEntry (
6830
- ErrorTypeRepr::create (Context, tildeLoc,
6831
- diag::already_suppressed_copyable)));
6832
- else
6833
- TildeCopyableLoc = tildeLoc;
6834
-
6835
- continue ; // success
6836
- }
6837
-
6838
- if (nextTok.is (tok::code_complete)) {
6839
- consumeToken (); // consume '~'
6840
- Status.setHasCodeCompletionAndIsError ();
6841
- if (CodeCompletionCallbacks) {
6842
- CodeCompletionCallbacks->completeWithoutConstraintType ();
6843
- }
6844
- consumeToken (tok::code_complete);
6845
- }
6846
-
6847
- // can't suppress whatever is between '~' and ',' or '{'.
6848
- error = ErrorTypeRepr::create (Context, consumeToken (),
6849
- diag::only_suppress_copyable);
6850
- } else {
6851
- // Otherwise, a suppression isn't allowed here unless noncopyable
6852
- // generics is enabled, so record a delayed error diagnostic and
6853
- // eat the token to prevent further parsing errors.
6854
- error = ErrorTypeRepr::create (Context, consumeToken (),
6855
- diag::cannot_suppress_here);
6856
- }
6857
-
6858
- // Record the error parsing ~Copyable, but continue on to parseType.
6859
- if (error)
6860
- Inherited.push_back (InheritedEntry (error));
6861
- }
6862
-
6863
6792
auto ParsedTypeResult = parseType ();
6864
6793
Status |= ParsedTypeResult;
6865
6794
@@ -6868,9 +6797,6 @@ ParserStatus Parser::parseInheritance(
6868
6797
Inherited.push_back (InheritedEntry (ParsedTypeResult.get ()));
6869
6798
} while (HasNextType);
6870
6799
6871
- if (parseTildeCopyable)
6872
- *parseTildeCopyable = TildeCopyableLoc;
6873
-
6874
6800
return Status;
6875
6801
}
6876
6802
@@ -9165,14 +9091,10 @@ ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
9165
9091
// Parse optional inheritance clause within the context of the enum.
9166
9092
if (Tok.is (tok::colon)) {
9167
9093
SmallVector<InheritedEntry, 2 > Inherited;
9168
- SourceLoc parsedTildeCopyable;
9169
9094
Status |= parseInheritance (Inherited,
9170
9095
/* allowClassRequirement=*/ false ,
9171
- /* allowAnyObject=*/ false ,
9172
- &parsedTildeCopyable);
9096
+ /* allowAnyObject=*/ false );
9173
9097
ED->setInherited (Context.AllocateCopy (Inherited));
9174
-
9175
- addMoveOnlyAttrIf (parsedTildeCopyable, Context, ED);
9176
9098
}
9177
9099
9178
9100
diagnoseWhereClauseInGenericParamList (GenericParams);
@@ -9431,14 +9353,10 @@ ParserResult<StructDecl> Parser::parseDeclStruct(ParseDeclOptions Flags,
9431
9353
// Parse optional inheritance clause within the context of the struct.
9432
9354
if (Tok.is (tok::colon)) {
9433
9355
SmallVector<InheritedEntry, 2 > Inherited;
9434
- SourceLoc parsedTildeCopyable;
9435
9356
Status |= parseInheritance (Inherited,
9436
9357
/* allowClassRequirement=*/ false ,
9437
- /* allowAnyObject=*/ false ,
9438
- &parsedTildeCopyable);
9358
+ /* allowAnyObject=*/ false );
9439
9359
SD->setInherited (Context.AllocateCopy (Inherited));
9440
-
9441
- addMoveOnlyAttrIf (parsedTildeCopyable, Context, SD);
9442
9360
}
9443
9361
9444
9362
diagnoseWhereClauseInGenericParamList (GenericParams);
0 commit comments