From 61f3a438d3a729a6be941bca1ff4c6a97a33f221 Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Mon, 15 Oct 2018 17:44:23 -0400 Subject: Cargo Format Run `cargo fmt` and ignore generated files --- crates/ra_syntax/src/ast/generated.rs | 2 ++ crates/ra_syntax/src/ast/generated.rs.tera | 2 ++ crates/ra_syntax/src/ast/mod.rs | 24 +++++++++++------------- 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 160d186b8..a15e00176 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1,6 +1,8 @@ // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run // Do not edit manually +#![cfg_attr(rustfmt, rustfmt_skip)] + use crate::{ ast, SyntaxNodeRef, AstNode, diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index 5cb7a35ed..d2a281137 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera @@ -3,6 +3,8 @@ the below applies to the result of this template #}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run // Do not edit manually +#![cfg_attr(rustfmt, rustfmt_skip)] + use crate::{ ast, SyntaxNodeRef, AstNode, diff --git a/crates/ra_syntax/src/ast/mod.rs b/crates/ra_syntax/src/ast/mod.rs index 88193a1ed..34958b6cb 100644 --- a/crates/ra_syntax/src/ast/mod.rs +++ b/crates/ra_syntax/src/ast/mod.rs @@ -4,15 +4,18 @@ use std::marker::PhantomData; use itertools::Itertools; +pub use self::generated::*; use crate::{ - SmolStr, SyntaxNodeRef, SyntaxKind::*, yellow::{RefRoot, SyntaxNodeChildren}, + SmolStr, + SyntaxKind::*, + SyntaxNodeRef, }; -pub use self::generated::*; pub trait AstNode<'a>: Clone + Copy + 'a { fn cast(syntax: SyntaxNodeRef<'a>) -> Option - where Self: Sized; + where + Self: Sized; fn syntax(self) -> SyntaxNodeRef<'a>; } @@ -64,9 +67,7 @@ pub trait AttrsOwner<'a>: AstNode<'a> { impl<'a> FnDef<'a> { pub fn has_atom_attr(&self, atom: &str) -> bool { - self.attrs() - .filter_map(|x| x.as_atom()) - .any(|x| x == atom) + self.attrs().filter_map(|x| x.as_atom()).any(|x| x == atom) } } @@ -135,7 +136,7 @@ pub enum CommentFlavor { Line, Doc, ModuleDoc, - Multiline + Multiline, } impl CommentFlavor { @@ -145,7 +146,7 @@ impl CommentFlavor { Line => "//", Doc => "///", ModuleDoc => "//!", - Multiline => "/*" + Multiline => "/*", } } } @@ -166,16 +167,14 @@ impl<'a> Whitespace<'a> { impl<'a> Name<'a> { pub fn text(&self) -> SmolStr { - let ident = self.syntax().first_child() - .unwrap(); + let ident = self.syntax().first_child().unwrap(); ident.leaf_text().unwrap().clone() } } impl<'a> NameRef<'a> { pub fn text(&self) -> SmolStr { - let ident = self.syntax().first_child() - .unwrap(); + let ident = self.syntax().first_child().unwrap(); ident.leaf_text().unwrap().clone() } } @@ -241,7 +240,6 @@ fn children<'a, P: AstNode<'a>, C: AstNode<'a>>(parent: P) -> AstChildren<'a, C> AstChildren::new(parent.syntax()) } - #[derive(Debug)] pub struct AstChildren<'a, N> { inner: SyntaxNodeChildren>, -- cgit v1.2.3