@@ -6718,32 +6718,6 @@ ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
67186718 return DCC.fixupParserResult (ID);
67196719}
67206720
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-
67476721// / Parse an inheritance clause.
67486722// /
67496723// / \verbatim
@@ -6758,14 +6732,12 @@ static void addMoveOnlyAttrIf(SourceLoc const &parsedTildeCopyable,
67586732ParserStatus Parser::parseInheritance (
67596733 SmallVectorImpl<InheritedEntry> &Inherited,
67606734 bool allowClassRequirement,
6761- bool allowAnyObject,
6762- SourceLoc *parseTildeCopyable) {
6735+ bool allowAnyObject) {
67636736 consumeToken (tok::colon);
67646737
67656738 SourceLoc classRequirementLoc;
67666739
67676740 ParserStatus Status;
6768- SourceLoc TildeCopyableLoc;
67696741 SourceLoc prevComma;
67706742 bool HasNextType;
67716743 do {
@@ -6817,49 +6789,6 @@ ParserStatus Parser::parseInheritance(
68176789 continue ;
68186790 }
68196791
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-
68636792 auto ParsedTypeResult = parseType ();
68646793 Status |= ParsedTypeResult;
68656794
@@ -6868,9 +6797,6 @@ ParserStatus Parser::parseInheritance(
68686797 Inherited.push_back (InheritedEntry (ParsedTypeResult.get ()));
68696798 } while (HasNextType);
68706799
6871- if (parseTildeCopyable)
6872- *parseTildeCopyable = TildeCopyableLoc;
6873-
68746800 return Status;
68756801}
68766802
@@ -9165,14 +9091,10 @@ ParserResult<EnumDecl> Parser::parseDeclEnum(ParseDeclOptions Flags,
91659091 // Parse optional inheritance clause within the context of the enum.
91669092 if (Tok.is (tok::colon)) {
91679093 SmallVector<InheritedEntry, 2 > Inherited;
9168- SourceLoc parsedTildeCopyable;
91699094 Status |= parseInheritance (Inherited,
91709095 /* allowClassRequirement=*/ false ,
9171- /* allowAnyObject=*/ false ,
9172- &parsedTildeCopyable);
9096+ /* allowAnyObject=*/ false );
91739097 ED->setInherited (Context.AllocateCopy (Inherited));
9174-
9175- addMoveOnlyAttrIf (parsedTildeCopyable, Context, ED);
91769098 }
91779099
91789100 diagnoseWhereClauseInGenericParamList (GenericParams);
@@ -9431,14 +9353,10 @@ ParserResult<StructDecl> Parser::parseDeclStruct(ParseDeclOptions Flags,
94319353 // Parse optional inheritance clause within the context of the struct.
94329354 if (Tok.is (tok::colon)) {
94339355 SmallVector<InheritedEntry, 2 > Inherited;
9434- SourceLoc parsedTildeCopyable;
94359356 Status |= parseInheritance (Inherited,
94369357 /* allowClassRequirement=*/ false ,
9437- /* allowAnyObject=*/ false ,
9438- &parsedTildeCopyable);
9358+ /* allowAnyObject=*/ false );
94399359 SD->setInherited (Context.AllocateCopy (Inherited));
9440-
9441- addMoveOnlyAttrIf (parsedTildeCopyable, Context, SD);
94429360 }
94439361
94449362 diagnoseWhereClauseInGenericParamList (GenericParams);
0 commit comments