Revert style preference-related fixes

This commit is contained in:
Igor Aleksanov 2020-08-12 14:08:55 +03:00
parent d180b8bbe8
commit fcd4b0176f
5 changed files with 21 additions and 21 deletions

View file

@ -106,7 +106,6 @@ struct FlycheckActor {
cargo_handle: Option<CargoHandle>, cargo_handle: Option<CargoHandle>,
} }
#[allow(clippy::large_enum_variant)]
enum Event { enum Event {
Restart(Restart), Restart(Restart),
CheckEvent(Option<cargo_metadata::Message>), CheckEvent(Option<cargo_metadata::Message>),

View file

@ -13,18 +13,18 @@ pub struct ArenaMap<ID, V> {
impl<T, V> ArenaMap<Idx<T>, V> { impl<T, V> ArenaMap<Idx<T>, V> {
pub fn insert(&mut self, id: Idx<T>, t: V) { pub fn insert(&mut self, id: Idx<T>, t: V) {
let idx = Self::into_idx(id); let idx = Self::to_idx(id);
self.v.resize_with((idx + 1).max(self.v.len()), || None); self.v.resize_with((idx + 1).max(self.v.len()), || None);
self.v[idx] = Some(t); self.v[idx] = Some(t);
} }
pub fn get(&self, id: Idx<T>) -> Option<&V> { pub fn get(&self, id: Idx<T>) -> Option<&V> {
self.v.get(Self::into_idx(id)).and_then(|it| it.as_ref()) self.v.get(Self::to_idx(id)).and_then(|it| it.as_ref())
} }
pub fn get_mut(&mut self, id: Idx<T>) -> Option<&mut V> { pub fn get_mut(&mut self, id: Idx<T>) -> Option<&mut V> {
self.v.get_mut(Self::into_idx(id)).and_then(|it| it.as_mut()) self.v.get_mut(Self::to_idx(id)).and_then(|it| it.as_mut())
} }
pub fn values(&self) -> impl Iterator<Item = &V> { pub fn values(&self) -> impl Iterator<Item = &V> {
@ -39,7 +39,7 @@ impl<T, V> ArenaMap<Idx<T>, V> {
self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?))) self.v.iter().enumerate().filter_map(|(idx, o)| Some((Self::from_idx(idx), o.as_ref()?)))
} }
fn into_idx(id: Idx<T>) -> usize { fn to_idx(id: Idx<T>) -> usize {
u32::from(id.into_raw()) as usize u32::from(id.into_raw()) as usize
} }
@ -51,7 +51,7 @@ impl<T, V> ArenaMap<Idx<T>, V> {
impl<T, V> std::ops::Index<Idx<V>> for ArenaMap<Idx<V>, T> { impl<T, V> std::ops::Index<Idx<V>> for ArenaMap<Idx<V>, T> {
type Output = T; type Output = T;
fn index(&self, id: Idx<V>) -> &T { fn index(&self, id: Idx<V>) -> &T {
self.v[Self::into_idx(id)].as_ref().unwrap() self.v[Self::to_idx(id)].as_ref().unwrap()
} }
} }

View file

@ -243,11 +243,13 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
// test lambda_ret_block // test lambda_ret_block
// fn main() { || -> i32 { 92 }(); } // fn main() { || -> i32 { 92 }(); }
block_expr(p); block_expr(p);
} else if p.at_ts(EXPR_FIRST) { } else {
if p.at_ts(EXPR_FIRST) {
expr(p); expr(p);
} else { } else {
p.error("expected expression"); p.error("expected expression");
} }
}
m.complete(p, CLOSURE_EXPR) m.complete(p, CLOSURE_EXPR)
} }

View file

@ -19,9 +19,6 @@ impl FileSet {
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.files.len() self.files.len()
} }
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> { pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
let mut base = self.paths[&anchor].clone(); let mut base = self.paths[&anchor].clone();
base.pop(); base.pop();

View file

@ -91,7 +91,8 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result<String> {
support::children(&self.syntax) support::children(&self.syntax)
} }
} }
} else if let Some(token_kind) = field.token_kind() { } else {
if let Some(token_kind) = field.token_kind() {
quote! { quote! {
pub fn #method_name(&self) -> Option<#ty> { pub fn #method_name(&self) -> Option<#ty> {
support::token(&self.syntax, #token_kind) support::token(&self.syntax, #token_kind)
@ -104,6 +105,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result<String> {
} }
} }
} }
}
}); });
( (
quote! { quote! {