rustdoc chokes on impl trait?
Manishearth opened this issue · 7 comments
Trying to do a rust internals docs build with compiler-docs = true
in the configuration.
I get this error:
Documenting rustc_data_structures v0.0.0 (file:///Users/manishearth/mozilla/rust/src/librustc_data_structures)
error[E0277]: the trait bound `(): core::iter::Iterator` is not satisfied
--> src/librustc_data_structures/indexed_vec.rs:150:74
|
150 | pub fn drain<'a, R: RangeArgument<usize>>(&'a mut self, range: R) -> impl Iterator<Item=T> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method
|
= help: the trait `core::iter::Iterator` is not implemented for `()`
= note: the return type of a function must have a statically known size
error[E0277]: the trait bound `(): core::iter::Iterator` is not satisfied
--> src/librustc_data_structures/indexed_vec.rs:156:36
|
156 | &'a mut self, range: R) -> impl Iterator<Item=(I, T)> + 'a {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator; maybe try calling `.iter()` or a similar method
|
= help: the trait `core::iter::Iterator` is not implemented for `()`
= note: the return type of a function must have a statically known size
error: Compilation failed, aborting rustdoc
error: Could not document `rustc_data_structures`.
Caused by:
process didn't exit successfully: `/Users/manishearth/mozilla/rust/build/bootstrap/debug/rustdoc --crate-name rustc_data_structures src/librustc_data_structures/lib.rs --target x86_64-apple-darwin -o /Users/manishearth/mozilla/rust/build/x86_64-apple-darwin/stage1-rustc/x86_64-apple-darwin/doc -L dependency=/Users/manishearth/mozilla/rust/build/x86_64-apple-darwin/stage1-rustc/x86_64-apple-darwin/release/deps -L dependency=/Users/manishearth/mozilla/rust/build/x86_64-apple-darwin/stage1-rustc/release/deps --extern log=/Users/manishearth/mozilla/rust/build/x86_64-apple-darwin/stage1-rustc/x86_64-apple-darwin/release/deps/liblog-08c10d216c38a725.rlib --extern serialize=/Users/manishearth/mozilla/rust/build/x86_64-apple-darwin/stage1-rustc/x86_64-apple-darwin/release/deps/libserialize-af034662b9c25f53.dylib --extern serialize=/Users/manishearth/mozilla/rust/build/x86_64-apple-darwin/stage1-rustc/x86_64-apple-darwin/release/deps/libserialize-af034662b9c25f53.rlib` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed
That function is returning vec.drain
. The error only happens while running rustdoc, not while compiling.
Looks like fallout of #43348, since the body of every fn
is replaced by loop {}
, but !
does not impl
all traits, thus the error. (This also affects --unpretty everybody_loops
)
#![feature(conservative_impl_trait)]
fn g() -> impl Iterator<Item=u8> { //~ ERROR E0277
loop {}
}
fn main() {}
ah, figured it was something related to that, but was having trouble creating an MWE since I had to look up how to --cfg dox
@kennytm any way to turn off the dox stuff for my local doc build? Or do you know how to fix this?
I guess I can just fix this by, like, using the right type there 😄. impl trait isn't really necessary
Another way to fix it would be to not use everybody_loops for impl trait funcs, but that's not great
@Manishearth I'll submit a PR to opt-out of loop {}
for -> impl Trait
. It is already opt-out for const fn
.
oh, awesome. thanks!