Skip to content

Commit

Permalink
Merge pull request #1354 from google/remove-unused-fields
Browse files Browse the repository at this point in the history
Remove redundant fields.
  • Loading branch information
adetaylor authored Jan 9, 2024
2 parents 2f84e49 + b78edba commit e0923cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
6 changes: 3 additions & 3 deletions engine/src/conversion/analysis/fun/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub(crate) enum ReceiverMutability {

#[derive(Clone, Debug)]
pub(crate) enum MethodKind {
Normal(ReceiverMutability),
Normal,
Constructor { is_default: bool },
Static,
Virtual(ReceiverMutability),
Expand Down Expand Up @@ -964,7 +964,7 @@ impl<'a> FnAnalyzer<'a> {
let receiver_mutability =
receiver_mutability.expect("Failed to find receiver details");
match fun.virtualness {
Virtualness::None => MethodKind::Normal(receiver_mutability),
Virtualness::None => MethodKind::Normal,
Virtualness::Virtual => MethodKind::Virtual(receiver_mutability),
Virtualness::PureVirtual => MethodKind::PureVirtual(receiver_mutability),
}
Expand Down Expand Up @@ -1152,7 +1152,7 @@ impl<'a> FnAnalyzer<'a> {
ref impl_for,
method_kind:
MethodKind::Constructor { .. }
| MethodKind::Normal(..)
| MethodKind::Normal
| MethodKind::PureVirtual(..)
| MethodKind::Virtual(..),
..
Expand Down
33 changes: 12 additions & 21 deletions engine/src/parse_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use quote::ToTokens;
use std::{io::Read, path::PathBuf};
use std::{panic::UnwindSafe, path::Path, rc::Rc};
use syn::spanned::Spanned;
use syn::{token::Brace, Item, ItemMod};
use syn::Item;
use thiserror::Error;

/// Errors which may occur when parsing a Rust source file to discover
Expand Down Expand Up @@ -119,7 +119,7 @@ fn parse_file_contents(
Segment::Cxx(CxxBridge::from(itm))
}
Item::Mod(itm) => {
if let Some((brace, items)) = itm.content {
if let Some((_, items)) = itm.content {
let mut mod_state = State {
auto_allowlist: self.auto_allowlist,
..Default::default()
Expand All @@ -137,18 +137,9 @@ fn parse_file_contents(
}
self.extra_superclasses.extend(mod_state.extra_superclasses);
self.discoveries.extend(mod_state.discoveries);
Segment::Mod(
mod_state.results,
(
brace,
ItemMod {
content: None,
..itm
},
),
)
Segment::Mod(mod_state.results)
} else {
Segment::Other(Item::Mod(itm))
Segment::Other
}
}
Item::Struct(ref its) => {
Expand Down Expand Up @@ -189,13 +180,13 @@ fn parse_file_contents(
self.discoveries
.search_item(&item, mod_path)
.map_err(ParseError::Discovery)?;
Segment::Other(item)
Segment::Other
}
_ => {
self.discoveries
.search_item(&item, mod_path)
.map_err(ParseError::Discovery)?;
Segment::Other(item)
Segment::Other
}
};
self.results.push(result);
Expand Down Expand Up @@ -283,8 +274,8 @@ pub struct ParsedFile(Vec<Segment>);
enum Segment {
Autocxx(IncludeCppEngine),
Cxx(CxxBridge),
Mod(Vec<Segment>, (Brace, ItemMod)),
Other(Item),
Mod(Vec<Segment>),
Other,
}

pub trait CppBuildable {
Expand All @@ -303,7 +294,7 @@ impl ParsedFile {
.flat_map(|s| -> Box<dyn Iterator<Item = &IncludeCppEngine>> {
match s {
Segment::Autocxx(includecpp) => Box::new(std::iter::once(includecpp)),
Segment::Mod(segments, _) => Box::new(do_get_autocxxes(segments)),
Segment::Mod(segments) => Box::new(do_get_autocxxes(segments)),
_ => Box::new(std::iter::empty()),
}
})
Expand Down Expand Up @@ -331,7 +322,7 @@ impl ParsedFile {
Segment::Cxx(cxxbridge) => {
Box::new(std::iter::once(cxxbridge as &dyn CppBuildable))
}
Segment::Mod(segments, _) => Box::new(do_get_cpp_buildables(segments)),
Segment::Mod(segments) => Box::new(do_get_cpp_buildables(segments)),
_ => Box::new(std::iter::empty()),
}
})
Expand All @@ -349,7 +340,7 @@ impl ParsedFile {
.flat_map(|s| -> Box<dyn Iterator<Item = &mut IncludeCppEngine>> {
match s {
Segment::Autocxx(includecpp) => Box::new(std::iter::once(includecpp)),
Segment::Mod(segments, _) => Box::new(do_get_autocxxes_mut(segments)),
Segment::Mod(segments) => Box::new(do_get_autocxxes_mut(segments)),
_ => Box::new(std::iter::empty()),
}
})
Expand All @@ -368,7 +359,7 @@ impl ParsedFile {
.flat_map(|s| -> Box<dyn Iterator<Item = &PathBuf>> {
match s {
Segment::Autocxx(includecpp) => Box::new(includecpp.include_dirs()),
Segment::Mod(segments, _) => Box::new(do_get_include_dirs(segments)),
Segment::Mod(segments) => Box::new(do_get_include_dirs(segments)),
_ => Box::new(std::iter::empty()),
}
})
Expand Down

0 comments on commit e0923cf

Please sign in to comment.