Skip to content

Commit f925735

Browse files
bors[bot]matklad
andauthored
Merge #6297
6297: Support Display name in project.json r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 1c24f57 + f753c3e commit f925735

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/project_model/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ impl ProjectWorkspace {
335335
crate_graph.add_crate_root(
336336
file_id,
337337
krate.edition,
338-
// FIXME json definitions can store the crate name
339-
None,
338+
krate.display_name.clone(),
340339
cfg_options,
341340
env,
342341
proc_macro.unwrap_or_default(),

crates/project_model/src/project_json.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::path::PathBuf;
44

5-
use base_db::{CrateId, CrateName, Dependency, Edition};
5+
use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
66
use paths::{AbsPath, AbsPathBuf};
77
use rustc_hash::FxHashMap;
88
use serde::{de, Deserialize};
@@ -21,6 +21,7 @@ pub struct ProjectJson {
2121
/// useful in creating the crate graph.
2222
#[derive(Clone, Debug, Eq, PartialEq)]
2323
pub struct Crate {
24+
pub(crate) display_name: Option<CrateDisplayName>,
2425
pub(crate) root_module: AbsPathBuf,
2526
pub(crate) edition: Edition,
2627
pub(crate) deps: Vec<Dependency>,
@@ -68,6 +69,9 @@ impl ProjectJson {
6869
};
6970

7071
Crate {
72+
display_name: crate_data
73+
.display_name
74+
.map(CrateDisplayName::from_canonical_name),
7175
root_module,
7276
edition: crate_data.edition.into(),
7377
deps: crate_data
@@ -114,6 +118,7 @@ pub struct ProjectJsonData {
114118

115119
#[derive(Deserialize)]
116120
struct CrateData {
121+
display_name: Option<String>,
117122
root_module: PathBuf,
118123
edition: EditionData,
119124
deps: Vec<DepData>,

docs/user/manual.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ interface JsonProject {
287287
}
288288
289289
interface Crate {
290+
/// Optional crate name used for display purposes, without affecting semantics.
291+
/// See the `deps` key for semantically-significant crate names.
292+
display_name?: string;
290293
/// Path to the root module of the crate.
291294
root_module: string;
292295
/// Edition of the crate.

0 commit comments

Comments
 (0)