-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.
Description
When compiling with --message-format=json-render-diagnostics
I expected to see this target.name
match the name in Cargo.tom
Instead, I see the snake_case
version of the name. This differs from stable.
This appears to impact all lib crate types, but not bin
crates.
Meta
rustc --version --verbose
:
rustc 1.80.0-nightly (9c9b56879 2024-05-05)
binary: rustc
commit-hash: 9c9b568792ef20d8459c745345dd3e79b7c7fa8c
commit-date: 2024-05-05
host: aarch64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.4
Example
Create the test project.
mkdir my-example
cargo init
Compile on stable and view the output:
$ cargo +stable build --message-format=json-render-diagnostics 2> /dev/null | jq .
{
"reason": "compiler-artifact",
"package_id": "path+file:///private/tmp/my-example#0.1.0",
"manifest_path": "/private/tmp/my-example/Cargo.toml",
"target": {
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"name": "my-example",
"src_path": "/private/tmp/my-example/src/lib.rs",
"edition": "2021",
"doc": true,
"doctest": true,
"test": true
},
"profile": {
"opt_level": "0",
"debuginfo": 2,
"debug_assertions": true,
"overflow_checks": true,
"test": false
},
"features": [],
"filenames": [
"/private/tmp/my-example/target/debug/libmy_example.rlib",
"/private/tmp/my-example/target/debug/deps/libmy_example-cabcf031fa7095e7.rmeta"
],
"executable": null,
"fresh": false
}
{
"reason": "build-finished",
"success": true
}
Compile with nightly:
$ cargo +nightly build --message-format=json-render-diagnostics 2> /dev/null | jq .
{
"reason": "compiler-artifact",
"package_id": "path+file:///private/tmp/my-example#0.1.0",
"manifest_path": "/private/tmp/my-example/Cargo.toml",
"target": {
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"name": "my_example",
"src_path": "/private/tmp/my-example/src/lib.rs",
"edition": "2021",
"doc": true,
"doctest": true,
"test": true
},
"profile": {
"opt_level": "0",
"debuginfo": 2,
"debug_assertions": true,
"overflow_checks": true,
"test": false
},
"features": [],
"filenames": [
"/private/tmp/my-example/target/debug/libmy_example.rlib",
"/private/tmp/my-example/target/debug/deps/libmy_example-f13fc0aeb358fb87.rmeta"
],
"executable": null,
"fresh": false
}
{
"reason": "build-finished",
"success": true
}
Note that on stable name
is my-example
, but on nightly, it is my_example
.
$ cargo +stable build --message-format=json-render-diagnostics 2> /dev/null | jq '.target.name'
"my-example"
null
$ cargo +nightly build --message-format=json-render-diagnostics 2> /dev/null | jq '.target.name'
"my_example"
null
Metadata
Metadata
Assignees
Labels
A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)Area: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Status: This issue is waiting on initial triage.