mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Revert style preference-related fixes
This commit is contained in:
parent
d180b8bbe8
commit
fcd4b0176f
5 changed files with 21 additions and 21 deletions
|
@ -106,7 +106,6 @@ struct FlycheckActor {
|
|||
cargo_handle: Option<CargoHandle>,
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
enum Event {
|
||||
Restart(Restart),
|
||||
CheckEvent(Option<cargo_metadata::Message>),
|
||||
|
|
|
@ -13,18 +13,18 @@ pub struct ArenaMap<ID, V> {
|
|||
|
||||
impl<T, V> ArenaMap<Idx<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[idx] = Some(t);
|
||||
}
|
||||
|
||||
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> {
|
||||
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> {
|
||||
|
@ -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()?)))
|
||||
}
|
||||
|
||||
fn into_idx(id: Idx<T>) -> usize {
|
||||
fn to_idx(id: Idx<T>) -> 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> {
|
||||
type Output = 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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -243,10 +243,12 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
|
|||
// test lambda_ret_block
|
||||
// fn main() { || -> i32 { 92 }(); }
|
||||
block_expr(p);
|
||||
} else if p.at_ts(EXPR_FIRST) {
|
||||
expr(p);
|
||||
} else {
|
||||
p.error("expected expression");
|
||||
if p.at_ts(EXPR_FIRST) {
|
||||
expr(p);
|
||||
} else {
|
||||
p.error("expected expression");
|
||||
}
|
||||
}
|
||||
m.complete(p, CLOSURE_EXPR)
|
||||
}
|
||||
|
|
|
@ -19,9 +19,6 @@ impl FileSet {
|
|||
pub fn len(&self) -> usize {
|
||||
self.files.len()
|
||||
}
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
pub fn resolve_path(&self, anchor: FileId, path: &str) -> Option<FileId> {
|
||||
let mut base = self.paths[&anchor].clone();
|
||||
base.pop();
|
||||
|
|
|
@ -91,16 +91,18 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> Result<String> {
|
|||
support::children(&self.syntax)
|
||||
}
|
||||
}
|
||||
} else if let Some(token_kind) = field.token_kind() {
|
||||
quote! {
|
||||
pub fn #method_name(&self) -> Option<#ty> {
|
||||
support::token(&self.syntax, #token_kind)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
pub fn #method_name(&self) -> Option<#ty> {
|
||||
support::child(&self.syntax)
|
||||
if let Some(token_kind) = field.token_kind() {
|
||||
quote! {
|
||||
pub fn #method_name(&self) -> Option<#ty> {
|
||||
support::token(&self.syntax, #token_kind)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
pub fn #method_name(&self) -> Option<#ty> {
|
||||
support::child(&self.syntax)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue