1
Fork 0

Fix check issue

Clean up tidy checks
This commit is contained in:
Will Crichton 2021-05-30 10:00:44 -07:00
parent 4b3f82ad03
commit 7831fee9f8
5 changed files with 24 additions and 14 deletions

View file

@ -2466,7 +2466,7 @@ fn render_call_locations(
let filtered_locations: Vec<_> = call_locations
.iter()
.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) {
Ok(contents) => contents,
Err(e) => {

View file

@ -1973,7 +1973,8 @@ details.undocumented[open] > summary::before {
/* 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;
height: 240px;
}

View file

@ -1019,11 +1019,14 @@ function hideThemeButtonState() {
var output = [];
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]) {
var endIndex = lineIndex;
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;
endIndex += 1;
}
@ -1065,7 +1068,8 @@ function hideThemeButtonState() {
var wrapper = elt.querySelector(".code-wrapper");
var halfHeight = wrapper.offsetHeight / 2;
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;
lines.scrollTo(0, scrollOffset);
elt.querySelector(".rust").scrollTo(0, scrollOffset);
@ -1093,7 +1097,9 @@ function hideThemeButtonState() {
codeLines[loc.from[0]],
litHtml[loc.from[0]],
loc.from[1],
'<span class="highlight" data-loc="' + JSON.stringify(loc).replace(/"/g, "&quot;") + '">');
'<span class="highlight" data-loc="' +
JSON.stringify(loc).replace(/"/g, "&quot;") +
'">');
}, true); // do this backwards to avoid shifting later offsets
litParent.innerHTML = litHtml.join('\n');
@ -1131,7 +1137,9 @@ function hideThemeButtonState() {
function updateScrapedExamples() {
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) {
@ -1155,7 +1163,8 @@ function hideThemeButtonState() {
this.querySelector('.inner').innerHTML = labelForToggleButton(false);
if (!examples_init) {
examples_init = true;
onEach(more.getElementsByClassName('scraped-example'), updateScrapedExample);
onEach(more.getElementsByClassName('scraped-example'),
updateScrapedExample);
}
} else {
addClass(this, "collapsed");

View file

@ -620,7 +620,7 @@ fn opts() -> Vec<RustcOptGroup> {
)
}),
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", "", "")),
]
}

View file

@ -9,7 +9,7 @@ use rustc_hir::{
};
use rustc_interface::interface;
use rustc_middle::hir::map::Map;
use rustc_middle::ty::{TyCtxt, TyKind};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::symbol::Symbol;
crate type FnCallLocations = FxHashMap<String, Vec<(usize, usize)>>;
@ -60,7 +60,7 @@ where
};
// 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 {
let key = self.tcx.def_path(*def_id).to_string_no_crate_verbose();
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.
pub fn scrape(examples: &[String], krate: &str) -> interface::Result<AllCallLocations> {
// 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
.par_iter()
.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 file_name = args[0].clone();
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?
debug!("Scraping examples from krate {} with args:\n{:?}", krate, args);
let mut callbacks =