Skip to content

Commit

Permalink
add Debug impls for the Options structs
Browse files Browse the repository at this point in the history
  • Loading branch information
QuietMisdreavus committed Nov 4, 2018
1 parent 297cfea commit d0c9385
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
42 changes: 41 additions & 1 deletion src/librustdoc/config.rs
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
use std::path::PathBuf;

use errors;
Expand Down Expand Up @@ -99,8 +100,47 @@ pub struct Options {
pub render_options: RenderOptions,
}

impl fmt::Debug for Options {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct FmtExterns<'a>(&'a Externs);

impl<'a> fmt::Debug for FmtExterns<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_map()
.entries(self.0.iter())
.finish()
}
}

f.debug_struct("Options")
.field("input", &self.input)
.field("crate_name", &self.crate_name)
.field("error_format", &self.error_format)
.field("libs", &self.libs)
.field("externs", &FmtExterns(&self.externs))
.field("cfgs", &self.cfgs)
.field("codegen_options", &"...")
.field("debugging_options", &"...")
.field("target", &self.target)
.field("edition", &self.edition)
.field("maybe_sysroot", &self.maybe_sysroot)
.field("linker", &self.linker)
.field("lint_opts", &self.lint_opts)
.field("describe_lints", &self.describe_lints)
.field("lint_cap", &self.lint_cap)
.field("should_test", &self.should_test)
.field("test_args", &self.test_args)
.field("default_passes", &self.default_passes)
.field("manual_passes", &self.manual_passes)
.field("display_warnings", &self.display_warnings)
.field("crate_version", &self.crate_version)
.field("render_options", &self.render_options)
.finish()
}
}

/// Configuration options for the HTML page-creation process.
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct RenderOptions {
/// Output directory to generate docs into. Defaults to `doc`.
pub output: PathBuf,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/externalfiles.rs
Expand Up @@ -16,7 +16,7 @@ use syntax::feature_gate::UnstableFeatures;
use html::markdown::{IdMap, ErrorCodes, Markdown};
use std::cell::RefCell;

#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct ExternalHtml {
/// Content that will be included inline in the <head> section of a
/// rendered Markdown file or generated documentation
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Expand Up @@ -905,7 +905,7 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
links
}

#[derive(Clone, Default)]
#[derive(Clone, Default, Debug)]
pub struct IdMap {
map: FxHashMap<String, usize>,
}
Expand Down

0 comments on commit d0c9385

Please sign in to comment.