Reformat source code using new defaults

This commit is contained in:
Nick Cameron
2017-06-12 15:58:58 +12:00
parent 32e882789b
commit 1f512948a0
27 changed files with 3224 additions and 2447 deletions
+23 -17
View File
@@ -20,30 +20,35 @@
/// List all the files containing modules of a crate.
/// If a file is used twice in a crate, it appears only once.
pub fn list_files<'a>(krate: &'a ast::Crate,
codemap: &codemap::CodeMap)
-> BTreeMap<PathBuf, &'a ast::Mod> {
pub fn list_files<'a>(
krate: &'a ast::Crate,
codemap: &codemap::CodeMap,
) -> BTreeMap<PathBuf, &'a ast::Mod> {
let mut result = BTreeMap::new(); // Enforce file order determinism
let root_filename: PathBuf = codemap.span_to_filename(krate.span).into();
list_submodules(&krate.module,
root_filename.parent().unwrap(),
codemap,
&mut result);
list_submodules(
&krate.module,
root_filename.parent().unwrap(),
codemap,
&mut result,
);
result.insert(root_filename, &krate.module);
result
}
/// Recursively list all external modules included in a module.
fn list_submodules<'a>(module: &'a ast::Mod,
search_dir: &Path,
codemap: &codemap::CodeMap,
result: &mut BTreeMap<PathBuf, &'a ast::Mod>) {
fn list_submodules<'a>(
module: &'a ast::Mod,
search_dir: &Path,
codemap: &codemap::CodeMap,
result: &mut BTreeMap<PathBuf, &'a ast::Mod>,
) {
debug!("list_submodules: search_dir: {:?}", search_dir);
for item in &module.items {
if let ast::ItemKind::Mod(ref sub_mod) = item.node {
if !utils::contains_skip(&item.attrs) {
let is_internal = codemap.span_to_filename(item.span) ==
codemap.span_to_filename(sub_mod.inner);
codemap.span_to_filename(sub_mod.inner);
let dir_path = if is_internal {
search_dir.join(&item.ident.to_string())
} else {
@@ -59,11 +64,12 @@ fn list_submodules<'a>(module: &'a ast::Mod,
}
/// Find the file corresponding to an external mod
fn module_file(id: ast::Ident,
attrs: &[ast::Attribute],
dir_path: &Path,
codemap: &codemap::CodeMap)
-> PathBuf {
fn module_file(
id: ast::Ident,
attrs: &[ast::Attribute],
dir_path: &Path,
codemap: &codemap::CodeMap,
) -> PathBuf {
if let Some(path) = parser::Parser::submod_path_from_attr(attrs, dir_path) {
return path;
}