Skip to content

Commit c2a0d1b

Browse files
committed
Auto merge of #39204 - ollie27:linkchecker_fragment, r=alexcrichton
linkchecker: Fix checking links which are just fragments Also fix a typo which linkchecker should have caught. It was broken by 31a8638. r? @alexcrichton
2 parents d880128 + 543eca2 commit c2a0d1b

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

Diff for: src/doc/reference.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,15 @@ Rust syntax is restricted in two ways:
650650

651651
[RFC 550]: https://github.com/rust-lang/rfcs/blob/master/text/0550-macro-future-proofing.md
652652

653-
## Procedrual Macros
653+
## Procedural Macros
654654

655-
"Procedrual macros" are the second way to implement a macro. For now, the only
655+
"Procedural macros" are the second way to implement a macro. For now, the only
656656
thing they can be used for is to implement derive on your own types. See
657657
[the book][procedural macros] for a tutorial.
658658

659659
Procedural macros involve a few different parts of the language and its
660660
standard libraries. First is the `proc_macro` crate, included with Rust,
661-
that defines an interface for building a procedrual macro. The
661+
that defines an interface for building a procedural macro. The
662662
`#[proc_macro_derive(Foo)]` attribute is used to mark the the deriving
663663
function. This function must have the type signature:
664664

@@ -3805,7 +3805,7 @@ impl From<i32> for String {
38053805
}
38063806
```
38073807

3808-
The notation `Self` in the impl refers to the implementing type: `String`. In another
3808+
The notation `Self` in the impl refers to the implementing type: `String`. In another
38093809
example:
38103810

38113811
```

Diff for: src/tools/linkchecker/main.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,23 @@ fn check(cache: &mut Cache,
151151
}
152152
let mut parts = url.splitn(2, "#");
153153
let url = parts.next().unwrap();
154-
if url.is_empty() {
155-
return
156-
}
157154
let fragment = parts.next();
158155
let mut parts = url.splitn(2, "?");
159156
let url = parts.next().unwrap();
160157

161158
// Once we've plucked out the URL, parse it using our base url and
162159
// then try to extract a file path.
163160
let mut path = file.to_path_buf();
164-
path.pop();
165-
for part in Path::new(url).components() {
166-
match part {
167-
Component::Prefix(_) |
168-
Component::RootDir => panic!(),
169-
Component::CurDir => {}
170-
Component::ParentDir => { path.pop(); }
171-
Component::Normal(s) => { path.push(s); }
161+
if !url.is_empty() {
162+
path.pop();
163+
for part in Path::new(url).components() {
164+
match part {
165+
Component::Prefix(_) |
166+
Component::RootDir => panic!(),
167+
Component::CurDir => {}
168+
Component::ParentDir => { path.pop(); }
169+
Component::Normal(s) => { path.push(s); }
170+
}
172171
}
173172
}
174173

0 commit comments

Comments
 (0)