aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-06-12 00:06:28 +0100
committerVeetaha <[email protected]>2020-06-12 00:56:06 +0100
commit4fefc7d06c8da093e783852c5f0d3aea31e2c939 (patch)
tree0446115971bcfc749d68e8504f8b0d629732946e
parent36353bb1827dbd2efcde2d18c8598c4cc5e2e296 (diff)
Simplify
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs10
-rw-r--r--xtask/src/codegen/gen_syntax.rs2
2 files changed, 6 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs
index 56378385a..2e72d4927 100644
--- a/crates/ra_syntax/src/ast/tokens.rs
+++ b/crates/ra_syntax/src/ast/tokens.rs
@@ -84,7 +84,7 @@ impl Whitespace {
84} 84}
85 85
86pub struct QuoteOffsets { 86pub struct QuoteOffsets {
87 pub quotes: [TextRange; 2], 87 pub quotes: (TextRange, TextRange),
88 pub contents: TextRange, 88 pub contents: TextRange,
89} 89}
90 90
@@ -103,7 +103,7 @@ impl QuoteOffsets {
103 let end = TextSize::of(literal); 103 let end = TextSize::of(literal);
104 104
105 let res = QuoteOffsets { 105 let res = QuoteOffsets {
106 quotes: [TextRange::new(start, left_quote), TextRange::new(right_quote, end)], 106 quotes: (TextRange::new(start, left_quote), TextRange::new(right_quote, end)),
107 contents: TextRange::new(left_quote, right_quote), 107 contents: TextRange::new(left_quote, right_quote),
108 }; 108 };
109 Some(res) 109 Some(res)
@@ -116,17 +116,17 @@ pub trait HasQuotes: AstToken {
116 let offsets = QuoteOffsets::new(text)?; 116 let offsets = QuoteOffsets::new(text)?;
117 let o = self.syntax().text_range().start(); 117 let o = self.syntax().text_range().start();
118 let offsets = QuoteOffsets { 118 let offsets = QuoteOffsets {
119 quotes: [offsets.quotes[0] + o, offsets.quotes[1] + o], 119 quotes: (offsets.quotes.0 + o, offsets.quotes.1 + o),
120 contents: offsets.contents + o, 120 contents: offsets.contents + o,
121 }; 121 };
122 Some(offsets) 122 Some(offsets)
123 } 123 }
124 fn open_quote_text_range(&self) -> Option<TextRange> { 124 fn open_quote_text_range(&self) -> Option<TextRange> {
125 self.quote_offsets().map(|it| it.quotes[0]) 125 self.quote_offsets().map(|it| it.quotes.0)
126 } 126 }
127 127
128 fn close_quote_text_range(&self) -> Option<TextRange> { 128 fn close_quote_text_range(&self) -> Option<TextRange> {
129 self.quote_offsets().map(|it| it.quotes[1]) 129 self.quote_offsets().map(|it| it.quotes.1)
130 } 130 }
131 131
132 fn text_range_between_quotes(&self) -> Option<TextRange> { 132 fn text_range_between_quotes(&self) -> Option<TextRange> {
diff --git a/xtask/src/codegen/gen_syntax.rs b/xtask/src/codegen/gen_syntax.rs
index 19d5594f5..f8b34638b 100644
--- a/xtask/src/codegen/gen_syntax.rs
+++ b/xtask/src/codegen/gen_syntax.rs
@@ -68,7 +68,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
68 .iter() 68 .iter()
69 .map(|node| { 69 .map(|node| {
70 let name = format_ident!("{}", node.name); 70 let name = format_ident!("{}", node.name);
71 let kind = format_ident!("{}", to_upper_snake_case(&name.to_string())); 71 let kind = format_ident!("{}", to_upper_snake_case(node.name));
72 let traits = node.traits.iter().map(|trait_name| { 72 let traits = node.traits.iter().map(|trait_name| {
73 let trait_name = format_ident!("{}", trait_name); 73 let trait_name = format_ident!("{}", trait_name);
74 quote!(impl ast::#trait_name for #name {}) 74 quote!(impl ast::#trait_name for #name {})