Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc chokes on impl trait? #43869

Closed
Manishearth opened this issue Aug 14, 2017 · 7 comments
Closed

rustdoc chokes on impl trait? #43869

Manishearth opened this issue Aug 14, 2017 · 7 comments

Comments

@Manishearth
Copy link
Member

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.

@kennytm
Copy link
Member

kennytm commented Aug 14, 2017

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() {}

@Manishearth
Copy link
Member Author

Manishearth commented Aug 14, 2017

everybody_loops somedays

@Manishearth
Copy link
Member Author

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

@Manishearth
Copy link
Member Author

@kennytm any way to turn off the dox stuff for my local doc build? Or do you know how to fix this?

@Manishearth
Copy link
Member Author

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

@kennytm
Copy link
Member

kennytm commented Aug 14, 2017

@Manishearth I'll submit a PR to opt-out of loop {} for -> impl Trait. It is already opt-out for const fn.

@Manishearth
Copy link
Member Author

oh, awesome. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants