}
}
+#[derive(Debug)]
pub struct PackageSet<'cfg> {
packages: HashMap<PackageId, LazyCell<Package>>,
sources: RefCell<SourceMap<'cfg>>,
use std::collections::hash_map::{HashMap, IterMut, Values};
+use std::fmt;
use core::{Package, PackageId, Registry};
use util::CargoResult;
map: HashMap<SourceId, Box<Source + 'src>>,
}
+// impl debug on source requires specialization, if even desirable at all
+impl<'src> fmt::Debug for SourceMap<'src> {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "SourceMap ")?;
+ f.debug_set().entries(self.map.keys()).finish()
+ }
+}
+
/// A `std::collection::hash_map::Values` for `SourceMap`
pub type Sources<'a, 'src> = Values<'a, SourceId, Box<Source + 'src>>;
use ops;
use util::CargoResult;
+/// Strongly typed options for the `cargo doc` command.
+#[derive(Debug)]
pub struct DocOptions<'a> {
+ /// Whether to attempt to open the browser after compiling the docs
pub open_result: bool,
+ /// Options to pass through to the compiler
pub compile_opts: ops::CompileOptions<'a>,
}
+/// Main method for `cargo doc`.
pub fn doc(ws: &Workspace, options: &DocOptions) -> CargoResult<()> {
let specs = options.compile_opts.spec.into_package_id_specs(ws)?;
let resolve = ops::resolve_ws_precisely(
let mut lib_names = HashMap::new();
let mut bin_names = HashMap::new();
+ //println!("{:#?}", pkgs);
for package in &pkgs {
for target in package.targets().iter().filter(|t| t.documented()) {
if target.is_lib() {
}
ops::compile(ws, &options.compile_opts)?;
+ //println!("Made it!");
if options.open_result {
let name = if pkgs.len() > 1 {
.with_stderr_contains("[RUNNING] `rustdoc [..]-Zunstable-options --edition=2018[..]"),
);
}
+
+// Tests an issue where depending on different versions of the same file caused `cargo doc` to
+// fail.
+#[test]
+fn issue_5345() {
+ let foo = project("foo")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [target.'cfg(all(windows, target_arch = "x86"))'.dependencies]
+ bar = "0.1"
+
+ [target.'cfg(not(all(windows, target_arch = "x86")))'.dependencies]
+ bar = "0.2"
+ "#,
+ )
+ .file("src/lib.rs", "extern crate bar;")
+ .build();
+ Package::new("bar", "0.1.0").publish();
+ Package::new("bar", "0.2.0").publish();
+
+ assert_that(foo.cargo("build"), execs().with_status(0));
+ assert_that(foo.cargo("doc"), execs().with_status(0));
+}