Skip to content

Commit af355f0

Browse files
committed
Use crate_name() on the library target, update tests.
1 parent 58ed2e3 commit af355f0

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

src/cargo/ops/tree/format/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a> fmt::Display for Display<'a> {
108108
.iter()
109109
.find(|target| target.is_lib())
110110
{
111-
write!(fmt, "{}", target.name())?;
111+
write!(fmt, "{}", target.crate_name())?;
112112
}
113113
}
114114
}

src/doc/man/cargo-tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ strings will be replaced with the corresponding value:
145145
- `{l}` — The package license.
146146
- `{r}` — The package repository URL.
147147
- `{f}` — Comma-separated list of package features that are enabled.
148-
- `{lib}` — The name of the package's library.
148+
- `{lib}` — The name, as used in a `use` statement, of the package's library.
149149
{{/option}}
150150

151151
{{#option "`--prefix` _prefix_" }}

src/doc/man/generated_txt/cargo-tree.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ OPTIONS
138138
o {f} — Comma-separated list of package features that are
139139
enabled.
140140

141-
o {lib} — The name of the package's library.
141+
o {lib} — The name, as used in a use statement, of the package's
142+
library.
142143

143144
--prefix prefix
144145
Sets how each line is displayed. The prefix value can be one of:

src/doc/src/commands/cargo-tree.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ strings will be replaced with the corresponding value:</p>
145145
<li><code>{l}</code> — The package license.</li>
146146
<li><code>{r}</code> — The package repository URL.</li>
147147
<li><code>{f}</code> — Comma-separated list of package features that are enabled.</li>
148-
<li><code>{lib}</code> — The name of the package's library.</li>
148+
<li><code>{lib}</code> — The name, as used in a <code>use</code> statement, of the package's library.</li>
149149
</ul></dd>
150150

151151

src/etc/man/cargo-tree.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ strings will be replaced with the corresponding value:
188188
.RE
189189
.sp
190190
.RS 4
191-
\h'-04'\(bu\h'+02'\fB{lib}\fR \[em] The name of the package's library.
191+
\h'-04'\(bu\h'+02'\fB{lib}\fR \[em] The name, as used in a \fBuse\fR statement, of the package's library.
192192
.RE
193193
.RE
194194
.sp

tests/testsuite/tree.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ foo v0.1.0 ([..]/foo)
10091009
#[cargo_test]
10101010
fn format() {
10111011
Package::new("dep", "1.0.0").publish();
1012+
Package::new("other-dep", "1.0.0").publish();
10121013

10131014
Package::new("dep_that_is_awesome", "1.0.0")
10141015
.file(
@@ -1037,15 +1038,17 @@ fn format() {
10371038
10381039
[dependencies]
10391040
dep = {version="1.0", optional=true}
1041+
other-dep = {version="1.0", optional=true}
10401042
dep_that_is_awesome = {version="1.0", optional=true}
10411043
1044+
10421045
[features]
10431046
default = ["foo"]
10441047
foo = ["bar"]
10451048
bar = []
10461049
"#,
10471050
)
1048-
.file("src/lib.rs", "")
1051+
.file("src/main.rs", "")
10491052
.build();
10501053

10511054
p.cargo("tree --format <<<{p}>>>")
@@ -1082,20 +1085,21 @@ Caused by:
10821085
.arg("{p} [{f}]")
10831086
.with_stdout(
10841087
"\
1085-
foo v0.1.0 ([..]/foo) [bar,default,dep,dep_that_is_awesome,foo]
1088+
foo v0.1.0 ([..]/foo) [bar,default,dep,dep_that_is_awesome,foo,other-dep]
10861089
├── dep v1.0.0 []
1087-
└── dep_that_is_awesome v1.0.0 []
1090+
├── dep_that_is_awesome v1.0.0 []
1091+
└── other-dep v1.0.0 []
10881092
",
10891093
)
10901094
.run();
10911095

10921096
p.cargo("tree")
1093-
.arg("--features=dep_that_is_awesome")
1097+
.arg("--features=other-dep,dep_that_is_awesome")
10941098
.arg("--format={lib}")
10951099
.with_stdout(
1096-
"\
1097-
foo
1098-
└── awesome_dep
1100+
"
1101+
├── awesome_dep
1102+
└── other_dep
10991103
",
11001104
)
11011105
.run();

0 commit comments

Comments
 (0)