Skip to content

Commit

Permalink
Auto merge of rust-lang#2756 - RalfJung:rustup, r=RalfJung
Browse files Browse the repository at this point in the history
Rustup
  • Loading branch information
bors committed Jan 13, 2023
2 parents 18e753b + 24d7221 commit 5883674
Show file tree
Hide file tree
Showing 397 changed files with 14,560 additions and 5,746 deletions.
89 changes: 81 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions crates/base-db/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -234,6 +238,7 @@ impl ChangeFixture {
Ok(Vec::new()),
false,
CrateOrigin::Lang(LangCrateOrigin::Core),
target_layout.clone(),
);

for krate in all_crates {
Expand Down Expand Up @@ -271,6 +276,7 @@ impl ChangeFixture {
Ok(proc_macro),
true,
CrateOrigin::CratesIo { repo: None, name: None },
target_layout,
);

for krate in all_crates {
Expand Down Expand Up @@ -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>) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
}
}
}
Expand Down
21 changes: 17 additions & 4 deletions crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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))
Expand All @@ -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),
Expand All @@ -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))
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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))
Expand All @@ -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),
Expand All @@ -793,6 +805,7 @@ mod tests {
Ok(Vec::new()),
false,
CrateOrigin::CratesIo { repo: None, name: None },
None,
);
assert!(graph
.add_dep(
Expand Down
4 changes: 2 additions & 2 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 5883674

Please sign in to comment.