Skip to content

Commit 629b2cf

Browse files
committed
temporary workaround for rustdoc ICE rust-lang/rust#58011
1 parent fbecd5a commit 629b2cf

File tree

14 files changed

+110
-15
lines changed

14 files changed

+110
-15
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ parquet = ["amadeus-parquet", "amadeus-derive/parquet"]
3030
postgres = ["amadeus-postgres", "amadeus-derive/postgres"]
3131
csv = ["amadeus-serde", "amadeus-derive/serde"]
3232
json = ["amadeus-serde", "amadeus-derive/serde"]
33+
doc = ["amadeus-aws/doc", "amadeus-commoncrawl/doc", "amadeus-parquet/doc", "amadeus-postgres/doc", "amadeus-serde/doc"]
3334

3435
[package.metadata.docs.rs]
35-
features = ["constellation", "aws", "commoncrawl", "postgres", "csv", "json"]
36+
features = ["doc", "constellation", "aws", "commoncrawl", "postgres", "csv", "json"]
3637

3738
[dependencies]
3839
amadeus-core = { version = "=0.1.2", path = "amadeus-core" }

amadeus-aws/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ edition = "2018"
1818
azure-devops = { project = "alecmocatta/amadeus", pipeline = "tests" }
1919
maintenance = { status = "actively-developed" }
2020

21+
[features]
22+
doc = []
23+
2124
[dependencies]
2225
amadeus-core = { version = "=0.1.2", path = "../amadeus-core" }
2326
amadeus-types = { version = "=0.1.2", path = "../amadeus-types" }

amadeus-aws/src/cloudfront.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ impl Source for Cloudfront {
4242
type Item = CloudfrontRow;
4343
type Error = AwsError;
4444

45+
#[cfg(not(feature = "doc"))]
4546
type DistIter = impl DistributedIterator<Item = Result<Self::Item, Self::Error>>;
47+
#[cfg(feature = "doc")]
48+
type DistIter = amadeus_core::util::ImplDistributedIterator<Result<Self::Item, Self::Error>>;
4649
type Iter = iter::Empty<Result<Self::Item, Self::Error>>;
4750

51+
#[allow(clippy::let_and_return)]
4852
fn dist_iter(self) -> Self::DistIter {
4953
let Self {
5054
bucket,
@@ -59,7 +63,7 @@ impl Source for Cloudfront {
5963
None
6064
},
6165
);
62-
objects
66+
let ret = objects
6367
.into_dist_iter()
6468
.flat_map(FnMut!(move |key: String| {
6569
let region = if let Some(endpoint) = &region.1 {
@@ -115,7 +119,10 @@ impl Source for Cloudfront {
115119
}))
116120
.map(FnMut!(
117121
|x: Result<Result<CloudfrontRow, _>, _>| x.and_then(self::identity)
118-
))
122+
));
123+
#[cfg(feature = "doc")]
124+
let ret = amadeus_core::util::ImplDistributedIterator::new(ret);
125+
ret
119126
}
120127

121128
fn iter(self) -> Self::Iter {

amadeus-commoncrawl/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ edition = "2018"
1818
azure-devops = { project = "alecmocatta/amadeus", pipeline = "tests" }
1919
maintenance = { status = "actively-developed" }
2020

21+
[features]
22+
doc = []
23+
2124
[dependencies]
2225
amadeus-core = { version = "=0.1.2", path = "../amadeus-core" }
2326
amadeus-types = { version = "=0.1.2", path = "../amadeus-types" }

amadeus-commoncrawl/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ impl Source for CommonCrawl {
4242
type Item = Webpage<'static>;
4343
type Error = io::Error;
4444

45+
#[cfg(not(feature = "doc"))]
4546
type DistIter = impl DistributedIterator<Item = Result<Self::Item, Self::Error>>;
47+
#[cfg(feature = "doc")]
48+
type DistIter = amadeus_core::util::ImplDistributedIterator<Result<Self::Item, Self::Error>>;
4649
type Iter = iter::Empty<Result<Self::Item, Self::Error>>;
4750

51+
#[allow(clippy::let_and_return)]
4852
fn dist_iter(self) -> Self::DistIter {
4953
let body = MultiGzDecoder::new(self.body); // Content-Encoding isn't set, so decode manually
5054

51-
BufReader::new(body)
55+
let ret = BufReader::new(body)
5256
.lines()
5357
.map(FnMut!(|url: Result<String, io::Error>| -> String {
5458
format!("http://commoncrawl.s3.amazonaws.com/{}", url.unwrap())
@@ -65,7 +69,10 @@ impl Source for CommonCrawl {
6569
.unwrap();
6670
let body = MultiGzDecoder::new(body);
6771
WarcParser::new(body)
68-
}))
72+
}));
73+
#[cfg(feature = "doc")]
74+
let ret = amadeus_core::util::ImplDistributedIterator::new(ret);
75+
ret
6976
}
7077
fn iter(self) -> Self::Iter {
7178
iter::empty()

amadeus-core/src/util.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use serde::{Deserialize, Serialize};
2-
use std::{error, fmt, io, sync::Arc};
2+
use std::{error, fmt, io, marker::PhantomData, sync::Arc};
3+
4+
use crate::dist_iter::{Consumer, DistributedIterator};
35

46
pub struct ResultExpand<T, E>(pub Result<T, E>);
57
impl<T, E> IntoIterator for ResultExpand<T, E>
@@ -59,3 +61,34 @@ impl From<IoError> for io::Error {
5961
Arc::try_unwrap(err.0).unwrap()
6062
}
6163
}
64+
65+
pub struct ImplDistributedIterator<T>(PhantomData<fn(T)>);
66+
impl<T> ImplDistributedIterator<T> {
67+
pub fn new<U>(_drop: U) -> Self
68+
where
69+
U: DistributedIterator<Item = T>,
70+
{
71+
Self(PhantomData)
72+
}
73+
}
74+
impl<T: 'static> DistributedIterator for ImplDistributedIterator<T> {
75+
type Item = T;
76+
type Task = ImplConsumer<T>;
77+
78+
fn size_hint(&self) -> (usize, Option<usize>) {
79+
unreachable!()
80+
}
81+
fn next_task(&mut self) -> Option<Self::Task> {
82+
unreachable!()
83+
}
84+
}
85+
86+
#[derive(Serialize, Deserialize)]
87+
pub struct ImplConsumer<T>(PhantomData<fn(T)>);
88+
impl<T: 'static> Consumer for ImplConsumer<T> {
89+
type Item = T;
90+
91+
fn run(self, _i: &mut impl FnMut(Self::Item) -> bool) -> bool {
92+
unreachable!()
93+
}
94+
}

amadeus-parquet/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ edition = "2018"
1818
azure-devops = { project = "alecmocatta/amadeus", pipeline = "tests" }
1919
maintenance = { status = "actively-developed" }
2020

21+
[features]
22+
doc = []
23+
2124
[dependencies]
2225
amadeus-core = { version = "=0.1.2", path = "../amadeus-core" }
2326
amadeus-types = { version = "=0.1.2", path = "../amadeus-types" }

amadeus-parquet/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ where
6161
type Item = Row;
6262
type Error = ParquetError<F>;
6363

64+
#[cfg(not(feature = "doc"))]
6465
type DistIter = impl DistributedIterator<Item = Result<Self::Item, Self::Error>>;
66+
#[cfg(feature = "doc")]
67+
type DistIter = amadeus_core::util::ImplDistributedIterator<Result<Self::Item, Self::Error>>;
6568
type Iter = iter::Empty<Result<Self::Item, Self::Error>>;
6669

70+
#[allow(clippy::let_and_return)]
6771
fn dist_iter(self) -> Self::DistIter {
68-
self.partitions
72+
let ret = self
73+
.partitions
6974
.into_dist_iter()
7075
.flat_map(FnMut!(|partition: F::Partition| {
7176
ResultExpand(partition.pages().map_err(ParquetError::<F>::Partition))
@@ -79,7 +84,10 @@ where
7984
))
8085
})
8186
.map(|row: Result<Result<Row, _>, _>| Ok(row??))
82-
}))
87+
}));
88+
#[cfg(feature = "doc")]
89+
let ret = amadeus_core::util::ImplDistributedIterator::new(ret);
90+
ret
8391
}
8492
fn iter(self) -> Self::Iter {
8593
iter::empty()

amadeus-postgres/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ edition = "2018"
1818
azure-devops = { project = "alecmocatta/amadeus", pipeline = "tests" }
1919
maintenance = { status = "actively-developed" }
2020

21+
[features]
22+
doc = []
23+
2124
[dependencies]
2225
amadeus-core = { version = "=0.1.2", path = "../amadeus-core" }
2326
amadeus-types = { version = "=0.1.2", path = "../amadeus-types" }

amadeus-postgres/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,16 @@ where
166166
type Item = Row;
167167
type Error = Error;
168168

169+
#[cfg(not(feature = "doc"))]
169170
type DistIter = impl DistributedIterator<Item = Result<Self::Item, Self::Error>>;
171+
#[cfg(feature = "doc")]
172+
type DistIter = amadeus_core::util::ImplDistributedIterator<Result<Self::Item, Self::Error>>;
170173
type Iter = iter::Empty<Result<Self::Item, Self::Error>>;
171174

175+
#[allow(clippy::let_and_return)]
172176
fn dist_iter(self) -> Self::DistIter {
173-
self.files
177+
let ret = self
178+
.files
174179
.into_dist_iter()
175180
.flat_map(FnMut!(|(connect, tables)| {
176181
let (connect, tables): (ConnectParams, Vec<Source>) = (connect, tables);
@@ -213,7 +218,10 @@ where
213218
vec.into_iter()
214219
}),
215220
)
216-
}))
221+
}));
222+
#[cfg(feature = "doc")]
223+
let ret = amadeus_core::util::ImplDistributedIterator::new(ret);
224+
ret
217225
}
218226
fn iter(self) -> Self::Iter {
219227
iter::empty()

0 commit comments

Comments
 (0)