mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Restore cargo-fmt gating
This commit is contained in:
parent
1e19847af3
commit
680182d0a0
4 changed files with 12 additions and 19 deletions
|
@ -227,11 +227,9 @@ impl Module {
|
||||||
Some((name, def))
|
Some((name, def))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.flat_map(|(name, def)|
|
.flat_map(|(name, def)| {
|
||||||
ScopeDef::all_items(def)
|
ScopeDef::all_items(def).into_iter().map(move |item| (name.clone(), item))
|
||||||
.into_iter()
|
})
|
||||||
.map(move |item| (name.clone(), item))
|
|
||||||
)
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,10 +1296,8 @@ impl ScopeDef {
|
||||||
let mut items = ArrayVec::new();
|
let mut items = ArrayVec::new();
|
||||||
|
|
||||||
match (def.take_types(), def.take_values()) {
|
match (def.take_types(), def.take_values()) {
|
||||||
(Some(m1), None) =>
|
(Some(m1), None) => items.push(ScopeDef::ModuleDef(m1.into())),
|
||||||
items.push(ScopeDef::ModuleDef(m1.into())),
|
(None, Some(m2)) => items.push(ScopeDef::ModuleDef(m2.into())),
|
||||||
(None, Some(m2)) =>
|
|
||||||
items.push(ScopeDef::ModuleDef(m2.into())),
|
|
||||||
(Some(m1), Some(m2)) => {
|
(Some(m1), Some(m2)) => {
|
||||||
// Some items, like unit structs and enum variants, are
|
// Some items, like unit structs and enum variants, are
|
||||||
// returned as both a type and a value. Here we want
|
// returned as both a type and a value. Here we want
|
||||||
|
@ -1312,8 +1308,8 @@ impl ScopeDef {
|
||||||
} else {
|
} else {
|
||||||
items.push(ScopeDef::ModuleDef(m1.into()));
|
items.push(ScopeDef::ModuleDef(m1.into()));
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
(None, None) => {},
|
(None, None) => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(macro_def_id) = def.take_macros() {
|
if let Some(macro_def_id) = def.take_macros() {
|
||||||
|
|
|
@ -349,8 +349,8 @@ impl<'a, DB: HirDatabase> SemanticsScope<'a, DB> {
|
||||||
for item in items {
|
for item in items {
|
||||||
f(name.clone(), item);
|
f(name.clone(), item);
|
||||||
}
|
}
|
||||||
return
|
return;
|
||||||
},
|
}
|
||||||
resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()),
|
resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()),
|
||||||
resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()),
|
resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()),
|
||||||
resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }),
|
resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }),
|
||||||
|
|
|
@ -1005,5 +1005,4 @@ mod tests {
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,11 @@ pub fn project_root() -> PathBuf {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||||
|
let _dir = pushd(project_root());
|
||||||
ensure_rustfmt()?;
|
ensure_rustfmt()?;
|
||||||
|
|
||||||
if mode == Mode::Verify {
|
let check = if mode == Mode::Verify { "--check" } else { "" };
|
||||||
run!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN)?;
|
run!("rustup run {} -- cargo fmt -- {}", TOOLCHAIN, check)?;
|
||||||
} else {
|
|
||||||
run!("rustup run {} -- cargo fmt", TOOLCHAIN)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue