Skip to content

Commit d46bf8a

Browse files
committed
try not to break the logic
1 parent aaefdcf commit d46bf8a

File tree

4 files changed

+21
-28
lines changed

4 files changed

+21
-28
lines changed

compiler/rustc_resolve/src/rustdoc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ pub fn source_span_for_markdown_range(
574574
// because it matches the pattern,
575575
// which is checked to not be zero sized.
576576
if match_data.is_none()
577-
&& !snippet.as_bytes().windows(pat.len()).any(|s| s == pat.as_bytes())
577+
&& !snippet.as_bytes()[1..].windows(pat.len()).any(|s| s == pat.as_bytes())
578578
{
579579
match_data = Some((i, match_start));
580580
} else {

tests/rustdoc-ui/lints/bare-urls.fixed

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
//~^ ERROR this URL is not a hyperlink
3939
pub fn c() {}
4040

41-
#[doc = "here's a thing: <https://example.com/>"]
41+
#[doc = "here's a thing: https://example.com/"]
4242
//~^ ERROR this URL is not a hyperlink
4343
pub fn f() {}
4444

45-
/// <https://example.com/sugar>
45+
/// https://example.com/sugar
4646
//~^ ERROR this URL is not a hyperlink
47-
#[doc = "<https://example.com/raw>"]
47+
#[doc = "https://example.com/raw"]
4848
//~^ ERROR this URL is not a hyperlink
4949
pub fn mixed() {}
5050

tests/rustdoc-ui/lints/bare-urls.stderr

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,40 +208,33 @@ LL | /// hey! <https://somewhere.com/a?hello=12&bye=11#xyz>
208208
| + +
209209

210210
error: this URL is not a hyperlink
211-
--> $DIR/bare-urls.rs:41:26
211+
--> $DIR/bare-urls.rs:41:9
212212
|
213213
LL | #[doc = "here's a thing: https://example.com/"]
214-
| ^^^^^^^^^^^^^^^^^^^^
214+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
215215
|
216216
= note: bare URLs are not automatically turned into clickable links
217-
help: use an automatic link instead
218-
|
219-
LL | #[doc = "here's a thing: <https://example.com/>"]
220-
| + +
221217

222218
error: this URL is not a hyperlink
223-
--> $DIR/bare-urls.rs:45:5
219+
--> $DIR/bare-urls.rs:45:1
224220
|
225-
LL | /// https://example.com/sugar
226-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
221+
LL | / /// https://example.com/sugar
222+
LL | |
223+
LL | | #[doc = "https://example.com/raw"]
224+
| |_________________________________^
227225
|
228226
= note: bare URLs are not automatically turned into clickable links
229-
help: use an automatic link instead
230-
|
231-
LL | /// <https://example.com/sugar>
232-
| + +
233227

234228
error: this URL is not a hyperlink
235-
--> $DIR/bare-urls.rs:47:10
229+
--> $DIR/bare-urls.rs:45:1
236230
|
237-
LL | #[doc = "https://example.com/raw"]
238-
| ^^^^^^^^^^^^^^^^^^^^^^^
231+
LL | / /// https://example.com/sugar
232+
LL | |
233+
LL | | #[doc = "https://example.com/raw"]
234+
| |_________________________________^
239235
|
240236
= note: bare URLs are not automatically turned into clickable links
241-
help: use an automatic link instead
242-
|
243-
LL | #[doc = "<https://example.com/raw>"]
244-
| + +
237+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
245238

246239
error: aborting due to 20 previous errors
247240

tests/rustdoc-ui/unescaped_backticks.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,21 +628,21 @@ LL | /// or even to add a number `n` to 42 (`add(42, n)\`)!
628628
| +
629629

630630
error: unescaped backtick
631-
--> $DIR/unescaped_backticks.rs:108:10
631+
--> $DIR/unescaped_backticks.rs:108:9
632632
|
633633
LL | #[doc = "`"]
634-
| ^
634+
| ^^^
635635
|
636636
= help: the opening or closing backtick of an inline code may be missing
637637
= help: if you meant to use a literal backtick, escape it
638638
change: `
639639
to this: \`
640640

641641
error: unescaped backtick
642-
--> $DIR/unescaped_backticks.rs:115:26
642+
--> $DIR/unescaped_backticks.rs:115:9
643643
|
644644
LL | #[doc = concat!("\\", "`")]
645-
| ^
645+
| ^^^^^^^^^^^^^^^^^^^^
646646
|
647647
= help: the opening backtick of an inline code may be missing
648648
change: \`

0 commit comments

Comments
 (0)