Skip to content

Commit d0c9385

Browse files
committedNov 4, 2018
add Debug impls for the Options structs
1 parent 297cfea commit d0c9385

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed
 

‎src/librustdoc/config.rs

+41-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use std::collections::{BTreeMap, BTreeSet};
12+
use std::fmt;
1213
use std::path::PathBuf;
1314

1415
use errors;
@@ -99,8 +100,47 @@ pub struct Options {
99100
pub render_options: RenderOptions,
100101
}
101102

103+
impl fmt::Debug for Options {
104+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
105+
struct FmtExterns<'a>(&'a Externs);
106+
107+
impl<'a> fmt::Debug for FmtExterns<'a> {
108+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
109+
f.debug_map()
110+
.entries(self.0.iter())
111+
.finish()
112+
}
113+
}
114+
115+
f.debug_struct("Options")
116+
.field("input", &self.input)
117+
.field("crate_name", &self.crate_name)
118+
.field("error_format", &self.error_format)
119+
.field("libs", &self.libs)
120+
.field("externs", &FmtExterns(&self.externs))
121+
.field("cfgs", &self.cfgs)
122+
.field("codegen_options", &"...")
123+
.field("debugging_options", &"...")
124+
.field("target", &self.target)
125+
.field("edition", &self.edition)
126+
.field("maybe_sysroot", &self.maybe_sysroot)
127+
.field("linker", &self.linker)
128+
.field("lint_opts", &self.lint_opts)
129+
.field("describe_lints", &self.describe_lints)
130+
.field("lint_cap", &self.lint_cap)
131+
.field("should_test", &self.should_test)
132+
.field("test_args", &self.test_args)
133+
.field("default_passes", &self.default_passes)
134+
.field("manual_passes", &self.manual_passes)
135+
.field("display_warnings", &self.display_warnings)
136+
.field("crate_version", &self.crate_version)
137+
.field("render_options", &self.render_options)
138+
.finish()
139+
}
140+
}
141+
102142
/// Configuration options for the HTML page-creation process.
103-
#[derive(Clone)]
143+
#[derive(Clone, Debug)]
104144
pub struct RenderOptions {
105145
/// Output directory to generate docs into. Defaults to `doc`.
106146
pub output: PathBuf,

‎src/librustdoc/externalfiles.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use syntax::feature_gate::UnstableFeatures;
1616
use html::markdown::{IdMap, ErrorCodes, Markdown};
1717
use std::cell::RefCell;
1818

19-
#[derive(Clone)]
19+
#[derive(Clone, Debug)]
2020
pub struct ExternalHtml {
2121
/// Content that will be included inline in the <head> section of a
2222
/// rendered Markdown file or generated documentation

‎src/librustdoc/html/markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ pub fn markdown_links(md: &str) -> Vec<(String, Option<Range<usize>>)> {
905905
links
906906
}
907907

908-
#[derive(Clone, Default)]
908+
#[derive(Clone, Default, Debug)]
909909
pub struct IdMap {
910910
map: FxHashMap<String, usize>,
911911
}

0 commit comments

Comments
 (0)