Skip to content

Commit

Permalink
Merge #6297
Browse files Browse the repository at this point in the history
6297: Support Display name in project.json r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
  • Loading branch information
bors[bot] and matklad committed Oct 20, 2020
2 parents 1c24f57 + f753c3e commit f925735
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions crates/project_model/src/lib.rs
Expand Up @@ -335,8 +335,7 @@ impl ProjectWorkspace {
crate_graph.add_crate_root(
file_id,
krate.edition,
// FIXME json definitions can store the crate name
None,
krate.display_name.clone(),
cfg_options,
env,
proc_macro.unwrap_or_default(),
Expand Down
7 changes: 6 additions & 1 deletion crates/project_model/src/project_json.rs
Expand Up @@ -2,7 +2,7 @@

use std::path::PathBuf;

use base_db::{CrateId, CrateName, Dependency, Edition};
use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
use paths::{AbsPath, AbsPathBuf};
use rustc_hash::FxHashMap;
use serde::{de, Deserialize};
Expand All @@ -21,6 +21,7 @@ pub struct ProjectJson {
/// useful in creating the crate graph.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Crate {
pub(crate) display_name: Option<CrateDisplayName>,
pub(crate) root_module: AbsPathBuf,
pub(crate) edition: Edition,
pub(crate) deps: Vec<Dependency>,
Expand Down Expand Up @@ -68,6 +69,9 @@ impl ProjectJson {
};

Crate {
display_name: crate_data
.display_name
.map(CrateDisplayName::from_canonical_name),
root_module,
edition: crate_data.edition.into(),
deps: crate_data
Expand Down Expand Up @@ -114,6 +118,7 @@ pub struct ProjectJsonData {

#[derive(Deserialize)]
struct CrateData {
display_name: Option<String>,
root_module: PathBuf,
edition: EditionData,
deps: Vec<DepData>,
Expand Down
3 changes: 3 additions & 0 deletions docs/user/manual.adoc
Expand Up @@ -287,6 +287,9 @@ interface JsonProject {
}
interface Crate {
/// Optional crate name used for display purposes, without affecting semantics.
/// See the `deps` key for semantically-significant crate names.
display_name?: string;
/// Path to the root module of the crate.
root_module: string;
/// Edition of the crate.
Expand Down

0 comments on commit f925735

Please sign in to comment.