Skip to content

Commit 0db9e40

Browse files
committed
Fix unicode slicing bug
1 parent c9907ad commit 0db9e40

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/librustdoc/passes/html_tags.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn extract_path_backwards(text: &str, end_pos: usize) -> Option<usize> {
7474
use rustc_lexer::{is_id_continue, is_id_start};
7575
let mut current_pos = end_pos;
7676
loop {
77-
if current_pos >= 2 && &text[current_pos - 2..current_pos] == "::" {
77+
if current_pos >= 2 && text[..current_pos].ends_with("::") {
7878
current_pos -= 2;
7979
}
8080
let new_pos = text[..current_pos]
@@ -217,9 +217,9 @@ impl<'a, 'tcx> DocVisitor for InvalidHtmlTagsLinter<'a, 'tcx> {
217217
let mut diag = lint.build(msg);
218218
// If a tag looks like `<this>`, it might actually be a generic.
219219
// We don't try to detect stuff `<like, this>` because that's not valid HTML,
220-
// and we don' try to detect stuff `<like this>` because that's not valid Rust.
220+
// and we don't try to detect stuff `<like this>` because that's not valid Rust.
221221
if let Some(Some(generics_start)) = (is_open_tag
222-
&& &dox[range.end - 1..range.end] == ">")
222+
&& dox[..range.end].ends_with(">"))
223223
.then(|| extract_path_backwards(&dox, range.start))
224224
{
225225
let generics_sp = match super::source_span_for_markdown_range(

0 commit comments

Comments
 (0)