Skip to content

Commit 9053eee

Browse files
committed
Move UseAfterConsume to messages.scala
1 parent d45911f commit 9053eee

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

compiler/src/dotty/tools/dotc/cc/SepCheck.scala

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -454,32 +454,6 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
454454
|No clashing definitions were found. This might point to an internal error.""",
455455
tree.srcPos)
456456

457-
class UseAfterConsume(ref: Capability, consumedLoc: SrcPos, useLoc: SrcPos)(using Context) extends reporting.Message(reporting.ErrorMessageID.NoExplanationID):
458-
def kind = reporting.MessageKind.NoKind
459-
460-
protected def msg(using Context): String = ""
461-
462-
protected def explain(using Context): String = ""
463-
464-
override def leading(using Context): Option[String] = Some(
465-
em"""Separation failure: Illegal access to $ref, which was passed to a
466-
|consume parameter or was used as a prefix to a consume method
467-
|and therefore is no longer available.""".message
468-
)
469-
470-
override def parts(using Context): List[reporting.Message.MessagePart] = List(
471-
reporting.Message.MessagePart(
472-
"The capability was consumed here.",
473-
consumedLoc.sourcePos,
474-
isPrimary = false
475-
),
476-
reporting.Message.MessagePart(
477-
"Then, it was used here",
478-
useLoc.sourcePos,
479-
isPrimary = true
480-
)
481-
)
482-
483457
/** Report a failure where a previously consumed capability is used again,
484458
* @param ref the capability that is used after being consumed
485459
* @param loc the position where the capability was consumed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,3 +3741,27 @@ final class EncodedPackageName(name: Name)(using Context) extends SyntaxMsg(Enco
37413741
|or `myfile-test.scala` can produce encoded names for the generated package objects.
37423742
|
37433743
|In this case, the name `$name` is encoded as `${name.encode}`."""
3744+
3745+
class UseAfterConsume(ref: cc.Capabilities.Capability, consumedLoc: SourcePosition, useLoc: SourcePosition)(using Context)
3746+
extends TypeMsg(NoExplanationID):
3747+
protected def msg(using Context): String =
3748+
i"""Separation failure: Illegal access to $ref, which was passed to a
3749+
|consume parameter or was used as a prefix to a consume method
3750+
|and therefore is no longer available."""
3751+
3752+
protected def explain(using Context): String = ""
3753+
3754+
override def leading(using Context): Option[String] = Some(message)
3755+
3756+
override def parts(using Context): List[Message.MessagePart] = List(
3757+
Message.MessagePart(
3758+
"The capability was consumed here.",
3759+
consumedLoc,
3760+
isPrimary = false
3761+
),
3762+
Message.MessagePart(
3763+
"Then, it was used here",
3764+
useLoc,
3765+
isPrimary = true
3766+
)
3767+
)

0 commit comments

Comments
 (0)