steveklabnik/rustdoc

Not all required crates are added to doctests

hjr3 opened this issue · 3 comments

hjr3 commented

Download hyper and checkout tag v0.11.9. Run the tests:

RUST_BACKTRACE=1 cargo run --bin rustdoc -- --manifest-path=../hyper/Cargo.toml test

The tests fail because the test program does not extern the base64 crate.

     Running `target/debug/rustdoc --manifest-path=../hyper/Cargo.toml test`
  Generating save analysis data: Done
  Loading save analysis data: Done
  Generating JSON: Done
  Generating documentation: Done
running 2 tests
test hyper::header - 0 ... FAILED
test hyper::header - 1 ... FAILED

---- hyper::header - 0 stderr ----
error[E0463]: can't find crate for `base64` which `hyper` depends on
 --> <anon>:1:17
  |
1 | # [ macro_use ] extern crate hyper ; use hyper :: header :: Headers ; header ! { ( XRequestGuid , "X-Request-Guid" ) => [ String ] } fn main ( ) { let mut headers = Headers :: new ( ) ; headers . set ( XRequestGuid ( "a proper guid" . to_owned ( ) ) ) }
  |                 ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

---- hyper::header - 1 stderr ----
error[E0463]: can't find crate for `base64` which `hyper` depends on
 --> <anon>:1:1
  |
1 | extern crate hyper ; fn main ( ) { use std :: fmt ; use hyper :: header :: { self , Header , Raw } ; # [ derive ( Debug , Clone , Copy ) ] struct Dnt ( bool ) ; impl Header for Dnt { fn header_name ( ) -> & 'static str { "DNT" } fn parse_header ( raw : & Raw ) -> hyper :: Result < Dnt > { if raw . len ( ) == 1 { let line = & raw [ 0 ] ; if line . len ( ) == 1 { let byte = line [ 0 ] ; match byte { b'0' => return Ok ( Dnt ( true ) ) , b'1' => return Ok ( Dnt ( false ) ) , _ => ( ) , } } } Err ( hyper :: Error :: Header ) } fn fmt_header ( & self , f : & mut header :: Formatter ) -> fmt :: Result { let value = if self . 0 { "1" } else { "0" } ; f . fmt_line ( & value ) } } }
  | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

failures:
    hyper::header - 0
    hyper::header - 1

test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out
hjr3 commented

Not sure this is solvable without leveraging more of cargo. The approach of compiling using rustc will lead us down a path of basically recreating cargo. Already looking at this I ran into issues where a crate like hyper has two different versions of the slab crate.

Maybe rust-lang/cargo#3815 would help?

hjr3 commented

I tracked this down to a missing -L arg when building the artifact. I will fix this in #218 but if that does not land, I will make a separate PR.