Skip to content

Commit 4fefc7d

Browse files
committed
Simplify
1 parent 36353bb commit 4fefc7d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

crates/ra_syntax/src/ast/tokens.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl Whitespace {
8484
}
8585

8686
pub struct QuoteOffsets {
87-
pub quotes: [TextRange; 2],
87+
pub quotes: (TextRange, TextRange),
8888
pub contents: TextRange,
8989
}
9090

@@ -103,7 +103,7 @@ impl QuoteOffsets {
103103
let end = TextSize::of(literal);
104104

105105
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)),
107107
contents: TextRange::new(left_quote, right_quote),
108108
};
109109
Some(res)
@@ -116,17 +116,17 @@ pub trait HasQuotes: AstToken {
116116
let offsets = QuoteOffsets::new(text)?;
117117
let o = self.syntax().text_range().start();
118118
let offsets = QuoteOffsets {
119-
quotes: [offsets.quotes[0] + o, offsets.quotes[1] + o],
119+
quotes: (offsets.quotes.0 + o, offsets.quotes.1 + o),
120120
contents: offsets.contents + o,
121121
};
122122
Some(offsets)
123123
}
124124
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)
126126
}
127127

128128
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)
130130
}
131131

132132
fn text_range_between_quotes(&self) -> Option<TextRange> {

xtask/src/codegen/gen_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
6868
.iter()
6969
.map(|node| {
7070
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));
7272
let traits = node.traits.iter().map(|trait_name| {
7373
let trait_name = format_ident!("{}", trait_name);
7474
quote!(impl ast::#trait_name for #name {})

0 commit comments

Comments
 (0)