Skip to content

Commit 698f299

Browse files
committed
remove index canonical name
1 parent 0d71487 commit 698f299

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

crates/bindings-macro/src/table.rs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::sats;
22
use crate::sym;
3-
use crate::util::{check_duplicate, check_duplicate_msg, ident_to_litstr, match_meta};
3+
use crate::util::{check_duplicate, check_duplicate_msg, match_meta};
44
use core::slice;
55
use heck::ToSnakeCase;
66
use proc_macro2::{Span, TokenStream};
@@ -176,7 +176,6 @@ impl ScheduledArg {
176176
impl IndexArg {
177177
fn parse_meta(meta: ParseNestedMeta) -> syn::Result<Self> {
178178
let mut accessor = None;
179-
let mut _name = None;
180179
let mut algo = None;
181180

182181
meta.parse_nested_meta(|meta| {
@@ -185,11 +184,6 @@ impl IndexArg {
185184
check_duplicate(&accessor, &meta)?;
186185
accessor = Some(meta.value()?.parse()?);
187186
}
188-
sym::name => {
189-
check_duplicate(&_name, &meta)?;
190-
let litstr: LitStr = meta.value()?.parse()?;
191-
_name = Some(litstr);
192-
}
193187
sym::btree => {
194188
check_duplicate_msg(&algo, &meta, "index algorithm specified twice")?;
195189
algo = Some(Self::parse_btree(meta)?);
@@ -273,8 +267,6 @@ impl IndexArg {
273267
/// Parses an inline `#[index(btree)]`, `#[index(hash)]`, or `#[index(direct)]` attribute on a field.
274268
fn parse_index_attr(field: &Ident, attr: &syn::Attribute) -> syn::Result<Self> {
275269
let mut kind = None;
276-
let mut accessor: Option<Ident> = None;
277-
let mut _name: Option<LitStr> = None;
278270
attr.parse_nested_meta(|meta| {
279271
match_meta!(match meta {
280272
sym::btree => {
@@ -293,22 +285,14 @@ impl IndexArg {
293285
check_duplicate_msg(&kind, &meta, "index type specified twice")?;
294286
kind = Some(IndexType::Direct { column: field.clone() })
295287
}
296-
sym::accessor => {
297-
check_duplicate(&accessor, &meta)?;
298-
accessor = Some(meta.value()?.parse()?);
299-
}
300-
sym::name => {
301-
check_duplicate(&_name, &meta)?;
302-
_name = Some(meta.value()?.parse()?);
303-
}
304288
});
305289
Ok(())
306290
})?;
307291
let kind =
308292
kind.ok_or_else(|| syn::Error::new_spanned(&attr.meta, "must specify kind of index (`btree` , `direct`)"))?;
309293

310294
// Default accessor = field name if not provided
311-
let accessor = accessor.unwrap_or_else(|| field.clone());
295+
let accessor = field.clone();
312296
Ok(IndexArg::new(accessor, kind))
313297
}
314298

@@ -457,14 +441,12 @@ impl ValidatedIndex<'_> {
457441
})
458442
}
459443
};
460-
let accessor_name = ident_to_litstr(self.accessor_name);
461-
let index_name = &self.index_name;
444+
let source_name = self.index_name.clone();
462445
// Note: we do not pass the index_name through here.
463446
// We trust the schema validation logic to reconstruct the name we've stored in `self.name`.
464447
//TODO(shub): pass generated index name instead of accessor name as source_name
465448
quote!(spacetimedb::table::IndexDesc {
466-
source_name: #accessor_name,
467-
index_name: #index_name,
449+
source_name: #source_name,
468450
algo: #algo,
469451
})
470452
}
@@ -1066,9 +1048,11 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R
10661048
let trait_def = quote_spanned! {table_ident.span()=>
10671049
#[allow(non_camel_case_types, dead_code)]
10681050
#vis trait #table_ident {
1051+
#[allow(non_camel_case_types, dead_code)]
10691052
fn #table_ident(&self) -> &#tablehandle_ident;
10701053
}
10711054
impl #table_ident for spacetimedb::Local {
1055+
#[allow(non_camel_case_types, dead_code)]
10721056
fn #table_ident(&self) -> &#tablehandle_ident {
10731057
&#tablehandle_ident {}
10741058
}
@@ -1078,6 +1062,7 @@ pub(crate) fn table_impl(mut args: TableArgs, item: &syn::DeriveInput) -> syn::R
10781062
let trait_def_view = quote_spanned! {table_ident.span()=>
10791063
#[allow(non_camel_case_types, dead_code)]
10801064
#vis trait #view_trait_ident {
1065+
#[allow(non_camel_case_types, dead_code)]
10811066
fn #table_ident(&self) -> &#viewhandle_ident;
10821067
}
10831068
impl #view_trait_ident for spacetimedb::LocalReadOnly {

crates/bindings/src/table.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ pub trait TableInternal: Sized {
140140
#[derive(Clone, Copy)]
141141
pub struct IndexDesc<'a> {
142142
pub source_name: &'a str,
143-
pub index_name: &'a str,
144143
pub algo: IndexAlgo<'a>,
145144
}
146145

0 commit comments

Comments
 (0)