Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkchecker: Fix checking links which are just fragments #39204

Merged
merged 1 commit into from
Jan 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,15 @@ Rust syntax is restricted in two ways:

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

## Procedrual Macros
## Procedural Macros

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

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

Expand Down Expand Up @@ -3805,7 +3805,7 @@ impl From<i32> for String {
}
```

The notation `Self` in the impl refers to the implementing type: `String`. In another
The notation `Self` in the impl refers to the implementing type: `String`. In another
example:

```
Expand Down
21 changes: 10 additions & 11 deletions src/tools/linkchecker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,24 +151,23 @@ fn check(cache: &mut Cache,
}
let mut parts = url.splitn(2, "#");
let url = parts.next().unwrap();
if url.is_empty() {
return
}
let fragment = parts.next();
let mut parts = url.splitn(2, "?");
let url = parts.next().unwrap();

// Once we've plucked out the URL, parse it using our base url and
// then try to extract a file path.
let mut path = file.to_path_buf();
path.pop();
for part in Path::new(url).components() {
match part {
Component::Prefix(_) |
Component::RootDir => panic!(),
Component::CurDir => {}
Component::ParentDir => { path.pop(); }
Component::Normal(s) => { path.push(s); }
if !url.is_empty() {
path.pop();
for part in Path::new(url).components() {
match part {
Component::Prefix(_) |
Component::RootDir => panic!(),
Component::CurDir => {}
Component::ParentDir => { path.pop(); }
Component::Normal(s) => { path.push(s); }
}
}
}

Expand Down