Skip to content

Commit c9c1200

Browse files
committed
Address review comments
1 parent d5cac19 commit c9c1200

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/librustdoc/html/escape.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ impl<'a> fmt::Display for Escape<'a> {
1616
let Escape(s) = *self;
1717
let pile_o_bits = s;
1818
let mut last = 0;
19-
for (i, ch) in s.bytes().enumerate() {
20-
let s = match ch as char {
19+
for (i, ch) in s.char_indices() {
20+
let s = match ch {
2121
'>' => "&gt;",
2222
'<' => "&lt;",
2323
'&' => "&amp;",
@@ -27,6 +27,8 @@ impl<'a> fmt::Display for Escape<'a> {
2727
};
2828
fmt.write_str(&pile_o_bits[last..i])?;
2929
fmt.write_str(s)?;
30+
// NOTE: we only expect single byte characters here - which is fine as long as we
31+
// only match single byte characters
3032
last = i + 1;
3133
}
3234

src/librustdoc/html/render/mod.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ crate struct StylePath {
359359

360360
thread_local!(crate static CURRENT_DEPTH: Cell<usize> = Cell::new(0));
361361

362-
// FIXME: make this work
363362
crate const INITIAL_IDS: [&'static str; 15] = [
364363
"main",
365364
"search",
@@ -4101,7 +4100,7 @@ fn item_typedef(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::T
41014100
}
41024101

41034102
fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) {
4104-
w.write_str("<pre class=\"rust foreigntype\">extern {");
4103+
w.write_str("<pre class=\"rust foreigntype\">extern {\n");
41054104
render_attributes(w, it, false);
41064105
write!(
41074106
w,
@@ -4264,8 +4263,8 @@ fn get_methods(
42644263
fn small_url_encode(s: String) -> String {
42654264
let mut st = String::new();
42664265
let mut last_match = 0;
4267-
for (idx, c) in s.bytes().enumerate() {
4268-
let escaped = match c as char {
4266+
for (idx, c) in s.char_indices() {
4267+
let escaped = match c {
42694268
'<' => "%3C",
42704269
'>' => "%3E",
42714270
' ' => "%20",
@@ -4283,6 +4282,8 @@ fn small_url_encode(s: String) -> String {
42834282

42844283
st += &s[last_match..idx];
42854284
st += escaped;
4285+
// NOTE: we only expect single byte characters here - which is fine as long as we
4286+
// only match single byte characters
42864287
last_match = idx + 1;
42874288
}
42884289

@@ -4834,12 +4835,12 @@ fn item_proc_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, m: &clean
48344835
w.push_str("<pre class=\"rust derive\">");
48354836
write!(w, "#[derive({})]", name);
48364837
if !m.helpers.is_empty() {
4837-
w.push_str("\n{");
4838-
w.push_str(" // Attributes available to this derive:");
4838+
w.push_str("\n{\n");
4839+
w.push_str(" // Attributes available to this derive:\n");
48394840
for attr in &m.helpers {
48404841
writeln!(w, " #[{}]", attr);
48414842
}
4842-
w.push_str("}");
4843+
w.push_str("}\n");
48434844
}
48444845
w.push_str("</pre>");
48454846
}

src/librustdoc/html/sources.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ impl SourceCollector<'_, '_> {
9494
};
9595

9696
// Remove the utf-8 BOM if any
97-
let contents =
98-
if contents.starts_with('\u{feff}') { &contents[3..] } else { &contents[..] };
97+
let contents = if contents.starts_with('\u{feff}') { &contents[3..] } else { &contents };
9998

10099
// Create the intermediate directories
101100
let mut cur = self.dst.clone();

0 commit comments

Comments
 (0)