Skip to content

Commit 3e6ca41

Browse files
authored
Updating Rust to 1.91.0 (#7099)
This matches the FF desktop version for 147. Adding automatic and suggested changes from `cargo clippy --all-targets --all-features --fix`.
1 parent 21bb603 commit 3e6ca41

File tree

20 files changed

+49
-72
lines changed

20 files changed

+49
-72
lines changed

components/ads-client/src/http_cache/store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl HttpCacheStore {
5353
}
5454

5555
#[cfg(test)]
56-
pub fn get_clock(&self) -> &(dyn Clock) {
56+
pub fn get_clock(&self) -> &dyn Clock {
5757
&*self.clock
5858
}
5959

components/nimbus/src/schema.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,17 +278,13 @@ impl From<Branch> for ExperimentBranch {
278278
// ⚠️ in `test_lib_bw_compat`, and may require a DB migration. ⚠️
279279
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
280280
#[serde(rename_all = "snake_case")]
281+
#[derive(Default)]
281282
pub enum RandomizationUnit {
283+
#[default]
282284
NimbusId,
283285
UserId,
284286
}
285287

286-
impl Default for RandomizationUnit {
287-
fn default() -> Self {
288-
Self::NimbusId
289-
}
290-
}
291-
292288
#[derive(Default)]
293289
pub struct AvailableRandomizationUnits {
294290
pub user_id: Option<String>,

components/nimbus/src/stateful/gecko_prefs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl GeckoPrefStore {
160160
Ok(())
161161
}
162162

163-
pub fn get_mutable_pref_state(&self) -> MutexGuard<GeckoPrefStoreState> {
163+
pub fn get_mutable_pref_state(&self) -> MutexGuard<'_, GeckoPrefStoreState> {
164164
self.state
165165
.lock()
166166
.expect("Unable to lock GeckoPrefStore state")

components/nimbus/src/stateful/persistence.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,14 @@ pub struct SingleStoreDatabase {
273273

274274
impl SingleStoreDatabase {
275275
/// Function used to obtain a "reader" which is used for read-only transactions.
276-
pub fn read(&self) -> Result<Reader> {
276+
pub fn read(&self) -> Result<Reader<'_>> {
277277
Ok(self.rkv.read()?)
278278
}
279279

280280
/// Function used to obtain a "writer" which is used for transactions.
281281
/// The `writer.commit();` must be called to commit data added via the
282282
/// writer.
283-
pub fn write(&self) -> Result<Writer> {
283+
pub fn write(&self) -> Result<Writer<'_>> {
284284
Ok(self.rkv.write()?)
285285
}
286286

@@ -588,14 +588,14 @@ impl Database {
588588
}
589589

590590
/// Function used to obtain a "reader" which is used for read-only transactions.
591-
pub fn read(&self) -> Result<Reader> {
591+
pub fn read(&self) -> Result<Reader<'_>> {
592592
Ok(self.rkv.read()?)
593593
}
594594

595595
/// Function used to obtain a "writer" which is used for transactions.
596596
/// The `writer.commit();` must be called to commit data added via the
597597
/// writer.
598-
pub fn write(&self) -> Result<Writer> {
598+
pub fn write(&self) -> Result<Writer<'_>> {
599599
Ok(self.rkv.write()?)
600600
}
601601

components/nimbus/src/tests/stateless/test_cirrus_client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
AppContext, CirrusClient, EnrollmentRequest, EnrollmentResponse, EnrollmentStatus, Result,
1313
};
1414
use serde_json::{from_str, to_string, to_value, Map, Value};
15-
use std::collections::HashMap;
15+
use std::{collections::HashMap, slice};
1616

1717
fn create_client() -> Result<CirrusClient> {
1818
let metrics_handler = TestMetrics::new();
@@ -42,7 +42,7 @@ fn test_can_enroll() -> Result<()> {
4242
let client = create_client()?;
4343
let exp = helpers::get_experiment_with_newtab_feature_branches();
4444
client
45-
.set_experiments(to_string(&HashMap::from([("data", &[exp.clone()])])).unwrap())
45+
.set_experiments(to_string(&HashMap::from([("data", slice::from_ref(&exp))])).unwrap())
4646
.unwrap();
4747

4848
let result = client.enroll("test".to_string(), Default::default(), &[])?;
@@ -70,7 +70,7 @@ fn test_will_not_enroll_if_previously_did_not_enroll() -> Result<()> {
7070
let client = create_client()?;
7171
let exp = helpers::get_experiment_with_newtab_feature_branches();
7272
client
73-
.set_experiments(to_string(&HashMap::from([("data", &[exp.clone()])])).unwrap())
73+
.set_experiments(to_string(&HashMap::from([("data", slice::from_ref(&exp))])).unwrap())
7474
.unwrap();
7575

7676
let enrollment = ExperimentEnrollment {
@@ -94,7 +94,7 @@ fn test_handle_enrollment_works_with_json() -> Result<()> {
9494
"language == 'en' && region == 'US'",
9595
);
9696
client
97-
.set_experiments(to_string(&HashMap::from([("data", &[exp.clone()])])).unwrap())
97+
.set_experiments(to_string(&HashMap::from([("data", slice::from_ref(&exp))])).unwrap())
9898
.unwrap();
9999

100100
let request = Map::from_iter(vec![
@@ -193,7 +193,7 @@ fn test_sends_metrics_on_enrollment() -> Result<()> {
193193
)?;
194194
let exp = helpers::get_experiment_with_newtab_feature_branches();
195195
client
196-
.set_experiments(to_string(&HashMap::from([("data", &[exp.clone()])])).unwrap())
196+
.set_experiments(to_string(&HashMap::from([("data", slice::from_ref(&exp))])).unwrap())
197197
.unwrap();
198198
client.enroll("test".to_string(), Default::default(), &[])?;
199199

components/nimbus/src/tests/test_schema.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,7 @@
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44

55
use crate::{error::Result, FeatureConfig};
6-
use serde::{Deserialize, Serialize};
7-
use serde_json::{json, Map, Value};
8-
9-
#[derive(Deserialize, Serialize, Debug, Clone)]
10-
#[serde(rename_all = "camelCase")]
11-
pub struct FeatureConfigProposed {
12-
pub enabled: bool,
13-
pub feature_id: String,
14-
#[serde(default)]
15-
pub value: Map<String, Value>,
16-
}
6+
use serde_json::json;
177

188
#[test]
199
fn test_deserialize_untyped_json() -> Result<()> {

components/push/src/internal/config.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,14 @@ use crate::PushError;
1818
///
1919
/// Please contact services back-end for any additional bridge protocols.
2020
///
21-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
21+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
2222
pub enum BridgeType {
23+
#[default]
2324
Fcm,
2425
Adm,
2526
Apns,
2627
}
2728

28-
#[cfg(test)]
29-
// To avoid a future footgun, the default implementation is only for tests
30-
impl Default for BridgeType {
31-
fn default() -> Self {
32-
Self::Fcm
33-
}
34-
}
35-
3629
impl Display for BridgeType {
3730
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3831
write!(

components/remote_settings/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ impl GetItemsOptions {
11421142
}
11431143

11441144
/// Returns an iterator of (name, value) query pairs for these options.
1145-
pub fn iter_query_pairs(&self) -> impl Iterator<Item = (Cow<str>, Cow<str>)> {
1145+
pub fn iter_query_pairs(&self) -> impl Iterator<Item = (Cow<'_, str>, Cow<'_, str>)> {
11461146
self.filters
11471147
.iter()
11481148
.map(Filter::as_query_pair)
@@ -1202,7 +1202,7 @@ enum Filter {
12021202
}
12031203

12041204
impl Filter {
1205-
fn as_query_pair(&self) -> (Cow<str>, Cow<str>) {
1205+
fn as_query_pair(&self) -> (Cow<'_, str>, Cow<'_, str>) {
12061206
// For filters (https://docs.kinto-storage.org/en/latest/api/1.x/filtering.html),
12071207
// the query pair syntax is `[operator_]field=value` for each field.
12081208
match self {
@@ -1224,7 +1224,7 @@ impl Filter {
12241224
struct Sort(String, SortOrder);
12251225

12261226
impl Sort {
1227-
fn as_query_value(&self) -> Cow<str> {
1227+
fn as_query_value(&self) -> Cow<'_, str> {
12281228
match self.1 {
12291229
SortOrder::Ascending => self.0.as_str().into(),
12301230
SortOrder::Descending => format!("-{}", self.0).into(),
@@ -2241,7 +2241,7 @@ IKdcFKAt3fFrpyMhlfIKkLfmm0iDjmfmIXbDGBJw9SE=
22412241
fn test_valid_signature_after_retry() -> Result<()> {
22422242
ensure_initialized();
22432243
run_client_sync(
2244-
&vec![RemoteSettingsRecord {
2244+
&[RemoteSettingsRecord {
22452245
id: "bad-record".to_string(),
22462246
last_modified: 9999,
22472247
deleted: true,

components/remote_settings/src/signatures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod tests {
6767
fn test_records_canonicaljson_serialization() {
6868
let bytes = serialize_data(
6969
1337,
70-
&vec![RemoteSettingsRecord {
70+
&[RemoteSettingsRecord {
7171
last_modified: 42,
7272
id: "bonjour".into(),
7373
deleted: false,
@@ -84,7 +84,7 @@ mod tests {
8484
fn test_records_canonicaljson_serialization_with_attachment() {
8585
let bytes = serialize_data(
8686
1337,
87-
&vec![RemoteSettingsRecord {
87+
&[RemoteSettingsRecord {
8888
last_modified: 42,
8989
id: "bonjour".into(),
9090
deleted: true,

components/search/src/sort_helpers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ mod tests {
164164
fn test_sort_engines_by_order_hint() {
165165
let default_engine_id = None;
166166
let default_private_engine_id = None;
167-
let mut engines = vec![
167+
let mut engines = [
168168
create_engine("c-engine", Some(3), None),
169169
create_engine("b-engine", Some(2), None),
170170
create_engine("a-engine", Some(1), None),
@@ -190,7 +190,7 @@ mod tests {
190190
fn test_sort_engines_alphabetically_without_order_hint() {
191191
let default_engine_id = None;
192192
let default_private_engine_id = None;
193-
let mut engines = vec![
193+
let mut engines = [
194194
create_engine("c-engine", None, None),
195195
create_engine("b-engine", None, None),
196196
create_engine("a-engine", None, None),
@@ -216,7 +216,7 @@ mod tests {
216216
fn test_sort_engines_by_order_hint_and_alphabetically() {
217217
let default_engine_id = None;
218218
let default_private_engine_id = None;
219-
let mut engines = vec![
219+
let mut engines = [
220220
// Identifiers are the opposite order to the names, so that we
221221
// can show that we are sorting alphabetically by name.
222222
create_engine("d-engine", None, Some("Charlie")),
@@ -249,7 +249,7 @@ mod tests {
249249
fn test_sort_engines_with_defaults() {
250250
let default_engine_id = Some("a-engine".to_string());
251251
let default_private_engine_id = Some("b-engine".to_string());
252-
let mut engines = vec![
252+
let mut engines = [
253253
create_engine("c-engine", Some(3), None),
254254
create_engine("a-engine", Some(1), None), // Default engine should be first
255255
create_engine("b-engine", Some(2), None), // Default private engine should be second

0 commit comments

Comments
 (0)