Skip to content

Add a way to refer to a particular target in JSON messages #5508

Open
@matklad

Description

@matklad

Package and Target are two important internal datastructures in Cargo, and we expose them for tools via various JSON messages.

To refer to a pacakge, we use an opaque in theory PackageId string. We don't have an obvious way to refer to a target of a package, and that I think causes problems.

Specifically, I think we have three places which would like to refer to targets, and each does it in its own way:

  • In Artifact, we refer to target by just printing the whole target
  • In cargo metadata, we don't refer to targets from resolve deps at all, but we probably should
  • In the build plan PR, we print TargetKind, which is ambiguous.

Possible solution

  • Just use the whole target as in Artifact, everywhere (on the one hand, this seems kind-of inelegant and duplicate, on the other hand, this is simple and straightforward)

  • Use path to root file as a target_id, or (if that's ambigious), a pair of kind, path

Metadata

Metadata

Assignees

Labels

A-json-outputArea: JSON message outputCommand-metadataS-needs-designStatus: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions