Fix check issue
Clean up tidy checks
This commit is contained in:
parent
4b3f82ad03
commit
7831fee9f8
5 changed files with 24 additions and 14 deletions
|
@ -2466,7 +2466,7 @@ fn render_call_locations(
|
||||||
let filtered_locations: Vec<_> = call_locations
|
let filtered_locations: Vec<_> = call_locations
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(file, locs)| {
|
.filter_map(|(file, locs)| {
|
||||||
// TODO(wcrichto): file I/O should be cached
|
// FIXME(wcrichto): file I/O should be cached
|
||||||
let mut contents = match fs::read_to_string(&file) {
|
let mut contents = match fs::read_to_string(&file) {
|
||||||
Ok(contents) => contents,
|
Ok(contents) => contents,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -1973,7 +1973,8 @@ details.undocumented[open] > summary::before {
|
||||||
|
|
||||||
/* This part is for the new "examples" components */
|
/* This part is for the new "examples" components */
|
||||||
|
|
||||||
.scraped-example:not(.expanded) .code-wrapper pre.line-numbers, .scraped-example:not(.expanded) .code-wrapper .example-wrap pre.rust {
|
.scraped-example:not(.expanded) .code-wrapper pre.line-numbers,
|
||||||
|
.scraped-example:not(.expanded) .code-wrapper .example-wrap pre.rust {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 240px;
|
height: 240px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1019,11 +1019,14 @@ function hideThemeButtonState() {
|
||||||
var output = [];
|
var output = [];
|
||||||
|
|
||||||
while (locs.length > 0 && lineIndex < codeLines.length) {
|
while (locs.length > 0 && lineIndex < codeLines.length) {
|
||||||
var lineLength = codeLines[lineIndex].length + 1; // +1 here and later is due to omitted \n
|
// +1 here and later is due to omitted \n
|
||||||
|
var lineLength = codeLines[lineIndex].length + 1;
|
||||||
while (locs.length > 0 && totalOffset + lineLength > locs[0][0]) {
|
while (locs.length > 0 && totalOffset + lineLength > locs[0][0]) {
|
||||||
var endIndex = lineIndex;
|
var endIndex = lineIndex;
|
||||||
var charsRemaining = locs[0][1] - totalOffset;
|
var charsRemaining = locs[0][1] - totalOffset;
|
||||||
while (endIndex < codeLines.length && charsRemaining > codeLines[endIndex].length + 1) {
|
while (endIndex < codeLines.length &&
|
||||||
|
charsRemaining > codeLines[endIndex].length + 1)
|
||||||
|
{
|
||||||
charsRemaining -= codeLines[endIndex].length + 1;
|
charsRemaining -= codeLines[endIndex].length + 1;
|
||||||
endIndex += 1;
|
endIndex += 1;
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1068,8 @@ function hideThemeButtonState() {
|
||||||
var wrapper = elt.querySelector(".code-wrapper");
|
var wrapper = elt.querySelector(".code-wrapper");
|
||||||
var halfHeight = wrapper.offsetHeight / 2;
|
var halfHeight = wrapper.offsetHeight / 2;
|
||||||
var lines = elt.querySelector('.line-numbers');
|
var lines = elt.querySelector('.line-numbers');
|
||||||
var offsetMid = (lines.children[loc.from[0]].offsetTop + lines.children[loc.to[0]].offsetTop) / 2;
|
var offsetMid = (lines.children[loc.from[0]].offsetTop
|
||||||
|
+ lines.children[loc.to[0]].offsetTop) / 2;
|
||||||
var scrollOffset = offsetMid - halfHeight;
|
var scrollOffset = offsetMid - halfHeight;
|
||||||
lines.scrollTo(0, scrollOffset);
|
lines.scrollTo(0, scrollOffset);
|
||||||
elt.querySelector(".rust").scrollTo(0, scrollOffset);
|
elt.querySelector(".rust").scrollTo(0, scrollOffset);
|
||||||
|
@ -1093,7 +1097,9 @@ function hideThemeButtonState() {
|
||||||
codeLines[loc.from[0]],
|
codeLines[loc.from[0]],
|
||||||
litHtml[loc.from[0]],
|
litHtml[loc.from[0]],
|
||||||
loc.from[1],
|
loc.from[1],
|
||||||
'<span class="highlight" data-loc="' + JSON.stringify(loc).replace(/"/g, """) + '">');
|
'<span class="highlight" data-loc="' +
|
||||||
|
JSON.stringify(loc).replace(/"/g, """) +
|
||||||
|
'">');
|
||||||
}, true); // do this backwards to avoid shifting later offsets
|
}, true); // do this backwards to avoid shifting later offsets
|
||||||
litParent.innerHTML = litHtml.join('\n');
|
litParent.innerHTML = litHtml.join('\n');
|
||||||
|
|
||||||
|
@ -1131,7 +1137,9 @@ function hideThemeButtonState() {
|
||||||
|
|
||||||
function updateScrapedExamples() {
|
function updateScrapedExamples() {
|
||||||
onEach(document.getElementsByClassName('scraped-example-list'), function (exampleSet) {
|
onEach(document.getElementsByClassName('scraped-example-list'), function (exampleSet) {
|
||||||
updateScrapedExample(exampleSet.querySelector(".small-section-header + .scraped-example"));
|
updateScrapedExample(
|
||||||
|
exampleSet.querySelector(".small-section-header + .scraped-example")
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
onEach(document.getElementsByClassName("more-scraped-examples"), function (more) {
|
onEach(document.getElementsByClassName("more-scraped-examples"), function (more) {
|
||||||
|
@ -1155,7 +1163,8 @@ function hideThemeButtonState() {
|
||||||
this.querySelector('.inner').innerHTML = labelForToggleButton(false);
|
this.querySelector('.inner').innerHTML = labelForToggleButton(false);
|
||||||
if (!examples_init) {
|
if (!examples_init) {
|
||||||
examples_init = true;
|
examples_init = true;
|
||||||
onEach(more.getElementsByClassName('scraped-example'), updateScrapedExample);
|
onEach(more.getElementsByClassName('scraped-example'),
|
||||||
|
updateScrapedExample);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addClass(this, "collapsed");
|
addClass(this, "collapsed");
|
||||||
|
|
|
@ -620,7 +620,7 @@ fn opts() -> Vec<RustcOptGroup> {
|
||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
unstable("scrape-examples", |o| o.optmulti("", "scrape-examples", "", "")),
|
unstable("scrape-examples", |o| o.optmulti("", "scrape-examples", "", "")),
|
||||||
unstable("repository-url", |o| o.optopt("", "repository-url", "", "TODO")),
|
unstable("repository-url", |o| o.optopt("", "repository-url", "", "")),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use rustc_hir::{
|
||||||
};
|
};
|
||||||
use rustc_interface::interface;
|
use rustc_interface::interface;
|
||||||
use rustc_middle::hir::map::Map;
|
use rustc_middle::hir::map::Map;
|
||||||
use rustc_middle::ty::{TyCtxt, TyKind};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
||||||
crate type FnCallLocations = FxHashMap<String, Vec<(usize, usize)>>;
|
crate type FnCallLocations = FxHashMap<String, Vec<(usize, usize)>>;
|
||||||
|
@ -60,7 +60,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save call site if the function resovles to a concrete definition
|
// Save call site if the function resovles to a concrete definition
|
||||||
if let TyKind::FnDef(def_id, _) = ty.kind() {
|
if let ty::FnDef(def_id, _) = ty.kind() {
|
||||||
if self.tcx.crate_name(def_id.krate) == self.krate {
|
if self.tcx.crate_name(def_id.krate) == self.krate {
|
||||||
let key = self.tcx.def_path(*def_id).to_string_no_crate_verbose();
|
let key = self.tcx.def_path(*def_id).to_string_no_crate_verbose();
|
||||||
let entries = self.calls.entry(key).or_insert_with(FxHashMap::default);
|
let entries = self.calls.entry(key).or_insert_with(FxHashMap::default);
|
||||||
|
@ -107,16 +107,16 @@ impl rustc_driver::Callbacks for Callbacks {
|
||||||
/// * `krate` is the name of the crate being documented.
|
/// * `krate` is the name of the crate being documented.
|
||||||
pub fn scrape(examples: &[String], krate: &str) -> interface::Result<AllCallLocations> {
|
pub fn scrape(examples: &[String], krate: &str) -> interface::Result<AllCallLocations> {
|
||||||
// Scrape each crate in parallel
|
// Scrape each crate in parallel
|
||||||
// TODO(wcrichto): do we need optional support for no rayon?
|
// FIXME(wcrichto): do we need optional support for no rayon?
|
||||||
let maps = examples
|
let maps = examples
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|example| {
|
.map(|example| {
|
||||||
// TODO(wcrichto): is there a more robust way to get arguments than split(" ")?
|
// FIXME(wcrichto): is there a more robust way to get arguments than split(" ")?
|
||||||
let mut args = example.split(" ").map(|s| s.to_owned()).collect::<Vec<_>>();
|
let mut args = example.split(" ").map(|s| s.to_owned()).collect::<Vec<_>>();
|
||||||
let file_name = args[0].clone();
|
let file_name = args[0].clone();
|
||||||
args.insert(0, "_".to_string());
|
args.insert(0, "_".to_string());
|
||||||
|
|
||||||
// TODO(wcrichto): is there any setup / cleanup that needs to be performed
|
// FIXME(wcrichto): is there any setup / cleanup that needs to be performed
|
||||||
// here upon the invocation of rustc_driver?
|
// here upon the invocation of rustc_driver?
|
||||||
debug!("Scraping examples from krate {} with args:\n{:?}", krate, args);
|
debug!("Scraping examples from krate {} with args:\n{:?}", krate, args);
|
||||||
let mut callbacks =
|
let mut callbacks =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue