mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
parent
b3ef934ccb
commit
25242fe93f
395 changed files with 14569 additions and 5755 deletions
|
@ -162,6 +162,7 @@ impl ChangeFixture {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
origin,
|
||||
meta.target_data_layout.as_deref().map(Arc::from),
|
||||
);
|
||||
let prev = crates.insert(crate_name.clone(), crate_id);
|
||||
assert!(prev.is_none());
|
||||
|
@ -197,6 +198,7 @@ impl ChangeFixture {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
} else {
|
||||
for (from, to, prelude) in crate_deps {
|
||||
|
@ -210,6 +212,8 @@ impl ChangeFixture {
|
|||
.unwrap();
|
||||
}
|
||||
}
|
||||
let target_layout =
|
||||
crate_graph.iter().next().and_then(|it| crate_graph[it].target_layout.clone());
|
||||
|
||||
if let Some(mini_core) = mini_core {
|
||||
let core_file = file_id;
|
||||
|
@ -234,6 +238,7 @@ impl ChangeFixture {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::Lang(LangCrateOrigin::Core),
|
||||
target_layout.clone(),
|
||||
);
|
||||
|
||||
for krate in all_crates {
|
||||
|
@ -271,6 +276,7 @@ impl ChangeFixture {
|
|||
Ok(proc_macro),
|
||||
true,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
target_layout,
|
||||
);
|
||||
|
||||
for krate in all_crates {
|
||||
|
@ -391,6 +397,7 @@ struct FileMeta {
|
|||
edition: Edition,
|
||||
env: Env,
|
||||
introduce_new_source_root: Option<SourceRootKind>,
|
||||
target_data_layout: Option<String>,
|
||||
}
|
||||
|
||||
fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
|
||||
|
@ -400,9 +407,9 @@ fn parse_crate(crate_str: String) -> (String, CrateOrigin, Option<String>) {
|
|||
Some((version, url)) => {
|
||||
(version, CrateOrigin::CratesIo { repo: Some(url.to_owned()), name: None })
|
||||
}
|
||||
_ => panic!("Bad crates.io parameter: {}", data),
|
||||
_ => panic!("Bad crates.io parameter: {data}"),
|
||||
},
|
||||
_ => panic!("Bad string for crate origin: {}", b),
|
||||
_ => panic!("Bad string for crate origin: {b}"),
|
||||
};
|
||||
(a.to_owned(), origin, Some(version.to_string()))
|
||||
} else {
|
||||
|
@ -432,8 +439,9 @@ impl From<Fixture> for FileMeta {
|
|||
introduce_new_source_root: f.introduce_new_source_root.map(|kind| match &*kind {
|
||||
"local" => SourceRootKind::Local,
|
||||
"library" => SourceRootKind::Library,
|
||||
invalid => panic!("invalid source root kind '{}'", invalid),
|
||||
invalid => panic!("invalid source root kind '{invalid}'"),
|
||||
}),
|
||||
target_data_layout: f.target_data_layout,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ impl fmt::Display for CrateName {
|
|||
impl ops::Deref for CrateName {
|
||||
type Target = str;
|
||||
fn deref(&self) -> &str {
|
||||
&*self.0
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ impl fmt::Display for CrateDisplayName {
|
|||
impl ops::Deref for CrateDisplayName {
|
||||
type Target = str;
|
||||
fn deref(&self) -> &str {
|
||||
&*self.crate_name
|
||||
&self.crate_name
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,6 +270,7 @@ pub struct CrateData {
|
|||
pub display_name: Option<CrateDisplayName>,
|
||||
pub cfg_options: CfgOptions,
|
||||
pub potential_cfg_options: CfgOptions,
|
||||
pub target_layout: Option<Arc<str>>,
|
||||
pub env: Env,
|
||||
pub dependencies: Vec<Dependency>,
|
||||
pub proc_macro: ProcMacroLoadResult,
|
||||
|
@ -328,6 +329,7 @@ impl CrateGraph {
|
|||
proc_macro: ProcMacroLoadResult,
|
||||
is_proc_macro: bool,
|
||||
origin: CrateOrigin,
|
||||
target_layout: Option<Arc<str>>,
|
||||
) -> CrateId {
|
||||
let data = CrateData {
|
||||
root_file_id,
|
||||
|
@ -340,6 +342,7 @@ impl CrateGraph {
|
|||
proc_macro,
|
||||
dependencies: Vec::new(),
|
||||
origin,
|
||||
target_layout,
|
||||
is_proc_macro,
|
||||
};
|
||||
let crate_id = CrateId(self.arena.len() as u32);
|
||||
|
@ -615,8 +618,8 @@ impl CyclicDependenciesError {
|
|||
impl fmt::Display for CyclicDependenciesError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let render = |(id, name): &(CrateId, Option<CrateDisplayName>)| match name {
|
||||
Some(it) => format!("{}({:?})", it, id),
|
||||
None => format!("{:?}", id),
|
||||
Some(it) => format!("{it}({id:?})"),
|
||||
None => format!("{id:?}"),
|
||||
};
|
||||
let path = self.path.iter().rev().map(render).collect::<Vec<String>>().join(" -> ");
|
||||
write!(
|
||||
|
@ -649,6 +652,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
let crate2 = graph.add_crate_root(
|
||||
FileId(2u32),
|
||||
|
@ -661,6 +665,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
let crate3 = graph.add_crate_root(
|
||||
FileId(3u32),
|
||||
|
@ -673,6 +678,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
assert!(graph
|
||||
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
||||
|
@ -699,6 +705,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
let crate2 = graph.add_crate_root(
|
||||
FileId(2u32),
|
||||
|
@ -711,6 +718,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
assert!(graph
|
||||
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
||||
|
@ -734,6 +742,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
let crate2 = graph.add_crate_root(
|
||||
FileId(2u32),
|
||||
|
@ -746,6 +755,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
let crate3 = graph.add_crate_root(
|
||||
FileId(3u32),
|
||||
|
@ -758,6 +768,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
assert!(graph
|
||||
.add_dep(crate1, Dependency::new(CrateName::new("crate2").unwrap(), crate2))
|
||||
|
@ -781,6 +792,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
let crate2 = graph.add_crate_root(
|
||||
FileId(2u32),
|
||||
|
@ -793,6 +805,7 @@ mod tests {
|
|||
Ok(Vec::new()),
|
||||
false,
|
||||
CrateOrigin::CratesIo { repo: None, name: None },
|
||||
None,
|
||||
);
|
||||
assert!(graph
|
||||
.add_dep(
|
||||
|
|
|
@ -75,9 +75,9 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
|
|||
}
|
||||
|
||||
fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
|
||||
let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id));
|
||||
let _p = profile::span("parse_query").detail(|| format!("{file_id:?}"));
|
||||
let text = db.file_text(file_id);
|
||||
SourceFile::parse(&*text)
|
||||
SourceFile::parse(&text)
|
||||
}
|
||||
|
||||
/// We don't want to give HIR knowledge of source roots, hence we extract these
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue