Skip to content
This repository was archived by the owner on Apr 9, 2020. It is now read-only.

Commit fed2ac8

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
rust: Head start on some upcoming warnings
Summary: This diff sets two Rust lints to warn in fbcode: ``` [rust] warn_lints = bare_trait_objects, ellipsis_inclusive_range_patterns ``` and fixes occurrences of those warnings within common/rust, hg, and mononoke. Both of these lints are set to warn by default starting with rustc 1.37. Enabling them early avoids writing even more new code that needs to be fixed when we pull in 1.37 in six weeks. Upstream tracking issue: rust-lang/rust#54910 Reviewed By: Imxset21 Differential Revision: D16200291 fbshipit-source-id: aca11a7a944e9fa95f94e226b52f6f053b97ec74
1 parent b9f18bd commit fed2ac8

File tree

47 files changed

+220
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+220
-215
lines changed

blobrepo/blob_changeset/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use mononoke_types::DateTime;
3434
/// 1. It ensures that the prefix applies first, which is important for shared caches like
3535
/// memcache.
3636
/// 2. It ensures that all possible blobrepos use a prefix.
37-
pub type RepoBlobstore = CensoredBlob<PrefixBlobstore<Arc<Blobstore>>>;
37+
pub type RepoBlobstore = CensoredBlob<PrefixBlobstore<Arc<dyn Blobstore>>>;
3838

3939
pub struct ChangesetMetadata {
4040
pub user: String,

blobrepo/changeset_fetcher/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ pub trait ChangesetFetcher: Send + Sync {
3030
cs_id: ChangesetId,
3131
) -> BoxFuture<Vec<ChangesetId>, Error>;
3232

33-
fn get_stats(&self) -> HashMap<String, Box<Any>> {
33+
fn get_stats(&self) -> HashMap<String, Box<dyn Any>> {
3434
HashMap::new()
3535
}
3636
}
3737

3838
/// Simplest ChangesetFetcher implementation which is just a wrapper around `Changesets` object
3939
pub struct SimpleChangesetFetcher {
40-
changesets: Arc<Changesets>,
40+
changesets: Arc<dyn Changesets>,
4141
repo_id: RepositoryId,
4242
}
4343

4444
impl SimpleChangesetFetcher {
45-
pub fn new(changesets: Arc<Changesets>, repo_id: RepositoryId) -> Self {
45+
pub fn new(changesets: Arc<dyn Changesets>, repo_id: RepositoryId) -> Self {
4646
Self {
4747
changesets,
4848
repo_id,

blobrepo/factory/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub fn new_memblob_empty(
186186
fn new_development<T: SqlFactory>(
187187
logger: Logger,
188188
sql_factory: &T,
189-
blobstore: Arc<Blobstore>,
189+
blobstore: Arc<dyn Blobstore>,
190190
censored_blobs: Option<HashMap<String, String>>,
191191
scuba_censored_table: Option<String>,
192192
repoid: RepositoryId,
@@ -226,7 +226,7 @@ fn new_development<T: SqlFactory>(
226226
fn new_production<T: SqlFactory>(
227227
logger: Logger,
228228
sql_factory: &T,
229-
blobstore: Arc<Blobstore>,
229+
blobstore: Arc<dyn Blobstore>,
230230
censored_blobs: Option<HashMap<String, String>>,
231231
scuba_censored_table: Option<String>,
232232
repoid: RepositoryId,
@@ -280,10 +280,9 @@ fn new_production<T: SqlFactory>(
280280
let changeset_fetcher_factory = {
281281
cloned!(changesets, repoid);
282282
move || {
283-
let res: Arc<ChangesetFetcher + Send + Sync> = Arc::new(SimpleChangesetFetcher::new(
284-
changesets.clone(),
285-
repoid.clone(),
286-
));
283+
let res: Arc<dyn ChangesetFetcher + Send + Sync> = Arc::new(
284+
SimpleChangesetFetcher::new(changesets.clone(), repoid.clone()),
285+
);
287286
res
288287
}
289288
};

blobrepo/src/manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl BlobManifest {
226226
}
227227

228228
impl Manifest for BlobManifest {
229-
fn lookup(&self, path: &MPathElement) -> Option<Box<Entry + Sync>> {
229+
fn lookup(&self, path: &MPathElement) -> Option<Box<dyn Entry + Sync>> {
230230
self.content.files.get(path).map({
231231
move |entry_id| {
232232
HgBlobEntry::new(
@@ -240,7 +240,7 @@ impl Manifest for BlobManifest {
240240
})
241241
}
242242

243-
fn list(&self) -> Box<Iterator<Item = Box<Entry + Sync>> + Send> {
243+
fn list(&self) -> Box<dyn Iterator<Item = Box<dyn Entry + Sync>> + Send> {
244244
let list_iter = self.content.files.clone().into_iter().map({
245245
let blobstore = self.blobstore.clone();
246246
move |(path, entry_id)| {

blobrepo/src/repo.rs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,33 @@ define_stats! {
115115
pub struct BlobRepo {
116116
logger: Logger,
117117
blobstore: RepoBlobstore,
118-
bookmarks: Arc<Bookmarks>,
119-
filenodes: Arc<Filenodes>,
120-
changesets: Arc<Changesets>,
121-
bonsai_hg_mapping: Arc<BonsaiHgMapping>,
118+
bookmarks: Arc<dyn Bookmarks>,
119+
filenodes: Arc<dyn Filenodes>,
120+
changesets: Arc<dyn Changesets>,
121+
bonsai_hg_mapping: Arc<dyn BonsaiHgMapping>,
122122
repoid: RepositoryId,
123123
// Returns new ChangesetFetcher that can be used by operation that work with commit graph
124124
// (for example, revsets).
125-
changeset_fetcher_factory: Arc<Fn() -> Arc<ChangesetFetcher + Send + Sync> + Send + Sync>,
126-
hg_generation_lease: Arc<LeaseOps>,
125+
changeset_fetcher_factory:
126+
Arc<dyn Fn() -> Arc<dyn ChangesetFetcher + Send + Sync> + Send + Sync>,
127+
hg_generation_lease: Arc<dyn LeaseOps>,
127128
}
128129

129130
impl BlobRepo {
130131
pub fn new(
131132
logger: Logger,
132-
bookmarks: Arc<Bookmarks>,
133+
bookmarks: Arc<dyn Bookmarks>,
133134
blobstore: RepoBlobstore,
134-
filenodes: Arc<Filenodes>,
135-
changesets: Arc<Changesets>,
136-
bonsai_hg_mapping: Arc<BonsaiHgMapping>,
135+
filenodes: Arc<dyn Filenodes>,
136+
changesets: Arc<dyn Changesets>,
137+
bonsai_hg_mapping: Arc<dyn BonsaiHgMapping>,
137138
repoid: RepositoryId,
138-
hg_generation_lease: Arc<LeaseOps>,
139+
hg_generation_lease: Arc<dyn LeaseOps>,
139140
) -> Self {
140141
let changeset_fetcher_factory = {
141142
cloned!(changesets, repoid);
142143
move || {
143-
let res: Arc<ChangesetFetcher + Send + Sync> = Arc::new(
144+
let res: Arc<dyn ChangesetFetcher + Send + Sync> = Arc::new(
144145
SimpleChangesetFetcher::new(changesets.clone(), repoid.clone()),
145146
);
146147
res
@@ -162,14 +163,16 @@ impl BlobRepo {
162163

163164
pub fn new_with_changeset_fetcher_factory(
164165
logger: Logger,
165-
bookmarks: Arc<Bookmarks>,
166+
bookmarks: Arc<dyn Bookmarks>,
166167
blobstore: RepoBlobstore,
167-
filenodes: Arc<Filenodes>,
168-
changesets: Arc<Changesets>,
169-
bonsai_hg_mapping: Arc<BonsaiHgMapping>,
168+
filenodes: Arc<dyn Filenodes>,
169+
changesets: Arc<dyn Changesets>,
170+
bonsai_hg_mapping: Arc<dyn BonsaiHgMapping>,
170171
repoid: RepositoryId,
171-
changeset_fetcher_factory: Arc<Fn() -> Arc<ChangesetFetcher + Send + Sync> + Send + Sync>,
172-
hg_generation_lease: Arc<LeaseOps>,
172+
changeset_fetcher_factory: Arc<
173+
dyn Fn() -> Arc<dyn ChangesetFetcher + Send + Sync> + Send + Sync,
174+
>,
175+
hg_generation_lease: Arc<dyn LeaseOps>,
173176
) -> Self {
174177
BlobRepo {
175178
logger,
@@ -643,7 +646,7 @@ impl BlobRepo {
643646
&self,
644647
ctx: CoreContext,
645648
manifestid: HgManifestId,
646-
) -> BoxFuture<Box<Manifest + Sync>, Error> {
649+
) -> BoxFuture<Box<dyn Manifest + Sync>, Error> {
647650
STATS::get_manifest_by_nodeid.add_value(1);
648651
BlobManifest::load(ctx, &self.blobstore, manifestid)
649652
.and_then(move |mf| mf.ok_or(ErrorKind::ManifestMissing(manifestid).into()))
@@ -764,7 +767,7 @@ impl BlobRepo {
764767
to_hg_bookmark_stream(&self, &ctx, stream)
765768
}
766769

767-
pub fn update_bookmark_transaction(&self, ctx: CoreContext) -> Box<bookmarks::Transaction> {
770+
pub fn update_bookmark_transaction(&self, ctx: CoreContext) -> Box<dyn bookmarks::Transaction> {
768771
STATS::update_bookmark_transaction.add_value(1);
769772
self.bookmarks.create_transaction(ctx, self.repoid)
770773
}
@@ -933,7 +936,7 @@ impl BlobRepo {
933936
.map(|res| res.map(|res| Generation::new(res.gen)))
934937
}
935938

936-
pub fn get_changeset_fetcher(&self) -> Arc<ChangesetFetcher> {
939+
pub fn get_changeset_fetcher(&self) -> Arc<dyn ChangesetFetcher> {
937940
(self.changeset_fetcher_factory)()
938941
}
939942

@@ -1042,7 +1045,7 @@ impl BlobRepo {
10421045
self.repoid
10431046
}
10441047

1045-
pub fn get_filenodes(&self) -> Arc<Filenodes> {
1048+
pub fn get_filenodes(&self) -> Arc<dyn Filenodes> {
10461049
self.filenodes.clone()
10471050
}
10481051

@@ -1719,7 +1722,7 @@ impl BlobRepo {
17191722
ctx: CoreContext,
17201723
repo: BlobRepo,
17211724
bcs_id: ChangesetId,
1722-
bonsai_hg_mapping: Arc<BonsaiHgMapping>,
1725+
bonsai_hg_mapping: Arc<dyn BonsaiHgMapping>,
17231726
) -> impl Future<Item = Vec<BonsaiChangeset>, Error = Error> {
17241727
let mut queue = VecDeque::new();
17251728
let mut visited: HashSet<ChangesetId> = HashSet::new();

blobrepo/test/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ fn test_get_manifest_from_bonsai() {
824824
};
825825
let get_entries = {
826826
cloned!(ctx, repo);
827-
move |ms_hash: HgManifestId| -> BoxFuture<HashMap<String, Box<Entry + Sync>>, Error> {
827+
move |ms_hash: HgManifestId| -> BoxFuture<HashMap<String, Box<dyn Entry + Sync>>, Error> {
828828
repo.get_manifest_by_nodeid(ctx.clone(), ms_hash)
829829
.map(|ms| {
830830
ms.list()

blobstore/multiplexedblob/src/base.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ pub trait MultiplexedBlobstorePutHandler: Send + Sync {
8989
}
9090

9191
pub struct MultiplexedBlobstoreBase {
92-
blobstores: Arc<[(BlobstoreId, Arc<Blobstore>)]>,
93-
handler: Arc<MultiplexedBlobstorePutHandler>,
92+
blobstores: Arc<[(BlobstoreId, Arc<dyn Blobstore>)]>,
93+
handler: Arc<dyn MultiplexedBlobstorePutHandler>,
9494
scuba_logger: Option<Arc<ScubaClient>>,
9595
}
9696

9797
impl MultiplexedBlobstoreBase {
9898
pub fn new(
99-
blobstores: Vec<(BlobstoreId, Arc<Blobstore>)>,
100-
handler: Arc<MultiplexedBlobstorePutHandler>,
99+
blobstores: Vec<(BlobstoreId, Arc<dyn Blobstore>)>,
100+
handler: Arc<dyn MultiplexedBlobstorePutHandler>,
101101
scuba_logger: Option<Arc<ScubaClient>>,
102102
) -> Self {
103103
Self {

blobstore/multiplexedblob/src/queue.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ use std::sync::Arc;
2222
pub struct MultiplexedBlobstore {
2323
repo_id: RepositoryId,
2424
blobstore: Arc<MultiplexedBlobstoreBase>,
25-
queue: Arc<BlobstoreSyncQueue>,
25+
queue: Arc<dyn BlobstoreSyncQueue>,
2626
}
2727

2828
impl MultiplexedBlobstore {
2929
pub fn new(
3030
repo_id: RepositoryId,
31-
blobstores: Vec<(BlobstoreId, Arc<Blobstore>)>,
32-
queue: Arc<BlobstoreSyncQueue>,
31+
blobstores: Vec<(BlobstoreId, Arc<dyn Blobstore>)>,
32+
queue: Arc<dyn BlobstoreSyncQueue>,
3333
scuba_logger: Option<Arc<ScubaClient>>,
3434
) -> Self {
3535
let put_handler = Arc::new(QueueBlobstorePutHandler {
@@ -58,7 +58,7 @@ impl fmt::Debug for MultiplexedBlobstore {
5858

5959
struct QueueBlobstorePutHandler {
6060
repo_id: RepositoryId,
61-
queue: Arc<BlobstoreSyncQueue>,
61+
queue: Arc<dyn BlobstoreSyncQueue>,
6262
}
6363

6464
impl MultiplexedBlobstorePutHandler for QueueBlobstorePutHandler {
@@ -151,8 +151,8 @@ pub struct ScrubBlobstore {
151151
impl ScrubBlobstore {
152152
pub fn new(
153153
repo_id: RepositoryId,
154-
blobstores: Vec<(BlobstoreId, Arc<Blobstore>)>,
155-
queue: Arc<BlobstoreSyncQueue>,
154+
blobstores: Vec<(BlobstoreId, Arc<dyn Blobstore>)>,
155+
queue: Arc<dyn BlobstoreSyncQueue>,
156156
scuba_logger: Option<Arc<ScubaClient>>,
157157
) -> Self {
158158
let inner = MultiplexedBlobstore::new(repo_id, blobstores, queue, scuba_logger);

blobstore_sync_queue/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub trait BlobstoreSyncQueue: Send + Sync {
8080
) -> BoxFuture<Vec<BlobstoreSyncQueueEntry>, Error>;
8181
}
8282

83-
impl BlobstoreSyncQueue for Arc<BlobstoreSyncQueue> {
83+
impl BlobstoreSyncQueue for Arc<dyn BlobstoreSyncQueue> {
8484
fn add(&self, ctx: CoreContext, entry: BlobstoreSyncQueueEntry) -> BoxFuture<(), Error> {
8585
(**self).add(ctx, entry)
8686
}

bookmarks/dbbookmarks/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl Bookmarks for SqlBookmarks {
385385
.boxify()
386386
}
387387

388-
fn create_transaction(&self, _ctx: CoreContext, repoid: RepositoryId) -> Box<Transaction> {
388+
fn create_transaction(&self, _ctx: CoreContext, repoid: RepositoryId) -> Box<dyn Transaction> {
389389
Box::new(SqlBookmarksTransaction::new(
390390
self.write_connection.clone(),
391391
repoid.clone(),

bookmarks/src/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ mod tests {
502502
bookmarks: &T,
503503
ctx: CoreContext,
504504
repoid: RepositoryId,
505-
) -> Box<Transaction> {
505+
) -> Box<dyn Transaction> {
506506
let mut transaction = bookmarks.create_transaction(ctx.clone(), repoid);
507507

508508
// Dirty the transaction.

bundle2_resolver/src/changegroup/filelog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl Arbitrary for Filelog {
305305
}
306306
}
307307

308-
fn shrink(&self) -> Box<Iterator<Item = Self>> {
308+
fn shrink(&self) -> Box<dyn Iterator<Item = Self>> {
309309
fn append(result: &mut Vec<Filelog>, f: Filelog) {
310310
result.append(&mut f.shrink().collect());
311311
result.push(f);

bundle2_resolver/src/getbundle_response.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub fn create_getbundle_response(
3030
blobrepo: BlobRepo,
3131
common: Vec<HgChangesetId>,
3232
heads: Vec<HgChangesetId>,
33-
lca_hint: Arc<LeastCommonAncestorsHint>,
34-
phases_hint: Option<Arc<Phases>>,
33+
lca_hint: Arc<dyn LeastCommonAncestorsHint>,
34+
phases_hint: Option<Arc<dyn Phases>>,
3535
) -> Result<Vec<PartEncodeBuilder>> {
3636
if common.is_empty() {
3737
return Err(err_msg("no 'common' heads specified. Pull will be very inefficient. Please use hg clone instead"));
@@ -180,7 +180,7 @@ fn prepare_phases_stream(
180180
ctx: CoreContext,
181181
repo: BlobRepo,
182182
heads: Vec<HgChangesetId>,
183-
phases: Arc<Phases>,
183+
phases: Arc<dyn Phases>,
184184
) -> impl Stream<Item = (HgChangesetId, HgPhase), Error = Error> {
185185
// create 'bonsai changesetid' => 'hg changesetid' hash map that will be later used
186186
// heads that are not known by the server will be skipped
@@ -240,7 +240,7 @@ fn calculate_public_roots(
240240
ctx: CoreContext,
241241
repo: BlobRepo,
242242
drafts: HashSet<ChangesetId>,
243-
phases: Arc<Phases>,
243+
phases: Arc<dyn Phases>,
244244
) -> impl Future<Item = HashSet<ChangesetId>, Error = Error> {
245245
future::loop_fn(
246246
(drafts, HashSet::new(), HashSet::new()),

bundle2_resolver/src/resolver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ struct Bundle2Resolver {
685685
bookmark_attrs: BookmarkAttrs,
686686
infinitepush_params: InfinitepushParams,
687687
hook_manager: Arc<HookManager>,
688-
scribe_commit_queue: Arc<ScribeCommitQueue>,
688+
scribe_commit_queue: Arc<dyn ScribeCommitQueue>,
689689
}
690690

691691
impl Bundle2Resolver {
@@ -1734,7 +1734,7 @@ fn filter_or_check_infinitepush_allowed(
17341734
}
17351735

17361736
fn add_bookmark_to_transaction(
1737-
txn: &mut Box<Transaction>,
1737+
txn: &mut Box<dyn Transaction>,
17381738
bookmark_push: BookmarkPush<ChangesetId>,
17391739
reason: BookmarkUpdateReason,
17401740
) -> Result<()> {

changesets/src/caching.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn get_cache_key(repo_id: RepositoryId, cs_id: &ChangesetId) -> String {
4141
}
4242

4343
pub struct CachingChangesets {
44-
changesets: Arc<Changesets>,
44+
changesets: Arc<dyn Changesets>,
4545
cachelib: CachelibHandler<ChangesetEntry>,
4646
memcache: MemcacheHandler,
4747
keygen: KeyGen,
@@ -58,7 +58,10 @@ fn get_keygen() -> KeyGen {
5858
}
5959

6060
impl CachingChangesets {
61-
pub fn new(changesets: Arc<Changesets>, cache_pool: cachelib::VolatileLruCachePool) -> Self {
61+
pub fn new(
62+
changesets: Arc<dyn Changesets>,
63+
cache_pool: cachelib::VolatileLruCachePool,
64+
) -> Self {
6265
Self {
6366
changesets,
6467
cachelib: cache_pool.into(),
@@ -68,7 +71,7 @@ impl CachingChangesets {
6871
}
6972

7073
#[cfg(test)]
71-
pub fn mocked(changesets: Arc<Changesets>) -> Self {
74+
pub fn mocked(changesets: Arc<dyn Changesets>) -> Self {
7275
let cachelib = CachelibHandler::create_mock();
7376
let memcache = MemcacheHandler::create_mock();
7477

changesets/src/wrappers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use mononoke_types::{ChangesetId, RepositoryId};
1515
use crate::errors::*;
1616
use crate::{ChangesetEntry, ChangesetInsert, Changesets};
1717

18-
impl Changesets for Arc<Changesets> {
18+
impl Changesets for Arc<dyn Changesets> {
1919
fn add(&self, ctx: CoreContext, cs: ChangesetInsert) -> BoxFuture<bool, Error> {
2020
(**self).add(ctx, cs)
2121
}

0 commit comments

Comments
 (0)