Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/ads-client/src/http_cache/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl HttpCacheStore {
}

#[cfg(test)]
pub fn get_clock(&self) -> &(dyn Clock) {
pub fn get_clock(&self) -> &dyn Clock {
&*self.clock
}

Expand Down
8 changes: 2 additions & 6 deletions components/nimbus/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,17 +278,13 @@ impl From<Branch> for ExperimentBranch {
// ⚠️ in `test_lib_bw_compat`, and may require a DB migration. ⚠️
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
#[derive(Default)]
pub enum RandomizationUnit {
#[default]
NimbusId,
UserId,
}

impl Default for RandomizationUnit {
fn default() -> Self {
Self::NimbusId
}
}

#[derive(Default)]
pub struct AvailableRandomizationUnits {
pub user_id: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion components/nimbus/src/stateful/gecko_prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl GeckoPrefStore {
Ok(())
}

pub fn get_mutable_pref_state(&self) -> MutexGuard<GeckoPrefStoreState> {
pub fn get_mutable_pref_state(&self) -> MutexGuard<'_, GeckoPrefStoreState> {
self.state
.lock()
.expect("Unable to lock GeckoPrefStore state")
Expand Down
8 changes: 4 additions & 4 deletions components/nimbus/src/stateful/persistence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ pub struct SingleStoreDatabase {

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

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

Expand Down Expand Up @@ -588,14 +588,14 @@ impl Database {
}

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

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

Expand Down
10 changes: 5 additions & 5 deletions components/nimbus/src/tests/stateless/test_cirrus_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
AppContext, CirrusClient, EnrollmentRequest, EnrollmentResponse, EnrollmentStatus, Result,
};
use serde_json::{from_str, to_string, to_value, Map, Value};
use std::collections::HashMap;
use std::{collections::HashMap, slice};

fn create_client() -> Result<CirrusClient> {
let metrics_handler = TestMetrics::new();
Expand Down Expand Up @@ -42,7 +42,7 @@ fn test_can_enroll() -> Result<()> {
let client = create_client()?;
let exp = helpers::get_experiment_with_newtab_feature_branches();
client
.set_experiments(to_string(&HashMap::from([("data", &[exp.clone()])])).unwrap())
.set_experiments(to_string(&HashMap::from([("data", slice::from_ref(&exp))])).unwrap())
.unwrap();

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

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

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

Expand Down
12 changes: 1 addition & 11 deletions components/nimbus/src/tests/test_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::{error::Result, FeatureConfig};
use serde::{Deserialize, Serialize};
use serde_json::{json, Map, Value};

#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct FeatureConfigProposed {
pub enabled: bool,
pub feature_id: String,
#[serde(default)]
pub value: Map<String, Value>,
}
use serde_json::json;

#[test]
fn test_deserialize_untyped_json() -> Result<()> {
Expand Down
11 changes: 2 additions & 9 deletions components/push/src/internal/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,14 @@ use crate::PushError;
///
/// Please contact services back-end for any additional bridge protocols.
///
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
pub enum BridgeType {
#[default]
Fcm,
Adm,
Apns,
}

#[cfg(test)]
// To avoid a future footgun, the default implementation is only for tests
impl Default for BridgeType {
fn default() -> Self {
Self::Fcm
}
}

impl Display for BridgeType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
Expand Down
8 changes: 4 additions & 4 deletions components/remote_settings/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ impl GetItemsOptions {
}

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

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

impl Sort {
fn as_query_value(&self) -> Cow<str> {
fn as_query_value(&self) -> Cow<'_, str> {
match self.1 {
SortOrder::Ascending => self.0.as_str().into(),
SortOrder::Descending => format!("-{}", self.0).into(),
Expand Down Expand Up @@ -2241,7 +2241,7 @@ IKdcFKAt3fFrpyMhlfIKkLfmm0iDjmfmIXbDGBJw9SE=
fn test_valid_signature_after_retry() -> Result<()> {
ensure_initialized();
run_client_sync(
&vec![RemoteSettingsRecord {
&[RemoteSettingsRecord {
id: "bad-record".to_string(),
last_modified: 9999,
deleted: true,
Expand Down
4 changes: 2 additions & 2 deletions components/remote_settings/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod tests {
fn test_records_canonicaljson_serialization() {
let bytes = serialize_data(
1337,
&vec![RemoteSettingsRecord {
&[RemoteSettingsRecord {
last_modified: 42,
id: "bonjour".into(),
deleted: false,
Expand All @@ -84,7 +84,7 @@ mod tests {
fn test_records_canonicaljson_serialization_with_attachment() {
let bytes = serialize_data(
1337,
&vec![RemoteSettingsRecord {
&[RemoteSettingsRecord {
last_modified: 42,
id: "bonjour".into(),
deleted: true,
Expand Down
8 changes: 4 additions & 4 deletions components/search/src/sort_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ mod tests {
fn test_sort_engines_by_order_hint() {
let default_engine_id = None;
let default_private_engine_id = None;
let mut engines = vec![
let mut engines = [
create_engine("c-engine", Some(3), None),
create_engine("b-engine", Some(2), None),
create_engine("a-engine", Some(1), None),
Expand All @@ -190,7 +190,7 @@ mod tests {
fn test_sort_engines_alphabetically_without_order_hint() {
let default_engine_id = None;
let default_private_engine_id = None;
let mut engines = vec![
let mut engines = [
create_engine("c-engine", None, None),
create_engine("b-engine", None, None),
create_engine("a-engine", None, None),
Expand All @@ -216,7 +216,7 @@ mod tests {
fn test_sort_engines_by_order_hint_and_alphabetically() {
let default_engine_id = None;
let default_private_engine_id = None;
let mut engines = vec![
let mut engines = [
// Identifiers are the opposite order to the names, so that we
// can show that we are sorting alphabetically by name.
create_engine("d-engine", None, Some("Charlie")),
Expand Down Expand Up @@ -249,7 +249,7 @@ mod tests {
fn test_sort_engines_with_defaults() {
let default_engine_id = Some("a-engine".to_string());
let default_private_engine_id = Some("b-engine".to_string());
let mut engines = vec![
let mut engines = [
create_engine("c-engine", Some(3), None),
create_engine("a-engine", Some(1), None), // Default engine should be first
create_engine("b-engine", Some(2), None), // Default private engine should be second
Expand Down
2 changes: 1 addition & 1 deletion components/suggest/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl SuggestDb {
/// if [Self::interrupt_handle::interrupt] is called after the operation starts. Calling
/// [Self::write] multiple times during the operation risks missing a call that happens after
/// between those calls.
pub fn write_scope(&self) -> Result<WriteScope> {
pub fn write_scope(&self) -> Result<WriteScope<'_>> {
Ok(WriteScope {
conn: self.conn.lock(),
scope: self.interrupt_handle.begin_interrupt_scope()?,
Expand Down
2 changes: 1 addition & 1 deletion components/suggest/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ where
(name, count)
})
.collect();
table_names_with_counts.sort_by(|a, b| (b.1.cmp(&a.1)));
table_names_with_counts.sort_by(|a, b| b.1.cmp(&a.1));
table_names_with_counts
}

Expand Down
12 changes: 6 additions & 6 deletions components/support/error/tests/macro_arguments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ error[E0277]: the trait bound `String: GetErrorHandling` is not satisfied
note: required by a bound in `convert_log_report_error`
--> $WORKSPACE/components/support/error/src/handling.rs
|
| pub fn convert_log_report_error<IE, EE>(e: IE) -> EE
94 | pub fn convert_log_report_error<IE, EE>(e: IE) -> EE
| ------------------------ required by a bound in this function
| where
| IE: GetErrorHandling<ExternalError = EE> + std::error::Error,
95 | where
96 | IE: GetErrorHandling<ExternalError = EE> + std::error::Error,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `convert_log_report_error`
= note: this error originates in the attribute macro `handle_error` (in Nightly builds, run with -Z macro-backtrace for more info)

Expand All @@ -82,9 +82,9 @@ error[E0277]: the trait bound `String: std::error::Error` is not satisfied
note: required by a bound in `convert_log_report_error`
--> $WORKSPACE/components/support/error/src/handling.rs
|
| pub fn convert_log_report_error<IE, EE>(e: IE) -> EE
94 | pub fn convert_log_report_error<IE, EE>(e: IE) -> EE
| ------------------------ required by a bound in this function
| where
| IE: GetErrorHandling<ExternalError = EE> + std::error::Error,
95 | where
96 | IE: GetErrorHandling<ExternalError = EE> + std::error::Error,
| ^^^^^^^^^^^^^^^^^ required by this bound in `convert_log_report_error`
= note: this error originates in the attribute macro `handle_error` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ use super::filters;

use super::common::{self, code_type};

pub struct ObjectRuntime;

impl CodeDeclaration for ObjectRuntime {}

pub struct ObjectCodeType {
id: String,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ use super::filters;

use super::common::{self, code_type};

pub struct ObjectRuntime;

impl CodeDeclaration for ObjectRuntime {}

pub struct ObjectCodeType {
id: String,
}
Expand Down
3 changes: 3 additions & 0 deletions components/support/nimbus-fml/src/editing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod error_kind;
mod error_path;
mod values_finder;

#[cfg(feature = "client-lib")]
pub(crate) use cursor_position::{CursorPosition, CursorSpan};
pub(crate) use error_converter::ErrorConverter;
pub(crate) use error_kind::ErrorKind;
Expand All @@ -18,6 +19,7 @@ pub(crate) struct FeatureValidationError {
pub(crate) kind: ErrorKind,
}

#[cfg(feature = "client-lib")]
#[derive(Debug, PartialEq, Default)]
pub struct FmlEditorError {
/// The message to display to the user.
Expand All @@ -34,6 +36,7 @@ pub struct FmlEditorError {
pub col: u32,
}

#[cfg(feature = "client-lib")]
#[derive(Debug, Default, PartialEq)]
pub struct CorrectionCandidate {
/// The string that should be inserted into the source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ impl FeatureManifest {
}

#[allow(unused)]
pub(crate) fn iter_imported_files(&self) -> Vec<ImportedModule> {
pub(crate) fn iter_imported_files(&self) -> Vec<ImportedModule<'_>> {
let map = &self.all_imports;

self.imported_features
Expand Down
Loading