internal: Refine CrateOrigin variants
This commit is contained in:
parent
42d671fcb7
commit
31db1fc75f
@ -166,6 +166,7 @@ pub fn parse_with_proc_macros(
|
|||||||
.as_deref()
|
.as_deref()
|
||||||
.map(Arc::from)
|
.map(Arc::from)
|
||||||
.ok_or_else(|| "target_data_layout unset".into()),
|
.ok_or_else(|| "target_data_layout unset".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let prev = crates.insert(crate_name.clone(), crate_id);
|
let prev = crates.insert(crate_name.clone(), crate_id);
|
||||||
assert!(prev.is_none());
|
assert!(prev.is_none());
|
||||||
@ -200,10 +201,11 @@ pub fn parse_with_proc_macros(
|
|||||||
default_cfg,
|
default_cfg,
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
default_target_data_layout
|
default_target_data_layout
|
||||||
.map(|x| x.into())
|
.map(|x| x.into())
|
||||||
.ok_or_else(|| "target_data_layout unset".into()),
|
.ok_or_else(|| "target_data_layout unset".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
for (from, to, prelude) in crate_deps {
|
for (from, to, prelude) in crate_deps {
|
||||||
@ -245,6 +247,7 @@ pub fn parse_with_proc_macros(
|
|||||||
false,
|
false,
|
||||||
CrateOrigin::Lang(LangCrateOrigin::Core),
|
CrateOrigin::Lang(LangCrateOrigin::Core),
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
for krate in all_crates {
|
for krate in all_crates {
|
||||||
@ -281,8 +284,9 @@ pub fn parse_with_proc_macros(
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
true,
|
true,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
target_layout,
|
target_layout,
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
proc_macros.insert(proc_macros_crate, Ok(proc_macro));
|
proc_macros.insert(proc_macros_crate, Ok(proc_macro));
|
||||||
|
|
||||||
@ -427,7 +431,7 @@ fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
|
|||||||
let (version, origin) = match b.split_once(':') {
|
let (version, origin) = match b.split_once(':') {
|
||||||
Some(("CratesIo", data)) => match data.split_once(',') {
|
Some(("CratesIo", data)) => match data.split_once(',') {
|
||||||
Some((version, url)) => {
|
Some((version, url)) => {
|
||||||
(version, CrateOrigin::CratesIo { repo: Some(url.to_owned()), name: None })
|
(version, CrateOrigin::Local { repo: Some(url.to_owned()), name: None })
|
||||||
}
|
}
|
||||||
_ => panic!("Bad crates.io parameter: {data}"),
|
_ => panic!("Bad crates.io parameter: {data}"),
|
||||||
},
|
},
|
||||||
@ -435,10 +439,9 @@ fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
|
|||||||
};
|
};
|
||||||
(a.to_owned(), origin, Some(version.to_string()))
|
(a.to_owned(), origin, Some(version.to_string()))
|
||||||
} else {
|
} else {
|
||||||
let crate_origin = match &*crate_str {
|
let crate_origin = match LangCrateOrigin::from(&*crate_str) {
|
||||||
"std" => CrateOrigin::Lang(LangCrateOrigin::Std),
|
LangCrateOrigin::Other => CrateOrigin::Local { repo: None, name: None },
|
||||||
"core" => CrateOrigin::Lang(LangCrateOrigin::Core),
|
origin => CrateOrigin::Lang(origin),
|
||||||
_ => CrateOrigin::CratesIo { repo: None, name: None },
|
|
||||||
};
|
};
|
||||||
(crate_str, crate_origin, None)
|
(crate_str, crate_origin, None)
|
||||||
}
|
}
|
||||||
|
@ -135,8 +135,12 @@ fn deref(&self) -> &str {
|
|||||||
/// Origin of the crates. It is used in emitting monikers.
|
/// Origin of the crates. It is used in emitting monikers.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum CrateOrigin {
|
pub enum CrateOrigin {
|
||||||
/// Crates that are from crates.io official registry,
|
/// Crates that are from the rustc workspace
|
||||||
CratesIo { repo: Option<String>, name: Option<String> },
|
Rustc { name: String },
|
||||||
|
/// Crates that are workspace members,
|
||||||
|
Local { repo: Option<String>, name: Option<String> },
|
||||||
|
/// Crates that are non member libraries.
|
||||||
|
Library { repo: Option<String>, name: String },
|
||||||
/// Crates that are provided by the language, like std, core, proc-macro, ...
|
/// Crates that are provided by the language, like std, core, proc-macro, ...
|
||||||
Lang(LangCrateOrigin),
|
Lang(LangCrateOrigin),
|
||||||
}
|
}
|
||||||
@ -257,6 +261,32 @@ pub struct ProcMacro {
|
|||||||
pub expander: Arc<dyn ProcMacroExpander>,
|
pub expander: Arc<dyn ProcMacroExpander>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub enum ReleaseChannel {
|
||||||
|
Stable,
|
||||||
|
Beta,
|
||||||
|
Nightly,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ReleaseChannel {
|
||||||
|
pub fn as_str(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
ReleaseChannel::Stable => "stable",
|
||||||
|
ReleaseChannel::Beta => "beta",
|
||||||
|
ReleaseChannel::Nightly => "nightly",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_str(str: &str) -> Option<Self> {
|
||||||
|
Some(match str {
|
||||||
|
"stable" => ReleaseChannel::Stable,
|
||||||
|
"beta" => ReleaseChannel::Beta,
|
||||||
|
"nightly" => ReleaseChannel::Nightly,
|
||||||
|
_ => return None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CrateData {
|
pub struct CrateData {
|
||||||
pub root_file_id: FileId,
|
pub root_file_id: FileId,
|
||||||
@ -271,11 +301,13 @@ pub struct CrateData {
|
|||||||
pub display_name: Option<CrateDisplayName>,
|
pub display_name: Option<CrateDisplayName>,
|
||||||
pub cfg_options: CfgOptions,
|
pub cfg_options: CfgOptions,
|
||||||
pub potential_cfg_options: CfgOptions,
|
pub potential_cfg_options: CfgOptions,
|
||||||
pub target_layout: TargetLayoutLoadResult,
|
|
||||||
pub env: Env,
|
pub env: Env,
|
||||||
pub dependencies: Vec<Dependency>,
|
pub dependencies: Vec<Dependency>,
|
||||||
pub origin: CrateOrigin,
|
pub origin: CrateOrigin,
|
||||||
pub is_proc_macro: bool,
|
pub is_proc_macro: bool,
|
||||||
|
// FIXME: These things should not be per crate! These are more per workspace crate graph level things
|
||||||
|
pub target_layout: TargetLayoutLoadResult,
|
||||||
|
pub channel: Option<ReleaseChannel>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
@ -329,6 +361,7 @@ pub fn add_crate_root(
|
|||||||
is_proc_macro: bool,
|
is_proc_macro: bool,
|
||||||
origin: CrateOrigin,
|
origin: CrateOrigin,
|
||||||
target_layout: Result<Arc<str>, Arc<str>>,
|
target_layout: Result<Arc<str>, Arc<str>>,
|
||||||
|
channel: Option<ReleaseChannel>,
|
||||||
) -> CrateId {
|
) -> CrateId {
|
||||||
let data = CrateData {
|
let data = CrateData {
|
||||||
root_file_id,
|
root_file_id,
|
||||||
@ -342,6 +375,7 @@ pub fn add_crate_root(
|
|||||||
origin,
|
origin,
|
||||||
target_layout,
|
target_layout,
|
||||||
is_proc_macro,
|
is_proc_macro,
|
||||||
|
channel,
|
||||||
};
|
};
|
||||||
let crate_id = CrateId(self.arena.len() as u32);
|
let crate_id = CrateId(self.arena.len() as u32);
|
||||||
let prev = self.arena.insert(crate_id, data);
|
let prev = self.arena.insert(crate_id, data);
|
||||||
@ -653,8 +687,9 @@ fn detect_cyclic_dependency_indirect() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let crate2 = graph.add_crate_root(
|
let crate2 = graph.add_crate_root(
|
||||||
FileId(2u32),
|
FileId(2u32),
|
||||||
@ -665,8 +700,9 @@ fn detect_cyclic_dependency_indirect() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let crate3 = graph.add_crate_root(
|
let crate3 = graph.add_crate_root(
|
||||||
FileId(3u32),
|
FileId(3u32),
|
||||||
@ -677,8 +713,9 @@ fn detect_cyclic_dependency_indirect() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
assert!(graph
|
assert!(graph
|
||||||
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
||||||
@ -703,8 +740,9 @@ fn detect_cyclic_dependency_direct() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let crate2 = graph.add_crate_root(
|
let crate2 = graph.add_crate_root(
|
||||||
FileId(2u32),
|
FileId(2u32),
|
||||||
@ -715,8 +753,9 @@ fn detect_cyclic_dependency_direct() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
assert!(graph
|
assert!(graph
|
||||||
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
||||||
@ -738,8 +777,9 @@ fn it_works() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let crate2 = graph.add_crate_root(
|
let crate2 = graph.add_crate_root(
|
||||||
FileId(2u32),
|
FileId(2u32),
|
||||||
@ -750,8 +790,9 @@ fn it_works() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let crate3 = graph.add_crate_root(
|
let crate3 = graph.add_crate_root(
|
||||||
FileId(3u32),
|
FileId(3u32),
|
||||||
@ -762,8 +803,9 @@ fn it_works() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
assert!(graph
|
assert!(graph
|
||||||
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
||||||
@ -785,8 +827,9 @@ fn dashes_are_normalized() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
let crate2 = graph.add_crate_root(
|
let crate2 = graph.add_crate_root(
|
||||||
FileId(2u32),
|
FileId(2u32),
|
||||||
@ -797,8 +840,9 @@ fn dashes_are_normalized() {
|
|||||||
CfgOptions::default(),
|
CfgOptions::default(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("".into()),
|
Err("".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
assert!(graph
|
assert!(graph
|
||||||
.add_dep(
|
.add_dep(
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
input::{
|
input::{
|
||||||
CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency,
|
CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency,
|
||||||
Edition, Env, LangCrateOrigin, ProcMacro, ProcMacroExpander, ProcMacroExpansionError,
|
Edition, Env, LangCrateOrigin, ProcMacro, ProcMacroExpander, ProcMacroExpansionError,
|
||||||
ProcMacroId, ProcMacroKind, ProcMacroLoadResult, ProcMacroPaths, ProcMacros, SourceRoot,
|
ProcMacroId, ProcMacroKind, ProcMacroLoadResult, ProcMacroPaths, ProcMacros,
|
||||||
SourceRootId, TargetLayoutLoadResult,
|
ReleaseChannel, SourceRoot, SourceRootId, TargetLayoutLoadResult,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
pub use salsa::{self, Cancelled};
|
pub use salsa::{self, Cancelled};
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
use hir::{db::HirDatabase, Adt, AsAssocItem, AssocItem, AssocItemContainer, HasAttrs};
|
use hir::{db::HirDatabase, Adt, AsAssocItem, AssocItem, AssocItemContainer, HasAttrs};
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::{CrateOrigin, LangCrateOrigin, SourceDatabase},
|
base_db::{CrateOrigin, LangCrateOrigin, ReleaseChannel, SourceDatabase},
|
||||||
defs::{Definition, NameClass, NameRefClass},
|
defs::{Definition, NameClass, NameRefClass},
|
||||||
helpers::pick_best_token,
|
helpers::pick_best_token,
|
||||||
RootDatabase,
|
RootDatabase,
|
||||||
@ -436,8 +436,9 @@ fn get_doc_base_url(db: &RootDatabase, def: Definition) -> Option<Url> {
|
|||||||
|
|
||||||
let krate = def.krate(db)?;
|
let krate = def.krate(db)?;
|
||||||
let display_name = krate.display_name(db)?;
|
let display_name = krate.display_name(db)?;
|
||||||
|
let crate_data = &db.crate_graph()[krate.into()];
|
||||||
let base = match db.crate_graph()[krate.into()].origin {
|
let channel = crate_data.channel.map_or("nightly", ReleaseChannel::as_str);
|
||||||
|
let base = match &crate_data.origin {
|
||||||
// std and co do not specify `html_root_url` any longer so we gotta handwrite this ourself.
|
// std and co do not specify `html_root_url` any longer so we gotta handwrite this ourself.
|
||||||
// FIXME: Use the toolchains channel instead of nightly
|
// FIXME: Use the toolchains channel instead of nightly
|
||||||
CrateOrigin::Lang(
|
CrateOrigin::Lang(
|
||||||
@ -447,9 +448,14 @@ fn get_doc_base_url(db: &RootDatabase, def: Definition) -> Option<Url> {
|
|||||||
| LangCrateOrigin::Std
|
| LangCrateOrigin::Std
|
||||||
| LangCrateOrigin::Test),
|
| LangCrateOrigin::Test),
|
||||||
) => {
|
) => {
|
||||||
format!("https://doc.rust-lang.org/nightly/{origin}")
|
format!("https://doc.rust-lang.org/{channel}/{origin}")
|
||||||
}
|
}
|
||||||
_ => {
|
CrateOrigin::Lang(_) => return None,
|
||||||
|
CrateOrigin::Rustc { name: _ } => {
|
||||||
|
format!("https://doc.rust-lang.org/{channel}/nightly-rustc/")
|
||||||
|
}
|
||||||
|
CrateOrigin::Local { repo: _, name: _ } => {
|
||||||
|
// FIXME: These should not attempt to link to docs.rs!
|
||||||
krate.get_html_root_url(db).or_else(|| {
|
krate.get_html_root_url(db).or_else(|| {
|
||||||
let version = krate.version(db);
|
let version = krate.version(db);
|
||||||
// Fallback to docs.rs. This uses `display_name` and can never be
|
// Fallback to docs.rs. This uses `display_name` and can never be
|
||||||
@ -464,6 +470,21 @@ fn get_doc_base_url(db: &RootDatabase, def: Definition) -> Option<Url> {
|
|||||||
))
|
))
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
|
CrateOrigin::Library { repo: _, name } => {
|
||||||
|
krate.get_html_root_url(db).or_else(|| {
|
||||||
|
let version = krate.version(db);
|
||||||
|
// Fallback to docs.rs. This uses `display_name` and can never be
|
||||||
|
// correct, but that's what fallbacks are about.
|
||||||
|
//
|
||||||
|
// FIXME: clicking on the link should just open the file in the editor,
|
||||||
|
// instead of falling back to external urls.
|
||||||
|
Some(format!(
|
||||||
|
"https://docs.rs/{krate}/{version}/",
|
||||||
|
krate = name,
|
||||||
|
version = version.as_deref().unwrap_or("*")
|
||||||
|
))
|
||||||
|
})?
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Url::parse(&base).ok()?.join(&format!("{display_name}/")).ok()
|
Url::parse(&base).ok()?.join(&format!("{display_name}/")).ok()
|
||||||
}
|
}
|
||||||
|
@ -240,8 +240,9 @@ pub fn from_single_file(text: String) -> (Analysis, FileId) {
|
|||||||
cfg_options,
|
cfg_options,
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo { repo: None, name: None },
|
CrateOrigin::Local { repo: None, name: None },
|
||||||
Err("Analysis::from_single_file has no target layout".into()),
|
Err("Analysis::from_single_file has no target layout".into()),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
change.change_file(file_id, Some(Arc::new(text)));
|
change.change_file(file_id, Some(Arc::new(text)));
|
||||||
change.set_crate_graph(crate_graph);
|
change.set_crate_graph(crate_graph);
|
||||||
|
@ -245,11 +245,17 @@ pub(crate) fn def_to_moniker(
|
|||||||
kind: if krate == from_crate { MonikerKind::Export } else { MonikerKind::Import },
|
kind: if krate == from_crate { MonikerKind::Export } else { MonikerKind::Import },
|
||||||
package_information: {
|
package_information: {
|
||||||
let (name, repo, version) = match krate.origin(db) {
|
let (name, repo, version) = match krate.origin(db) {
|
||||||
CrateOrigin::CratesIo { repo, name } => (
|
CrateOrigin::Library { repo, name } => (name, repo, krate.version(db)),
|
||||||
|
CrateOrigin::Local { repo, name } => (
|
||||||
name.unwrap_or(krate.display_name(db)?.canonical_name().to_string()),
|
name.unwrap_or(krate.display_name(db)?.canonical_name().to_string()),
|
||||||
repo,
|
repo,
|
||||||
krate.version(db),
|
krate.version(db),
|
||||||
),
|
),
|
||||||
|
CrateOrigin::Rustc { name } => (
|
||||||
|
name.clone(),
|
||||||
|
Some("https://github.com/rust-lang/rust/".to_string()),
|
||||||
|
Some(format!("https://github.com/rust-lang/rust/compiler/{name}",)),
|
||||||
|
),
|
||||||
CrateOrigin::Lang(lang) => (
|
CrateOrigin::Lang(lang) => (
|
||||||
krate.display_name(db)?.canonical_name().to_string(),
|
krate.display_name(db)?.canonical_name().to_string(),
|
||||||
Some("https://github.com/rust-lang/rust/".to_string()),
|
Some("https://github.com/rust-lang/rust/".to_string()),
|
||||||
|
@ -40,6 +40,7 @@ pub(crate) fn shuffle_crate_graph(db: &mut RootDatabase) {
|
|||||||
data.is_proc_macro,
|
data.is_proc_macro,
|
||||||
data.origin.clone(),
|
data.origin.clone(),
|
||||||
data.target_layout.clone(),
|
data.target_layout.clone(),
|
||||||
|
data.channel,
|
||||||
);
|
);
|
||||||
new_proc_macros.insert(new_id, proc_macros[&old_id].clone());
|
new_proc_macros.insert(new_id, proc_macros[&old_id].clone());
|
||||||
map.insert(old_id, new_id);
|
map.insert(old_id, new_id);
|
||||||
|
@ -43,5 +43,5 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||||||
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
.unresolved_reference { color: #FC5555; text-decoration: wavy underline; }
|
||||||
</style>
|
</style>
|
||||||
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module crate_root default_library library">std</span><span class="semicolon">;</span>
|
<pre><code><span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module crate_root default_library library">std</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module crate_root library">alloc</span> <span class="keyword">as</span> <span class="module crate_root declaration library">abc</span><span class="semicolon">;</span>
|
<span class="keyword">extern</span> <span class="keyword">crate</span> <span class="module crate_root default_library library">alloc</span> <span class="keyword">as</span> <span class="module crate_root default_library declaration library">abc</span><span class="semicolon">;</span>
|
||||||
</code></pre>
|
</code></pre>
|
@ -41,7 +41,8 @@ fn load_rust_project(file: &str) -> (CrateGraph, ProcMacroPaths) {
|
|||||||
let data = get_test_json_file(file);
|
let data = get_test_json_file(file);
|
||||||
let project = rooted_project_json(data);
|
let project = rooted_project_json(data);
|
||||||
let sysroot = Ok(get_fake_sysroot());
|
let sysroot = Ok(get_fake_sysroot());
|
||||||
let project_workspace = ProjectWorkspace::Json { project, sysroot, rustc_cfg: Vec::new() };
|
let project_workspace =
|
||||||
|
ProjectWorkspace::Json { project, sysroot, rustc_cfg: Vec::new(), toolchain: None };
|
||||||
to_crate_graph(project_workspace)
|
to_crate_graph(project_workspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,9 +155,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
"debug_assertions",
|
"debug_assertions",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -187,13 +185,14 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
1,
|
1,
|
||||||
@ -223,9 +222,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
"debug_assertions",
|
"debug_assertions",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -265,13 +261,14 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
2,
|
2,
|
||||||
@ -301,9 +298,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
"debug_assertions",
|
"debug_assertions",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -343,13 +337,14 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
3,
|
3,
|
||||||
@ -379,9 +374,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
"debug_assertions",
|
"debug_assertions",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -421,13 +413,14 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
4,
|
4,
|
||||||
@ -466,9 +459,6 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
"feature=use_std",
|
"feature=use_std",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -489,15 +479,14 @@ fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: Some(
|
name: "libc",
|
||||||
"https://github.com/rust-lang/libc",
|
|
||||||
),
|
|
||||||
name: Some(
|
|
||||||
"libc",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}"#]],
|
}"#]],
|
||||||
@ -552,9 +541,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -585,13 +571,14 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
1,
|
1,
|
||||||
@ -623,9 +610,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -665,13 +649,14 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
2,
|
2,
|
||||||
@ -703,9 +688,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -745,13 +727,14 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
3,
|
3,
|
||||||
@ -783,9 +766,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -825,13 +805,14 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
4,
|
4,
|
||||||
@ -870,9 +851,6 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
"feature=use_std",
|
"feature=use_std",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -893,15 +871,14 @@ fn cargo_hello_world_project_model_with_selective_overrides() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: Some(
|
name: "libc",
|
||||||
"https://github.com/rust-lang/libc",
|
|
||||||
),
|
|
||||||
name: Some(
|
|
||||||
"libc",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}"#]],
|
}"#]],
|
||||||
@ -946,9 +923,6 @@ fn cargo_hello_world_project_model() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -979,13 +953,14 @@ fn cargo_hello_world_project_model() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
1,
|
1,
|
||||||
@ -1017,9 +992,6 @@ fn cargo_hello_world_project_model() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -1059,13 +1031,14 @@ fn cargo_hello_world_project_model() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
2,
|
2,
|
||||||
@ -1097,9 +1070,6 @@ fn cargo_hello_world_project_model() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -1139,13 +1109,14 @@ fn cargo_hello_world_project_model() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
3,
|
3,
|
||||||
@ -1177,9 +1148,6 @@ fn cargo_hello_world_project_model() {
|
|||||||
"test",
|
"test",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -1219,13 +1187,14 @@ fn cargo_hello_world_project_model() {
|
|||||||
prelude: true,
|
prelude: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: None,
|
name: "hello-world",
|
||||||
name: Some(
|
|
||||||
"hello-world",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
4,
|
4,
|
||||||
@ -1264,9 +1233,6 @@ fn cargo_hello_world_project_model() {
|
|||||||
"feature=use_std",
|
"feature=use_std",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"target_data_layout not loaded",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {
|
entries: {
|
||||||
"CARGO_PKG_LICENSE": "",
|
"CARGO_PKG_LICENSE": "",
|
||||||
@ -1287,15 +1253,14 @@ fn cargo_hello_world_project_model() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
origin: CratesIo {
|
origin: Rustc {
|
||||||
repo: Some(
|
name: "libc",
|
||||||
"https://github.com/rust-lang/libc",
|
|
||||||
),
|
|
||||||
name: Some(
|
|
||||||
"libc",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"target_data_layout not loaded",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}"#]],
|
}"#]],
|
||||||
@ -1332,9 +1297,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1353,6 +1315,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Alloc,
|
Alloc,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
1,
|
1,
|
||||||
@ -1376,9 +1342,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1387,6 +1350,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Core,
|
Core,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
2,
|
2,
|
||||||
@ -1410,9 +1377,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1421,6 +1385,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Other,
|
Other,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
3,
|
3,
|
||||||
@ -1444,9 +1412,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1455,6 +1420,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Other,
|
Other,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
4,
|
4,
|
||||||
@ -1478,9 +1447,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1508,6 +1474,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Other,
|
Other,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
5,
|
5,
|
||||||
@ -1531,9 +1501,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1542,6 +1509,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Other,
|
Other,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
6,
|
6,
|
||||||
@ -1565,9 +1536,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1649,6 +1617,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Std,
|
Std,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
7,
|
7,
|
||||||
@ -1672,9 +1644,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1683,6 +1652,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Other,
|
Other,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
8,
|
8,
|
||||||
@ -1706,9 +1679,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1717,6 +1687,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Test,
|
Test,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
9,
|
9,
|
||||||
@ -1740,9 +1714,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1751,6 +1722,10 @@ fn rust_project_hello_world_project_model() {
|
|||||||
Other,
|
Other,
|
||||||
),
|
),
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
CrateId(
|
CrateId(
|
||||||
10,
|
10,
|
||||||
@ -1774,9 +1749,6 @@ fn rust_project_hello_world_project_model() {
|
|||||||
potential_cfg_options: CfgOptions(
|
potential_cfg_options: CfgOptions(
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
target_layout: Err(
|
|
||||||
"rust-project.json projects have no target layout set",
|
|
||||||
),
|
|
||||||
env: Env {
|
env: Env {
|
||||||
entries: {},
|
entries: {},
|
||||||
},
|
},
|
||||||
@ -1818,13 +1790,17 @@ fn rust_project_hello_world_project_model() {
|
|||||||
prelude: false,
|
prelude: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
origin: CratesIo {
|
origin: Local {
|
||||||
repo: None,
|
repo: None,
|
||||||
name: Some(
|
name: Some(
|
||||||
"hello_world",
|
"hello_world",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
is_proc_macro: false,
|
is_proc_macro: false,
|
||||||
|
target_layout: Err(
|
||||||
|
"rust-project.json projects have no target layout set",
|
||||||
|
),
|
||||||
|
channel: None,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}"#]],
|
}"#]],
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
use anyhow::{format_err, Context, Result};
|
use anyhow::{format_err, Context, Result};
|
||||||
use base_db::{
|
use base_db::{
|
||||||
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
|
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, Edition, Env,
|
||||||
FileId, LangCrateOrigin, ProcMacroPaths, TargetLayoutLoadResult,
|
FileId, LangCrateOrigin, ProcMacroPaths, ReleaseChannel, TargetLayoutLoadResult,
|
||||||
};
|
};
|
||||||
use cfg::{CfgDiff, CfgOptions};
|
use cfg::{CfgDiff, CfgOptions};
|
||||||
use paths::{AbsPath, AbsPathBuf};
|
use paths::{AbsPath, AbsPathBuf};
|
||||||
@ -82,7 +82,14 @@ pub enum ProjectWorkspace {
|
|||||||
target_layout: Result<String, String>,
|
target_layout: Result<String, String>,
|
||||||
},
|
},
|
||||||
/// Project workspace was manually specified using a `rust-project.json` file.
|
/// Project workspace was manually specified using a `rust-project.json` file.
|
||||||
Json { project: ProjectJson, sysroot: Result<Sysroot, Option<String>>, rustc_cfg: Vec<CfgFlag> },
|
Json {
|
||||||
|
project: ProjectJson,
|
||||||
|
sysroot: Result<Sysroot, Option<String>>,
|
||||||
|
/// Holds cfg flags for the current target. We get those by running
|
||||||
|
/// `rustc --print cfg`.
|
||||||
|
rustc_cfg: Vec<CfgFlag>,
|
||||||
|
toolchain: Option<Version>,
|
||||||
|
},
|
||||||
// FIXME: The primary limitation of this approach is that the set of detached files needs to be fixed at the beginning.
|
// FIXME: The primary limitation of this approach is that the set of detached files needs to be fixed at the beginning.
|
||||||
// That's not the end user experience we should strive for.
|
// That's not the end user experience we should strive for.
|
||||||
// Ideally, you should be able to just open a random detached file in existing cargo projects, and get the basic features working.
|
// Ideally, you should be able to just open a random detached file in existing cargo projects, and get the basic features working.
|
||||||
@ -96,6 +103,8 @@ pub enum ProjectWorkspace {
|
|||||||
DetachedFiles {
|
DetachedFiles {
|
||||||
files: Vec<AbsPathBuf>,
|
files: Vec<AbsPathBuf>,
|
||||||
sysroot: Result<Sysroot, Option<String>>,
|
sysroot: Result<Sysroot, Option<String>>,
|
||||||
|
/// Holds cfg flags for the current target. We get those by running
|
||||||
|
/// `rustc --print cfg`.
|
||||||
rustc_cfg: Vec<CfgFlag>,
|
rustc_cfg: Vec<CfgFlag>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -127,12 +136,13 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|||||||
.field("toolchain", &toolchain)
|
.field("toolchain", &toolchain)
|
||||||
.field("data_layout", &data_layout)
|
.field("data_layout", &data_layout)
|
||||||
.finish(),
|
.finish(),
|
||||||
ProjectWorkspace::Json { project, sysroot, rustc_cfg } => {
|
ProjectWorkspace::Json { project, sysroot, rustc_cfg, toolchain } => {
|
||||||
let mut debug_struct = f.debug_struct("Json");
|
let mut debug_struct = f.debug_struct("Json");
|
||||||
debug_struct.field("n_crates", &project.n_crates());
|
debug_struct.field("n_crates", &project.n_crates());
|
||||||
if let Ok(sysroot) = sysroot {
|
if let Ok(sysroot) = sysroot {
|
||||||
debug_struct.field("n_sysroot_crates", &sysroot.crates().len());
|
debug_struct.field("n_sysroot_crates", &sysroot.crates().len());
|
||||||
}
|
}
|
||||||
|
debug_struct.field("toolchain", &toolchain);
|
||||||
debug_struct.field("n_rustc_cfg", &rustc_cfg.len());
|
debug_struct.field("n_rustc_cfg", &rustc_cfg.len());
|
||||||
debug_struct.finish()
|
debug_struct.finish()
|
||||||
}
|
}
|
||||||
@ -152,6 +162,19 @@ pub fn load(
|
|||||||
config: &CargoConfig,
|
config: &CargoConfig,
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
) -> Result<ProjectWorkspace> {
|
) -> Result<ProjectWorkspace> {
|
||||||
|
let version = |current_dir, cmd_path, prefix: &str| {
|
||||||
|
let cargo_version = utf8_stdout({
|
||||||
|
let mut cmd = Command::new(cmd_path);
|
||||||
|
cmd.envs(&config.extra_env);
|
||||||
|
cmd.arg("--version").current_dir(current_dir);
|
||||||
|
cmd
|
||||||
|
})?;
|
||||||
|
anyhow::Ok(
|
||||||
|
cargo_version
|
||||||
|
.get(prefix.len()..)
|
||||||
|
.and_then(|it| Version::parse(it.split_whitespace().next()?).ok()),
|
||||||
|
)
|
||||||
|
};
|
||||||
let res = match manifest {
|
let res = match manifest {
|
||||||
ProjectManifest::ProjectJson(project_json) => {
|
ProjectManifest::ProjectJson(project_json) => {
|
||||||
let project_json = project_json.canonicalize()?;
|
let project_json = project_json.canonicalize()?;
|
||||||
@ -162,24 +185,17 @@ pub fn load(
|
|||||||
format!("Failed to deserialize json file {}", project_json.display())
|
format!("Failed to deserialize json file {}", project_json.display())
|
||||||
})?;
|
})?;
|
||||||
let project_location = project_json.parent().to_path_buf();
|
let project_location = project_json.parent().to_path_buf();
|
||||||
|
let toolchain = version(&*project_location, toolchain::rustc(), "rustc ")?;
|
||||||
let project_json = ProjectJson::new(&project_location, data);
|
let project_json = ProjectJson::new(&project_location, data);
|
||||||
ProjectWorkspace::load_inline(
|
ProjectWorkspace::load_inline(
|
||||||
project_json,
|
project_json,
|
||||||
config.target.as_deref(),
|
config.target.as_deref(),
|
||||||
&config.extra_env,
|
&config.extra_env,
|
||||||
|
toolchain,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ProjectManifest::CargoToml(cargo_toml) => {
|
ProjectManifest::CargoToml(cargo_toml) => {
|
||||||
let cargo_version = utf8_stdout({
|
let toolchain = version(cargo_toml.parent(), toolchain::cargo(), "cargo ")?;
|
||||||
let mut cmd = Command::new(toolchain::cargo());
|
|
||||||
cmd.envs(&config.extra_env);
|
|
||||||
cmd.arg("--version");
|
|
||||||
cmd
|
|
||||||
})?;
|
|
||||||
let toolchain = cargo_version
|
|
||||||
.get("cargo ".len()..)
|
|
||||||
.and_then(|it| Version::parse(it.split_whitespace().next()?).ok());
|
|
||||||
|
|
||||||
let meta = CargoWorkspace::fetch_metadata(
|
let meta = CargoWorkspace::fetch_metadata(
|
||||||
&cargo_toml,
|
&cargo_toml,
|
||||||
cargo_toml.parent(),
|
cargo_toml.parent(),
|
||||||
@ -304,6 +320,7 @@ pub fn load_inline(
|
|||||||
project_json: ProjectJson,
|
project_json: ProjectJson,
|
||||||
target: Option<&str>,
|
target: Option<&str>,
|
||||||
extra_env: &FxHashMap<String, String>,
|
extra_env: &FxHashMap<String, String>,
|
||||||
|
toolchain: Option<Version>,
|
||||||
) -> ProjectWorkspace {
|
) -> ProjectWorkspace {
|
||||||
let sysroot = match (project_json.sysroot.clone(), project_json.sysroot_src.clone()) {
|
let sysroot = match (project_json.sysroot.clone(), project_json.sysroot_src.clone()) {
|
||||||
(Some(sysroot), Some(sysroot_src)) => Ok(Sysroot::load(sysroot, sysroot_src)),
|
(Some(sysroot), Some(sysroot_src)) => Ok(Sysroot::load(sysroot, sysroot_src)),
|
||||||
@ -328,7 +345,7 @@ pub fn load_inline(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let rustc_cfg = rustc_cfg::get(None, target, extra_env);
|
let rustc_cfg = rustc_cfg::get(None, target, extra_env);
|
||||||
ProjectWorkspace::Json { project: project_json, sysroot, rustc_cfg }
|
ProjectWorkspace::Json { project: project_json, sysroot, rustc_cfg, toolchain }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_detached_files(
|
pub fn load_detached_files(
|
||||||
@ -470,7 +487,7 @@ pub fn to_roots(&self) -> Vec<PackageRoot> {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
match self {
|
match self {
|
||||||
ProjectWorkspace::Json { project, sysroot, rustc_cfg: _ } => project
|
ProjectWorkspace::Json { project, sysroot, rustc_cfg: _, toolchain: _ } => project
|
||||||
.crates()
|
.crates()
|
||||||
.map(|(_, krate)| PackageRoot {
|
.map(|(_, krate)| PackageRoot {
|
||||||
is_local: krate.is_workspace_member,
|
is_local: krate.is_workspace_member,
|
||||||
@ -577,14 +594,17 @@ pub fn to_crate_graph(
|
|||||||
let _p = profile::span("ProjectWorkspace::to_crate_graph");
|
let _p = profile::span("ProjectWorkspace::to_crate_graph");
|
||||||
|
|
||||||
let (mut crate_graph, proc_macros) = match self {
|
let (mut crate_graph, proc_macros) = match self {
|
||||||
ProjectWorkspace::Json { project, sysroot, rustc_cfg } => project_json_to_crate_graph(
|
ProjectWorkspace::Json { project, sysroot, rustc_cfg, toolchain } => {
|
||||||
rustc_cfg.clone(),
|
project_json_to_crate_graph(
|
||||||
load,
|
rustc_cfg.clone(),
|
||||||
project,
|
load,
|
||||||
sysroot.as_ref().ok(),
|
project,
|
||||||
extra_env,
|
sysroot.as_ref().ok(),
|
||||||
Err("rust-project.json projects have no target layout set".into()),
|
extra_env,
|
||||||
),
|
Err("rust-project.json projects have no target layout set".into()),
|
||||||
|
toolchain.as_ref().and_then(|it| ReleaseChannel::from_str(it.pre.as_str())),
|
||||||
|
)
|
||||||
|
}
|
||||||
ProjectWorkspace::Cargo {
|
ProjectWorkspace::Cargo {
|
||||||
cargo,
|
cargo,
|
||||||
sysroot,
|
sysroot,
|
||||||
@ -592,7 +612,7 @@ pub fn to_crate_graph(
|
|||||||
rustc_cfg,
|
rustc_cfg,
|
||||||
cfg_overrides,
|
cfg_overrides,
|
||||||
build_scripts,
|
build_scripts,
|
||||||
toolchain: _,
|
toolchain,
|
||||||
target_layout,
|
target_layout,
|
||||||
} => cargo_to_crate_graph(
|
} => cargo_to_crate_graph(
|
||||||
load,
|
load,
|
||||||
@ -606,6 +626,7 @@ pub fn to_crate_graph(
|
|||||||
Ok(it) => Ok(Arc::from(it.as_str())),
|
Ok(it) => Ok(Arc::from(it.as_str())),
|
||||||
Err(it) => Err(Arc::from(it.as_str())),
|
Err(it) => Err(Arc::from(it.as_str())),
|
||||||
},
|
},
|
||||||
|
toolchain.as_ref().and_then(|it| ReleaseChannel::from_str(it.pre.as_str())),
|
||||||
),
|
),
|
||||||
ProjectWorkspace::DetachedFiles { files, sysroot, rustc_cfg } => {
|
ProjectWorkspace::DetachedFiles { files, sysroot, rustc_cfg } => {
|
||||||
detached_files_to_crate_graph(
|
detached_files_to_crate_graph(
|
||||||
@ -657,9 +678,19 @@ pub fn eq_ignore_build_data(&self, other: &Self) -> bool {
|
|||||||
&& sysroot == o_sysroot
|
&& sysroot == o_sysroot
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
Self::Json { project, sysroot, rustc_cfg },
|
Self::Json { project, sysroot, rustc_cfg, toolchain },
|
||||||
Self::Json { project: o_project, sysroot: o_sysroot, rustc_cfg: o_rustc_cfg },
|
Self::Json {
|
||||||
) => project == o_project && rustc_cfg == o_rustc_cfg && sysroot == o_sysroot,
|
project: o_project,
|
||||||
|
sysroot: o_sysroot,
|
||||||
|
rustc_cfg: o_rustc_cfg,
|
||||||
|
toolchain: o_toolchain,
|
||||||
|
},
|
||||||
|
) => {
|
||||||
|
project == o_project
|
||||||
|
&& rustc_cfg == o_rustc_cfg
|
||||||
|
&& sysroot == o_sysroot
|
||||||
|
&& toolchain == o_toolchain
|
||||||
|
}
|
||||||
(
|
(
|
||||||
Self::DetachedFiles { files, sysroot, rustc_cfg },
|
Self::DetachedFiles { files, sysroot, rustc_cfg },
|
||||||
Self::DetachedFiles { files: o_files, sysroot: o_sysroot, rustc_cfg: o_rustc_cfg },
|
Self::DetachedFiles { files: o_files, sysroot: o_sysroot, rustc_cfg: o_rustc_cfg },
|
||||||
@ -684,6 +715,7 @@ fn project_json_to_crate_graph(
|
|||||||
sysroot: Option<&Sysroot>,
|
sysroot: Option<&Sysroot>,
|
||||||
extra_env: &FxHashMap<String, String>,
|
extra_env: &FxHashMap<String, String>,
|
||||||
target_layout: TargetLayoutLoadResult,
|
target_layout: TargetLayoutLoadResult,
|
||||||
|
channel: Option<ReleaseChannel>,
|
||||||
) -> (CrateGraph, ProcMacroPaths) {
|
) -> (CrateGraph, ProcMacroPaths) {
|
||||||
let mut crate_graph = CrateGraph::default();
|
let mut crate_graph = CrateGraph::default();
|
||||||
let mut proc_macros: ProcMacroPaths = FxHashMap::default();
|
let mut proc_macros: ProcMacroPaths = FxHashMap::default();
|
||||||
@ -694,6 +726,7 @@ fn project_json_to_crate_graph(
|
|||||||
rustc_cfg.clone(),
|
rustc_cfg.clone(),
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
load,
|
load,
|
||||||
|
channel,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -726,15 +759,16 @@ fn project_json_to_crate_graph(
|
|||||||
cfg_options,
|
cfg_options,
|
||||||
env,
|
env,
|
||||||
krate.is_proc_macro,
|
krate.is_proc_macro,
|
||||||
if krate.display_name.is_some() {
|
if let Some(name) = krate.display_name.clone() {
|
||||||
CrateOrigin::CratesIo {
|
CrateOrigin::Local {
|
||||||
repo: krate.repository.clone(),
|
repo: krate.repository.clone(),
|
||||||
name: krate.display_name.clone().map(|n| n.canonical_name().to_string()),
|
name: Some(name.canonical_name().to_string()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CrateOrigin::CratesIo { repo: None, name: None }
|
CrateOrigin::Local { repo: None, name: None }
|
||||||
},
|
},
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
if krate.is_proc_macro {
|
if krate.is_proc_macro {
|
||||||
if let Some(path) = krate.proc_macro_dylib_path.clone() {
|
if let Some(path) = krate.proc_macro_dylib_path.clone() {
|
||||||
@ -784,6 +818,7 @@ fn cargo_to_crate_graph(
|
|||||||
override_cfg: &CfgOverrides,
|
override_cfg: &CfgOverrides,
|
||||||
build_scripts: &WorkspaceBuildScripts,
|
build_scripts: &WorkspaceBuildScripts,
|
||||||
target_layout: TargetLayoutLoadResult,
|
target_layout: TargetLayoutLoadResult,
|
||||||
|
channel: Option<ReleaseChannel>,
|
||||||
) -> (CrateGraph, ProcMacroPaths) {
|
) -> (CrateGraph, ProcMacroPaths) {
|
||||||
let _p = profile::span("cargo_to_crate_graph");
|
let _p = profile::span("cargo_to_crate_graph");
|
||||||
let mut crate_graph = CrateGraph::default();
|
let mut crate_graph = CrateGraph::default();
|
||||||
@ -795,6 +830,7 @@ fn cargo_to_crate_graph(
|
|||||||
rustc_cfg.clone(),
|
rustc_cfg.clone(),
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
load,
|
load,
|
||||||
|
channel,
|
||||||
),
|
),
|
||||||
None => (SysrootPublicDeps::default(), None),
|
None => (SysrootPublicDeps::default(), None),
|
||||||
};
|
};
|
||||||
@ -859,6 +895,8 @@ fn cargo_to_crate_graph(
|
|||||||
&cargo[tgt].name,
|
&cargo[tgt].name,
|
||||||
cargo[tgt].is_proc_macro,
|
cargo[tgt].is_proc_macro,
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
|
true,
|
||||||
|
channel,
|
||||||
);
|
);
|
||||||
if cargo[tgt].kind == TargetKind::Lib {
|
if cargo[tgt].kind == TargetKind::Lib {
|
||||||
lib_tgt = Some((crate_id, cargo[tgt].name.clone()));
|
lib_tgt = Some((crate_id, cargo[tgt].name.clone()));
|
||||||
@ -945,6 +983,7 @@ fn cargo_to_crate_graph(
|
|||||||
rustc_build_scripts
|
rustc_build_scripts
|
||||||
},
|
},
|
||||||
target_layout,
|
target_layout,
|
||||||
|
channel,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -967,6 +1006,7 @@ fn detached_files_to_crate_graph(
|
|||||||
rustc_cfg.clone(),
|
rustc_cfg.clone(),
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
load,
|
load,
|
||||||
|
None,
|
||||||
),
|
),
|
||||||
None => (SysrootPublicDeps::default(), None),
|
None => (SysrootPublicDeps::default(), None),
|
||||||
};
|
};
|
||||||
@ -995,11 +1035,12 @@ fn detached_files_to_crate_graph(
|
|||||||
cfg_options.clone(),
|
cfg_options.clone(),
|
||||||
Env::default(),
|
Env::default(),
|
||||||
false,
|
false,
|
||||||
CrateOrigin::CratesIo {
|
CrateOrigin::Local {
|
||||||
repo: None,
|
repo: None,
|
||||||
name: display_name.map(|n| n.canonical_name().to_string()),
|
name: display_name.map(|n| n.canonical_name().to_string()),
|
||||||
},
|
},
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
public_deps.add_to_crate_graph(&mut crate_graph, detached_file_crate);
|
public_deps.add_to_crate_graph(&mut crate_graph, detached_file_crate);
|
||||||
@ -1021,6 +1062,7 @@ fn handle_rustc_crates(
|
|||||||
override_cfg: &CfgOverrides,
|
override_cfg: &CfgOverrides,
|
||||||
build_scripts: &WorkspaceBuildScripts,
|
build_scripts: &WorkspaceBuildScripts,
|
||||||
target_layout: TargetLayoutLoadResult,
|
target_layout: TargetLayoutLoadResult,
|
||||||
|
channel: Option<ReleaseChannel>,
|
||||||
) {
|
) {
|
||||||
let mut rustc_pkg_crates = FxHashMap::default();
|
let mut rustc_pkg_crates = FxHashMap::default();
|
||||||
// The root package of the rustc-dev component is rustc_driver, so we match that
|
// The root package of the rustc-dev component is rustc_driver, so we match that
|
||||||
@ -1078,6 +1120,8 @@ fn handle_rustc_crates(
|
|||||||
&rustc_workspace[tgt].name,
|
&rustc_workspace[tgt].name,
|
||||||
rustc_workspace[tgt].is_proc_macro,
|
rustc_workspace[tgt].is_proc_macro,
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
|
true,
|
||||||
|
channel,
|
||||||
);
|
);
|
||||||
pkg_to_lib_crate.insert(pkg, crate_id);
|
pkg_to_lib_crate.insert(pkg, crate_id);
|
||||||
// Add dependencies on core / std / alloc for this crate
|
// Add dependencies on core / std / alloc for this crate
|
||||||
@ -1143,6 +1187,8 @@ fn add_target_crate_root(
|
|||||||
cargo_name: &str,
|
cargo_name: &str,
|
||||||
is_proc_macro: bool,
|
is_proc_macro: bool,
|
||||||
target_layout: TargetLayoutLoadResult,
|
target_layout: TargetLayoutLoadResult,
|
||||||
|
rustc_crate: bool,
|
||||||
|
channel: Option<ReleaseChannel>,
|
||||||
) -> CrateId {
|
) -> CrateId {
|
||||||
let edition = pkg.edition;
|
let edition = pkg.edition;
|
||||||
let mut potential_cfg_options = cfg_options.clone();
|
let mut potential_cfg_options = cfg_options.clone();
|
||||||
@ -1181,8 +1227,15 @@ fn add_target_crate_root(
|
|||||||
potential_cfg_options,
|
potential_cfg_options,
|
||||||
env,
|
env,
|
||||||
is_proc_macro,
|
is_proc_macro,
|
||||||
CrateOrigin::CratesIo { repo: pkg.repository.clone(), name: Some(pkg.name.clone()) },
|
if rustc_crate {
|
||||||
|
CrateOrigin::Rustc { name: pkg.name.clone() }
|
||||||
|
} else if pkg.is_member {
|
||||||
|
CrateOrigin::Local { repo: pkg.repository.clone(), name: Some(pkg.name.clone()) }
|
||||||
|
} else {
|
||||||
|
CrateOrigin::Library { repo: pkg.repository.clone(), name: pkg.name.clone() }
|
||||||
|
},
|
||||||
target_layout,
|
target_layout,
|
||||||
|
channel,
|
||||||
);
|
);
|
||||||
if is_proc_macro {
|
if is_proc_macro {
|
||||||
let proc_macro = match build_data.as_ref().map(|it| it.proc_macro_dylib_path.as_ref()) {
|
let proc_macro = match build_data.as_ref().map(|it| it.proc_macro_dylib_path.as_ref()) {
|
||||||
@ -1217,6 +1270,7 @@ fn sysroot_to_crate_graph(
|
|||||||
rustc_cfg: Vec<CfgFlag>,
|
rustc_cfg: Vec<CfgFlag>,
|
||||||
target_layout: TargetLayoutLoadResult,
|
target_layout: TargetLayoutLoadResult,
|
||||||
load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
|
load: &mut dyn FnMut(&AbsPath) -> Option<FileId>,
|
||||||
|
channel: Option<ReleaseChannel>,
|
||||||
) -> (SysrootPublicDeps, Option<CrateId>) {
|
) -> (SysrootPublicDeps, Option<CrateId>) {
|
||||||
let _p = profile::span("sysroot_to_crate_graph");
|
let _p = profile::span("sysroot_to_crate_graph");
|
||||||
let mut cfg_options = CfgOptions::default();
|
let mut cfg_options = CfgOptions::default();
|
||||||
@ -1239,6 +1293,7 @@ fn sysroot_to_crate_graph(
|
|||||||
false,
|
false,
|
||||||
CrateOrigin::Lang(LangCrateOrigin::from(&*sysroot[krate].name)),
|
CrateOrigin::Lang(LangCrateOrigin::from(&*sysroot[krate].name)),
|
||||||
target_layout.clone(),
|
target_layout.clone(),
|
||||||
|
channel,
|
||||||
);
|
);
|
||||||
Some((krate, crate_id))
|
Some((krate, crate_id))
|
||||||
})
|
})
|
||||||
|
@ -192,6 +192,7 @@ pub(crate) fn fetch_workspaces(&mut self, cause: Cause) {
|
|||||||
it.clone(),
|
it.clone(),
|
||||||
cargo_config.target.as_deref(),
|
cargo_config.target.as_deref(),
|
||||||
&cargo_config.extra_env,
|
&cargo_config.extra_env,
|
||||||
|
None,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -427,19 +428,19 @@ pub(crate) fn switch_workspaces(&mut self, cause: Cause) {
|
|||||||
let (crate_graph, proc_macro_paths) = {
|
let (crate_graph, proc_macro_paths) = {
|
||||||
let vfs = &mut self.vfs.write().0;
|
let vfs = &mut self.vfs.write().0;
|
||||||
let loader = &mut self.loader;
|
let loader = &mut self.loader;
|
||||||
let mem_docs = &self.mem_docs;
|
let mut load = |path: &AbsPath| {
|
||||||
let mut load = move |path: &AbsPath| {
|
|
||||||
let _p = profile::span("switch_workspaces::load");
|
let _p = profile::span("switch_workspaces::load");
|
||||||
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
|
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
|
||||||
if !mem_docs.contains(&vfs_path) {
|
match vfs.file_id(&vfs_path) {
|
||||||
let contents = loader.handle.load_sync(path);
|
Some(file_id) => Some(file_id),
|
||||||
vfs.set_file_contents(vfs_path.clone(), contents);
|
None => {
|
||||||
|
if !self.mem_docs.contains(&vfs_path) {
|
||||||
|
let contents = loader.handle.load_sync(path);
|
||||||
|
vfs.set_file_contents(vfs_path.clone(), contents);
|
||||||
|
}
|
||||||
|
vfs.file_id(&vfs_path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let res = vfs.file_id(&vfs_path);
|
|
||||||
if res.is_none() {
|
|
||||||
tracing::warn!("failed to load {}", path.display())
|
|
||||||
}
|
|
||||||
res
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut crate_graph = CrateGraph::default();
|
let mut crate_graph = CrateGraph::default();
|
||||||
|
@ -160,7 +160,7 @@ pub fn iter(&self) -> impl Iterator<Item = (FileId, &VfsPath)> + '_ {
|
|||||||
/// [`FileId`] for it.
|
/// [`FileId`] for it.
|
||||||
pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) -> bool {
|
pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) -> bool {
|
||||||
let file_id = self.alloc_file_id(path);
|
let file_id = self.alloc_file_id(path);
|
||||||
let change_kind = match (&self.get(file_id), &contents) {
|
let change_kind = match (self.get(file_id), &contents) {
|
||||||
(None, None) => return false,
|
(None, None) => return false,
|
||||||
(Some(old), Some(new)) if old == new => return false,
|
(Some(old), Some(new)) if old == new => return false,
|
||||||
(None, Some(_)) => ChangeKind::Create,
|
(None, Some(_)) => ChangeKind::Create,
|
||||||
|
Loading…
Reference in New Issue
Block a user