Rename non-Ident fields previously named ident
It will be clearer to avoid using 'ident' to refer to anything but Ident.
diff --git a/syntax/check.rs b/syntax/check.rs
index ba488e1..e8a6448 100644
--- a/syntax/check.rs
+++ b/syntax/check.rs
@@ -167,16 +167,16 @@
}
fn check_api_struct(cx: &mut Check, strct: &Struct) {
- let ident = &strct.ident;
- check_reserved_name(cx, &ident.rust);
+ let name = &strct.name;
+ check_reserved_name(cx, &name.rust);
if strct.fields.is_empty() {
let span = span_for_struct_error(strct);
cx.error(span, "structs without any fields are not supported");
}
- if cx.types.cxx.contains(&ident.rust) {
- if let Some(ety) = cx.types.untrusted.get(&ident.rust) {
+ if cx.types.cxx.contains(&name.rust) {
+ if let Some(ety) = cx.types.untrusted.get(&name.rust) {
let msg = "extern shared struct must be declared in an `unsafe extern` block";
cx.error(ety, msg);
}
@@ -198,7 +198,7 @@
}
fn check_api_enum(cx: &mut Check, enm: &Enum) {
- check_reserved_name(cx, &enm.ident.rust);
+ check_reserved_name(cx, &enm.name.rust);
if enm.variants.is_empty() {
let span = span_for_enum_error(enm);
@@ -207,13 +207,13 @@
}
fn check_api_type(cx: &mut Check, ety: &ExternType) {
- check_reserved_name(cx, &ety.ident.rust);
+ check_reserved_name(cx, &ety.name.rust);
- if let Some(reason) = cx.types.required_trivial.get(&ety.ident.rust) {
+ if let Some(reason) = cx.types.required_trivial.get(&ety.name.rust) {
let what = match reason {
- TrivialReason::StructField(strct) => format!("a field of `{}`", strct.ident.rust),
- TrivialReason::FunctionArgument(efn) => format!("an argument of `{}`", efn.ident.rust),
- TrivialReason::FunctionReturn(efn) => format!("a return value of `{}`", efn.ident.rust),
+ TrivialReason::StructField(strct) => format!("a field of `{}`", strct.name.rust),
+ TrivialReason::FunctionArgument(efn) => format!("an argument of `{}`", efn.name.rust),
+ TrivialReason::FunctionReturn(efn) => format!("a return value of `{}`", efn.name.rust),
};
let msg = format!(
"needs a cxx::ExternType impl in order to be used as {}",
diff --git a/syntax/ident.rs b/syntax/ident.rs
index bb2fe46..aaf7832 100644
--- a/syntax/ident.rs
+++ b/syntax/ident.rs
@@ -24,28 +24,28 @@
match api {
Api::Include(_) | Api::Impl(_) => {}
Api::Struct(strct) => {
- check_ident(cx, &strct.ident);
+ check_ident(cx, &strct.name);
for field in &strct.fields {
check(cx, &field.ident);
}
}
Api::Enum(enm) => {
- check_ident(cx, &enm.ident);
+ check_ident(cx, &enm.name);
for variant in &enm.variants {
check(cx, &variant.ident);
}
}
Api::CxxType(ety) | Api::RustType(ety) => {
- check_ident(cx, &ety.ident);
+ check_ident(cx, &ety.name);
}
Api::CxxFunction(efn) | Api::RustFunction(efn) => {
- check(cx, &efn.ident.rust);
+ check(cx, &efn.name.rust);
for arg in &efn.args {
check(cx, &arg.ident);
}
}
Api::TypeAlias(alias) => {
- check_ident(cx, &alias.ident);
+ check_ident(cx, &alias.name);
}
}
}
diff --git a/syntax/mangle.rs b/syntax/mangle.rs
index 55ffca5..cc5115a 100644
--- a/syntax/mangle.rs
+++ b/syntax/mangle.rs
@@ -15,13 +15,13 @@
Some(receiver) => {
let receiver_ident = types.resolve(&receiver.ty);
join!(
- efn.ident.namespace,
+ efn.name.namespace,
CXXBRIDGE,
receiver_ident.cxx,
- efn.ident.rust
+ efn.name.rust
)
}
- None => join!(efn.ident.namespace, CXXBRIDGE, efn.ident.rust),
+ None => join!(efn.name.namespace, CXXBRIDGE, efn.name.rust),
}
}
diff --git a/syntax/mod.rs b/syntax/mod.rs
index 782d617..ac6350a 100644
--- a/syntax/mod.rs
+++ b/syntax/mod.rs
@@ -67,7 +67,7 @@
pub struct ExternType {
pub doc: Doc,
pub type_token: Token![type],
- pub ident: Pair,
+ pub name: Pair,
pub semi_token: Token![;],
pub trusted: bool,
}
@@ -76,7 +76,7 @@
pub doc: Doc,
pub derives: Vec<Derive>,
pub struct_token: Token![struct],
- pub ident: Pair,
+ pub name: Pair,
pub brace_token: Brace,
pub fields: Vec<Var>,
}
@@ -84,7 +84,7 @@
pub struct Enum {
pub doc: Doc,
pub enum_token: Token![enum],
- pub ident: Pair,
+ pub name: Pair,
pub brace_token: Brace,
pub variants: Vec<Variant>,
pub repr: Atom,
@@ -93,7 +93,7 @@
pub struct ExternFn {
pub lang: Lang,
pub doc: Doc,
- pub ident: Pair,
+ pub name: Pair,
pub sig: Signature,
pub semi_token: Token![;],
}
@@ -101,7 +101,7 @@
pub struct TypeAlias {
pub doc: Doc,
pub type_token: Token![type],
- pub ident: Pair,
+ pub name: Pair,
pub eq_token: Token![=],
pub ty: RustType,
pub semi_token: Token![;],
diff --git a/syntax/parse.rs b/syntax/parse.rs
index 6b5d925..2136653 100644
--- a/syntax/parse.rs
+++ b/syntax/parse.rs
@@ -90,7 +90,7 @@
doc,
derives,
struct_token: item.struct_token,
- ident: Pair::new(namespace.clone(), item.ident),
+ name: Pair::new(namespace.clone(), item.ident),
brace_token: fields.brace_token,
fields: fields
.named
@@ -177,7 +177,7 @@
Ok(Api::Enum(Enum {
doc,
enum_token,
- ident: Pair::new(namespace, item.ident),
+ name: Pair::new(namespace, item.ident),
brace_token,
variants,
repr,
@@ -241,8 +241,8 @@
}
let mut types = items.iter().filter_map(|item| match item {
- Api::CxxType(ety) | Api::RustType(ety) => Some(&ety.ident),
- Api::TypeAlias(alias) => Some(&alias.ident),
+ Api::CxxType(ety) | Api::RustType(ety) => Some(&ety.name),
+ Api::TypeAlias(alias) => Some(&alias.name),
_ => None,
});
if let (Some(single_type), None) = (types.next(), types.next()) {
@@ -305,7 +305,7 @@
Ok(api_type(ExternType {
doc,
type_token,
- ident: Pair::new(namespace, ident),
+ name: Pair::new(namespace, ident),
semi_token,
trusted,
}))
@@ -404,7 +404,7 @@
let throws = throws_tokens.is_some();
let unsafety = foreign_fn.sig.unsafety;
let fn_token = foreign_fn.sig.fn_token;
- let ident = Pair::new_from_differing_names(
+ let name = Pair::new_from_differing_names(
namespace,
cxx_name.unwrap_or(foreign_fn.sig.ident.clone()),
rust_name.unwrap_or(foreign_fn.sig.ident.clone()),
@@ -419,7 +419,7 @@
Ok(api_function(ExternFn {
lang,
doc,
- ident,
+ name,
sig: Signature {
unsafety,
fn_token,
@@ -468,7 +468,7 @@
Ok(TypeAlias {
doc,
type_token,
- ident: Pair::new(namespace, ident),
+ name: Pair::new(namespace, ident),
eq_token,
ty,
semi_token,
diff --git a/syntax/tokens.rs b/syntax/tokens.rs
index 2b32532..15c23dc 100644
--- a/syntax/tokens.rs
+++ b/syntax/tokens.rs
@@ -85,7 +85,7 @@
fn to_tokens(&self, tokens: &mut TokenStream) {
// Notional token range for error reporting purposes.
self.type_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
+ self.name.to_tokens(tokens);
}
}
@@ -93,7 +93,7 @@
fn to_tokens(&self, tokens: &mut TokenStream) {
// Notional token range for error reporting purposes.
self.type_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
+ self.name.to_tokens(tokens);
}
}
@@ -101,7 +101,7 @@
fn to_tokens(&self, tokens: &mut TokenStream) {
// Notional token range for error reporting purposes.
self.struct_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
+ self.name.to_tokens(tokens);
}
}
@@ -109,7 +109,7 @@
fn to_tokens(&self, tokens: &mut TokenStream) {
// Notional token range for error reporting purposes.
self.enum_token.to_tokens(tokens);
- self.ident.to_tokens(tokens);
+ self.name.to_tokens(tokens);
}
}
diff --git a/syntax/types.rs b/syntax/types.rs
index d9d6361..67b041b 100644
--- a/syntax/types.rs
+++ b/syntax/types.rs
@@ -70,7 +70,7 @@
match api {
Api::Include(_) => {}
Api::Struct(strct) => {
- let ident = &strct.ident.rust;
+ let ident = &strct.name.rust;
if !type_names.insert(ident)
&& (!cxx.contains(ident)
|| structs.contains_key(ident)
@@ -81,14 +81,14 @@
// type, then error.
duplicate_name(cx, strct, ident);
}
- structs.insert(&strct.ident.rust, strct);
+ structs.insert(&strct.name.rust, strct);
for field in &strct.fields {
visit(&mut all, &field.ty);
}
- add_resolution(&strct.ident);
+ add_resolution(&strct.name);
}
Api::Enum(enm) => {
- let ident = &enm.ident.rust;
+ let ident = &enm.name.rust;
if !type_names.insert(ident)
&& (!cxx.contains(ident)
|| structs.contains_key(ident)
@@ -100,10 +100,10 @@
duplicate_name(cx, enm, ident);
}
enums.insert(ident, enm);
- add_resolution(&enm.ident);
+ add_resolution(&enm.name);
}
Api::CxxType(ety) => {
- let ident = &ety.ident.rust;
+ let ident = &ety.name.rust;
if !type_names.insert(ident)
&& (cxx.contains(ident)
|| !structs.contains_key(ident) && !enums.contains_key(ident))
@@ -117,21 +117,21 @@
if !ety.trusted {
untrusted.insert(ident, ety);
}
- add_resolution(&ety.ident);
+ add_resolution(&ety.name);
}
Api::RustType(ety) => {
- let ident = &ety.ident.rust;
+ let ident = &ety.name.rust;
if !type_names.insert(ident) {
duplicate_name(cx, ety, ident);
}
rust.insert(ident);
- add_resolution(&ety.ident);
+ add_resolution(&ety.name);
}
Api::CxxFunction(efn) | Api::RustFunction(efn) => {
// Note: duplication of the C++ name is fine because C++ has
// function overloading.
- if !function_names.insert((&efn.receiver, &efn.ident.rust)) {
- duplicate_name(cx, efn, &efn.ident.rust);
+ if !function_names.insert((&efn.receiver, &efn.name.rust)) {
+ duplicate_name(cx, efn, &efn.name.rust);
}
for arg in &efn.args {
visit(&mut all, &arg.ty);
@@ -141,13 +141,13 @@
}
}
Api::TypeAlias(alias) => {
- let ident = &alias.ident;
- if !type_names.insert(&ident.rust) {
- duplicate_name(cx, alias, &ident.rust);
+ let ident = &alias.name.rust;
+ if !type_names.insert(ident) {
+ duplicate_name(cx, alias, ident);
}
- cxx.insert(&ident.rust);
- aliases.insert(&ident.rust, alias);
- add_resolution(&alias.ident);
+ cxx.insert(ident);
+ aliases.insert(ident, alias);
+ add_resolution(&alias.name);
}
Api::Impl(imp) => {
visit(&mut all, &imp.ty);