Skip to content

Commit

Permalink
Uses _ instead of dead_code where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarik Eshaq committed Dec 19, 2021
1 parent 3033e50 commit b1dba83
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 44 deletions.
6 changes: 3 additions & 3 deletions components/fxa-client/src/internal/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ pub enum PushPayload {
Unknown,
}

// Some of this structs fields are not read, except
// when deserialized, we mark them as dead_code
#[allow(dead_code)]
#[derive(Debug, Deserialize)]
pub struct CommandReceivedPushPayload {
#[allow(dead_code)]
command: String,
index: u64,
#[allow(dead_code)]
sender: String,
#[allow(dead_code)]
url: String,
}

Expand Down
12 changes: 6 additions & 6 deletions components/places/src/bookmark_sync/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2909,11 +2909,11 @@ mod tests {
let info_for_a = get_raw_bookmark(&writer, &guid_for_a)
.expect("Should fetch info for A")
.unwrap();
assert_eq!(info_for_a.sync_change_counter, 2);
assert_eq!(info_for_a._sync_change_counter, 2);
let info_for_unfiled = get_raw_bookmark(&writer, &BookmarkRootGuid::Unfiled.as_guid())
.expect("Should fetch info for unfiled")
.unwrap();
assert_eq!(info_for_unfiled.sync_change_counter, 2);
assert_eq!(info_for_unfiled._sync_change_counter, 2);

engine
.sync_finished(
Expand All @@ -2929,11 +2929,11 @@ mod tests {
let info_for_a = get_raw_bookmark(&writer, &guid_for_a)
.expect("Should fetch info for A")
.unwrap();
assert_eq!(info_for_a.sync_change_counter, 0);
assert_eq!(info_for_a._sync_change_counter, 0);
let info_for_unfiled = get_raw_bookmark(&writer, &BookmarkRootGuid::Unfiled.as_guid())
.expect("Should fetch info for unfiled")
.unwrap();
assert_eq!(info_for_unfiled.sync_change_counter, 0);
assert_eq!(info_for_unfiled._sync_change_counter, 0);

let mut tags_for_c = tags::get_tags_for_url(
&writer,
Expand Down Expand Up @@ -4322,8 +4322,8 @@ mod tests {
let bm = get_raw_bookmark(&writer, &guid.into())
.expect("must work")
.expect("must exist");
assert_eq!(bm.sync_status, SyncStatus::Normal, "{}", guid);
assert_eq!(bm.sync_change_counter, 0, "{}", guid);
assert_eq!(bm._sync_status, SyncStatus::Normal, "{}", guid);
assert_eq!(bm._sync_change_counter, 0, "{}", guid);
}
// And bookmarkEEEE wasn't on the server, so should be outgoing, and
// it's parent too.
Expand Down
45 changes: 20 additions & 25 deletions components/places/src/storage/bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,13 +1119,11 @@ pub fn insert_tree(db: &PlacesDb, tree: &FolderNode) -> Result<()> {
#[derive(Debug)]
struct FetchedTreeRow {
level: u32,
#[allow(dead_code)]
id: RowId,
_id: RowId,
guid: SyncGuid,
// parent and parent_guid are Option<> only to handle the root - we would
// assert but they aren't currently used.
#[allow(dead_code)]
parent: Option<RowId>,
_parent: Option<RowId>,
parent_guid: Option<SyncGuid>,
node_type: BookmarkType,
position: u32,
Expand All @@ -1140,9 +1138,9 @@ impl FetchedTreeRow {
let url = row.get::<_, Option<String>>("url")?;
Ok(Self {
level: row.get("level")?,
id: row.get::<_, RowId>("id")?,
_id: row.get::<_, RowId>("id")?,
guid: row.get::<_, String>("guid")?.into(),
parent: row.get::<_, Option<RowId>>("parent")?,
_parent: row.get::<_, Option<RowId>>("parent")?,
parent_guid: row
.get::<_, Option<String>>("parentGuid")?
.map(SyncGuid::from),
Expand Down Expand Up @@ -1372,13 +1370,10 @@ pub(crate) struct RawBookmark {
pub date_added: Timestamp,
pub date_modified: Timestamp,
pub guid: SyncGuid,
#[allow(dead_code)]
pub sync_status: SyncStatus,
#[allow(dead_code)]
pub sync_change_counter: u32,
pub _sync_status: SyncStatus,
pub _sync_change_counter: u32,
pub child_count: u32,
#[allow(dead_code)]
pub grandparent_id: Option<RowId>,
pub _grandparent_id: Option<RowId>,
}

impl RawBookmark {
Expand All @@ -1401,12 +1396,12 @@ impl RawBookmark {
date_added: row.get("dateAdded")?,
date_modified: row.get("lastModified")?,
guid: row.get::<_, String>("guid")?.into(),
sync_status: SyncStatus::from_u8(row.get::<_, u8>("_syncStatus")?),
sync_change_counter: row
_sync_status: SyncStatus::from_u8(row.get::<_, u8>("_syncStatus")?),
_sync_change_counter: row
.get::<_, Option<u32>>("syncChangeCounter")?
.unwrap_or_default(),
child_count: row.get("_childCount")?,
grandparent_id: row.get("_grandparentId")?,
_grandparent_id: row.get("_grandparentId")?,
})
}
}
Expand Down Expand Up @@ -1679,14 +1674,14 @@ mod tests {
assert_eq!(rb.position, 0);
assert_eq!(rb.title, Some("the title".into()));
assert_eq!(rb.url, Some(url));
assert_eq!(rb.sync_status, SyncStatus::New);
assert_eq!(rb.sync_change_counter, 1);
assert_eq!(rb._sync_status, SyncStatus::New);
assert_eq!(rb._sync_change_counter, 1);
assert!(global_change_tracker.changed());
assert_eq!(rb.child_count, 0);

let unfiled = get_raw_bookmark(&conn, &BookmarkRootGuid::Unfiled.as_guid())?
.expect("should get unfiled");
assert_eq!(unfiled.sync_change_counter, 1);
assert_eq!(unfiled._sync_change_counter, 1);

Ok(())
}
Expand Down Expand Up @@ -2101,7 +2096,7 @@ mod tests {
)?;
let bm = get_raw_bookmark(&conn, &guid)?.expect("should exist");
assert_eq!(bm.title, Some("the bookmark".to_string()));
assert_eq!(bm.sync_change_counter, 0);
assert_eq!(bm._sync_change_counter, 0);

// Update to the same value is still not a change.
update_bookmark(
Expand All @@ -2115,7 +2110,7 @@ mod tests {
)?;
let bm = get_raw_bookmark(&conn, &guid)?.expect("should exist");
assert_eq!(bm.title, Some("the bookmark".to_string()));
assert_eq!(bm.sync_change_counter, 0);
assert_eq!(bm._sync_change_counter, 0);

// Update to an empty string sets it to null
update_bookmark(
Expand All @@ -2129,7 +2124,7 @@ mod tests {
)?;
let bm = get_raw_bookmark(&conn, &guid)?.expect("should exist");
assert_eq!(bm.title, None);
assert_eq!(bm.sync_change_counter, 1);
assert_eq!(bm._sync_change_counter, 1);

Ok(())
}
Expand Down Expand Up @@ -2574,15 +2569,15 @@ mod tests {

let bmk = get_raw_bookmark(&conn, &"bookmarkAAAA".into())?
.expect("Should fetch A before resetting");
assert_eq!(bmk.sync_change_counter, 0);
assert_eq!(bmk.sync_status, SyncStatus::Normal);
assert_eq!(bmk._sync_change_counter, 0);
assert_eq!(bmk._sync_status, SyncStatus::Normal);

bookmark_sync::reset(&conn, &EngineSyncAssociation::Disconnected)?;

let bmk = get_raw_bookmark(&conn, &"bookmarkAAAA".into())?
.expect("Should fetch A after resetting");
assert_eq!(bmk.sync_change_counter, 1);
assert_eq!(bmk.sync_status, SyncStatus::New);
assert_eq!(bmk._sync_change_counter, 1);
assert_eq!(bmk._sync_status, SyncStatus::New);

// Ensure we reset Sync metadata, too.
let global = get_meta::<SyncGuid>(&conn, GLOBAL_SYNCID_META_KEY)?;
Expand Down
5 changes: 2 additions & 3 deletions components/support/nimbus-fml/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,7 @@ pub struct Parser {
enums: Vec<EnumDef>,
objects: Vec<ObjectDef>,
features: Vec<FeatureDef>,
#[allow(dead_code)]
channels: Vec<String>,
_channels: Vec<String>,
}

impl Parser {
Expand All @@ -481,7 +480,7 @@ impl Parser {
enums,
objects,
features,
channels: manifest.channels,
_channels: manifest.channels,
})
}

Expand Down
5 changes: 2 additions & 3 deletions components/sync15/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,7 @@ mod test {
#[derive(Debug, Clone)]
struct PostedData {
body: String,
#[allow(dead_code)]
xius: ServerTimestamp,
_xius: ServerTimestamp,
batch: Option<String>,
commit: bool,
payload_bytes: usize,
Expand Down Expand Up @@ -610,7 +609,7 @@ mod test {
let mut post = PostedData {
body: String::from_utf8(body.into()).expect("Posted invalid utf8..."),
batch: batch.clone(),
xius,
_xius: xius,
commit,
payload_bytes: 0,
records: 0,
Expand Down
26 changes: 23 additions & 3 deletions examples/places-autocomplete/src/autocomplete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,45 @@ struct ImportPlacesOptions {

#[derive(Default, Debug, Clone)]
struct LegacyPlaceVisit {
_id: i64,
date: i64,
visit_type: u8,
_from_visit: i64,
}

#[derive(Default, Debug, Clone)]
struct LegacyPlace {
id: i64,
_guid: String,
url: String,
title: Option<String>,
_title: Option<String>,
_hidden: i64,
_typed: i64,
_last_visit_date: i64,
_visit_count: i64,
_description: Option<String>,
_preview_image_url: Option<String>,
visits: Vec<LegacyPlaceVisit>,
}

impl LegacyPlace {
pub fn from_row(row: &rusqlite::Row<'_>) -> Self {
Self {
id: row.get_unwrap("place_id"),
title: row.get_unwrap("place_title"),
_guid: row.get_unwrap("place_guid"),
_title: row.get_unwrap("place_title"),
url: row.get_unwrap("place_url"),
_description: row.get_unwrap("place_description"),
_preview_image_url: row.get_unwrap("place_preview_image_url"),
_typed: row.get_unwrap("place_typed"),
_hidden: row.get_unwrap("place_hidden"),
_visit_count: row.get_unwrap("place_visit_count"),
_last_visit_date: row.get_unwrap("place_last_visit_date"),
visits: vec![LegacyPlaceVisit {
_id: row.get_unwrap("visit_id"),
date: row.get_unwrap("visit_date"),
visit_type: row.get_unwrap("visit_type"),
_from_visit: row.get_unwrap("visit_from_visit"),
}],
}
}
Expand All @@ -56,7 +74,7 @@ impl LegacyPlace {
VisitTransition::from_primitive(v.visit_type).unwrap_or(VisitTransition::Link),
)
.with_at(types::Timestamp((v.date / 1000) as u64))
.with_title(self.title.clone())
.with_title(self._title.clone())
.with_is_remote(rand::random::<f64>() < options.remote_probability);
places::storage::history::apply_observation_direct(db, obs)?;
}
Expand Down Expand Up @@ -140,8 +158,10 @@ fn import_places(
let id: i64 = row.get("place_id")?;
if current_place.id == id {
current_place.visits.push(LegacyPlaceVisit {
_id: row.get("visit_id")?,
date: row.get("visit_date")?,
visit_type: row.get("visit_type")?,
_from_visit: row.get("visit_from_visit")?,
});
continue;
}
Expand Down
1 change: 0 additions & 1 deletion megazords/ios-rust/build-xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ CFLAGS_x86_64_apple_ios="-target x86_64-apple-ios" \
cargo_build x86_64-apple-ios

# Hardware iOS targets
rustup target add aarch64-apple-ios-sim
cargo_build aarch64-apple-ios

# M1 iOS simulator.
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ targets = [
"x86_64-linux-android",
"aarch64-apple-ios",
"x86_64-apple-ios",
"aarch64-apple-ios-sim"
]
# The "rust-src" component is currently required for building for the M1 iOS simulator.
components = ["clippy", "rustfmt", "rust-src"]

0 comments on commit b1dba83

Please sign in to comment.