Skip to content

Commit

Permalink
Auto merge of rust-lang#105763 - Ezrashaw:rustc-book-relative-links, …
Browse files Browse the repository at this point in the history
…r=jyn514

Use relative links in the unstable and rustc book

Fixes rust-lang#98227.

As it stands, potential issues could arise from mismatch of stable/ nightly in the books. This PR fixes this issue by using relative links instead of absolute ones. I have replaced every absolute link under `src/doc/rustc` and `src/doc/unstable-book/` and tested each manually.

The link at `src/doc/rustc/src/targets/index.md:7`:
`[here](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.Target.html).`
I need help with because my local directory structure and https://doc.rust-lang.org/ seem to be different, where is `nightly-rustc`?

`@jyn514`
  • Loading branch information
bors committed Dec 16, 2022
2 parents a803f31 + 9ea3550 commit 01ef4b2
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/doc/rustc/src/exploit-mitigations.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ It is recommended that explicit wrapping methods such as `wrapping_add` be
used when wrapping semantics are intended, and that explicit checking and
wrapping methods always be used when using Unsafe Rust.

<small id="fn:2">2\. See <https://doc.rust-lang.org/std/primitive.u32.html>
<small id="fn:2">2\. See [the `u32` docs](../std/primitive.u32.html)
for more information on the checked, overflowing, saturating, and wrapping
methods (using u32 as an example). <a href="#fnref:2"
class="reversefootnote" role="doc-backlink">↩</a></small>
Expand Down Expand Up @@ -575,17 +575,17 @@ defaults (unrelated to `READ_IMPLIES_EXEC`).
<https://hacks.mozilla.org/2019/02/fearless-security-thread-safety/>.

3. S. Klabnik and C. Nichols. “What Is Ownership?.” The Rust Programming
Language. <https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html>.
Language. [https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html](../book/ch04-01-what-is-ownership.html).

4. S. Klabnik and C. Nichols. “References and Borrowing.” The Rust
Programming Language.
<https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html>.
[https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html](../book/ch04-02-references-and-borrowing.html).

5. S. Klabnik and C. Nichols. “The Slice Type.” The Rust Programming
Language. <https://doc.rust-lang.org/book/ch04-03-slices.html>.
Language. [https://doc.rust-lang.org/book/ch04-03-slices.html](../book/ch04-03-slices.html).

6. S. Klabnik and C. Nichols. “Unsafe Rust.” The Rust Programming Language.
<https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html>.
[https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html](../book/ch19-01-unsafe-rust.html).

7. S. Davidoff. “How Rust’s standard library was vulnerable for years and
nobody noticed.” Medium.
Expand Down Expand Up @@ -696,4 +696,4 @@ defaults (unrelated to `READ_IMPLIES_EXEC`).
for Rust #89653.” GitHub. <https://github.com/rust-lang/rust/issues/89653>.

41. “ControlFlowIntegrity.” The Rust Unstable Book.
<https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#controlflowintegrity>.
[https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html#controlflowintegrity](../unstable-book/compiler-flags/sanitizer.html#controlflowintegrity).
2 changes: 1 addition & 1 deletion src/doc/rustc/src/linker-plugin-lto.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ targeting Windows-like targets
This is fixed if you explicitly set the target, for example
`cargo build --target x86_64-pc-windows-msvc`
Without an explicit --target the flags will be passed to all compiler invocations (including build
scripts and proc macros), see [cargo docs on rustflags](https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags)
scripts and proc macros), see [cargo docs on rustflags](../cargo/reference/config.html#buildrustflags)

If you have dependencies using the `cc` crate, you will need to set these
environment variables:
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support/android.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ edition of the [Android NDK]. Supported Android targets are:
[Android NDK]: https://developer.android.com/ndk/downloads

A list of all supported targets can be found
[here](https://doc.rust-lang.org/rustc/platform-support.html)
[here](../platform-support.html)
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support/armv6k-nintendo-3ds.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ to an SD card to be inserted in the device.
The `cargo-3ds` tool mentioned in [Building Rust programs](#building-rust-programs)
supports the use of `3dslink` with `cargo 3ds run`. The default Rust test runner
is not supported, but
[custom test frameworks](https://doc.rust-lang.org/beta/unstable-book/language-features/custom-test-frameworks.html)
[custom test frameworks](../../unstable-book/language-features/custom-test-frameworks.html)
can be used with `cargo 3ds test` to run unit tests on a device.

The Rust test suite for `library/std` is not yet supported.
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc/src/platform-support/fuchsia.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ rustup target add aarch64-fuchsia
After installing our Fuchsia targets, we can now compile a Rust binary that targets
Fuchsia.

To create our Rust project, we can issue a standard `cargo` command as follows:
To create our Rust project, we can use [`cargo`][cargo] as follows:

**From base working directory**
```sh
Expand Down Expand Up @@ -867,7 +867,7 @@ ${SDK_PATH}/tools/${ARCH}/ffx debug connect -- \
[Fuchsia]: https://fuchsia.dev/
[source tree]: https://fuchsia.dev/fuchsia-src/get-started/learn/build
[rustup]: https://rustup.rs/
[cargo]: https://doc.rust-lang.org/cargo/
[cargo]: ../../cargo/index.html
[Fuchsia SDK]: https://chrome-infra-packages.appspot.com/p/fuchsia/sdk/core
[overview of CML]: https://fuchsia.dev/fuchsia-src/concepts/components/v2/component_manifests
[reference for the file format]: https://fuchsia.dev/reference/cml
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/targets/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ To see it for a different target, add the `--target` flag:
rustc +nightly -Z unstable-options --target=wasm32-unknown-unknown --print target-spec-json
```

To use a custom target, see the (unstable) [`build-std` feature](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std) of `cargo`.
To use a custom target, see the (unstable) [`build-std` feature](../../cargo/reference/unstable.html#build-std) of `cargo`.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ For example, `-Z branch-protection=bti,pac-ret,leaf` is valid, but

Rust's standard library does not ship with BTI or pointer authentication enabled by default.
In Cargo projects the standard library can be recompiled with pointer authentication using the nightly
[build-std](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std) feature.
[build-std](../../cargo/reference/unstable.html#build-std) feature.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ It is strongly recommended to also enable CFG checks for all linked libraries, i

To enable CFG in the standard library, use the [cargo `-Z build-std` functionality][build-std] to recompile the standard library with the same configuration options as the main program.

[build-std]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std
[build-std]: ../../cargo/reference/unstable.html#build-std

For example:
```cmd
Expand Down
6 changes: 3 additions & 3 deletions src/doc/unstable-book/src/compiler-flags/sanitizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ flow using an indirect branch/call to a function with different return and
parameter types than the return type expected and arguments intended/passed in
the call/branch site, the execution is also terminated (see Fig. 9).
[rust-book-ch19-05]: https://doc.rust-lang.org/book/ch19-05-advanced-functions-and-closures.html
[rust-book]: https://doc.rust-lang.org/book/title-page.html
[rust-book-ch19-05]: ../../book/ch19-05-advanced-functions-and-closures.html
[rust-book]: ../../book/title-page.html
# HWAddressSanitizer
Expand Down Expand Up @@ -691,7 +691,7 @@ It is strongly recommended to combine sanitizers with recompiled and
instrumented standard library, for example using [cargo `-Zbuild-std`
functionality][build-std].
[build-std]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std
[build-std]: ../../cargo/reference/unstable.html#build-std
# Build scripts and procedural macros
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ optimized out, if unused. However, with `make_foo` you can produce a wrapped
to inlining of `f`, `Foo::foo` can then be called from a foreign crate. This can
lead to miscompilations.

[Clto]: https://doc.rust-lang.org/rustc/codegen-options/index.html#lto
[Clto]: ../../rustc/codegen-options/index.html#lto
4 changes: 2 additions & 2 deletions src/doc/unstable-book/src/language-features/auto-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ that are automatically implemented for every type, unless the type, or a type it
has explicitly opted out via a negative impl. (Negative impls are separately controlled
by the `negative_impls` feature.)

[`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html
[`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html
[`Send`]: ../../std/marker/trait.Send.html
[`Sync`]: ../../std/marker/trait.Sync.html

```rust,ignore (partial-example)
impl !Trait for Type {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `unboxed_closures` feature allows you to write functions using the `"rust-ca
required for implementing the [`Fn*`] family of traits. `"rust-call"` functions must have
exactly one (non self) argument, a tuple representing the argument list.

[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html
[`Fn*`]: ../../std/ops/trait.Fn.html

```rust
#![feature(unboxed_closures)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Adds a free `default()` function to the `std::default` module. This function
just forwards to [`Default::default()`], but may remove repetition of the word
"default" from the call site.

[`Default::default()`]: https://doc.rust-lang.org/nightly/std/default/trait.Default.html#tymethod.default
[`Default::default()`]: ../../std/default/trait.Default.html#tymethod.default

Here is an example:

Expand Down
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/library-features/fn-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See Also: [`unboxed_closures`](../language-features/unboxed-closures.md)
The `fn_traits` feature allows for implementation of the [`Fn*`] traits
for creating custom closure-like types.

[`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html
[`Fn*`]: ../../std/ops/trait.Fn.html

```rust
#![feature(unboxed_closures)]
Expand Down

0 comments on commit 01ef4b2

Please sign in to comment.