Skip to content

Commit f199627

Browse files
Remove useless code and update index page test
1 parent d676386 commit f199627

File tree

2 files changed

+5
-25
lines changed

2 files changed

+5
-25
lines changed

src/librustdoc/html/render.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -951,40 +951,15 @@ themePicker.onblur = handleThemeButtonsBlur;
951951
key: &str,
952952
for_search_index: bool,
953953
) -> io::Result<(Vec<String>, Vec<String>, Vec<String>)> {
954-
use minifier::js;
955-
956954
let mut ret = Vec::new();
957955
let mut krates = Vec::new();
958956
let mut variables = Vec::new();
959957

960-
let mut krate = krate.to_owned();
961-
962958
if path.exists() {
963959
for line in BufReader::new(File::open(path)?).lines() {
964960
let line = line?;
965961
if for_search_index && line.starts_with("var R") {
966962
variables.push(line.clone());
967-
// We need to check if the crate name has been put into a variable as well.
968-
let tokens: js::Tokens<'_> = js::simple_minify(&line)
969-
.into_iter()
970-
.filter(js::clean_token)
971-
.collect::<Vec<_>>()
972-
.into();
973-
let mut pos = 0;
974-
while pos < tokens.len() {
975-
if let Some((var_pos, Some(value_pos))) =
976-
js::get_variable_name_and_value_positions(&tokens, pos) {
977-
if let Some(s) = tokens.0[value_pos].get_string() {
978-
if &s[1..s.len() - 1] == krate {
979-
if let Some(var) = tokens[var_pos].get_other() {
980-
krate = var.to_owned();
981-
break
982-
}
983-
}
984-
}
985-
}
986-
pos += 1;
987-
}
988963
continue;
989964
}
990965
if !line.starts_with(key) {
@@ -1344,6 +1319,8 @@ fn write_minify_replacer<W: Write>(
13441319
f,
13451320
"R",
13461321
Token::Char(ReservedChar::Backline),
1322+
// This closure prevents crates' name to be aggregated. It allows to not
1323+
// have to look for crate's name into the strings array.
13471324
|tokens, pos| {
13481325
pos < 2 ||
13491326
!tokens[pos - 1].is_char(ReservedChar::OpenBracket) ||

src/test/rustdoc/index-page.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
// aux-build:all-item-types.rs
2+
// build-aux-docs
13
// compile-flags: -Z unstable-options --enable-index-page
24

35
#![crate_name = "foo"]
46

57
// @has foo/../index.html
68
// @has - '//span[@class="in-band"]' 'List of all crates'
79
// @has - '//ul[@class="mod"]//a[@href="foo/index.html"]' 'foo'
10+
// @has - '//ul[@class="mod"]//a[@href="all_item_types/index.html"]' 'all_item_types'
811
pub struct Foo;

0 commit comments

Comments
 (0)