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

Convert clippy_lints to intra-doc links #6412

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::f64::consts as f64;
declare_clippy_lint! {
/// **What it does:** Checks for floating point literals that approximate
/// constants which are defined in
/// [`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)
/// [`std::f32::consts`](std::f32::consts#constants)
/// or
/// [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),
/// [`std::f64::consts`](std::f64::consts#constants),
/// respectively, suggesting to use the predefined constant.
///
/// **Why is this bad?** Usually, the definition in the standard library is more
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ declare_clippy_lint! {
/// ```
///
/// Note that there are crates that simplify creating the error type, e.g.
/// [`thiserror`](https://docs.rs/thiserror).
/// [`thiserror`].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// [`thiserror`].
/// [`thiserror`](https://docs.rs/thiserror).

pub RESULT_UNIT_ERR,
style,
"public function returning `Result` with an `Err` type of `()`"
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,14 @@ declare_clippy_lint! {
/// - yield or pause the thread
///
/// For `std` targets, this can be done with
/// [`std::thread::sleep`](https://doc.rust-lang.org/std/thread/fn.sleep.html)
/// or [`std::thread::yield_now`](https://doc.rust-lang.org/std/thread/fn.yield_now.html).
/// [`std::thread::sleep`](std::thread::sleep())
/// or [`std::thread::yield_now`](std::thread::yield_now()).
///
/// For `no_std` targets, doing this is more complicated, especially because
/// `#[panic_handler]`s can't panic. To stop/pause the thread, you will
/// probably need to invoke some target-specific intrinsic. Examples include:
/// - [`x86_64::instructions::hlt`](https://docs.rs/x86_64/0.12.2/x86_64/instructions/fn.hlt.html)
/// - [`cortex_m::asm::wfi`](https://docs.rs/cortex-m/0.6.3/cortex_m/asm/fn.wfi.html)
/// - [`x86_64::instructions::hlt`](x86_64::instructions::hlt())
/// - [`cortex_m::asm::wfi`](cortex_m::asm::wfi())
///
/// **Known problems:** None.
///
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mem_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare_clippy_lint! {
/// }
/// ```
///
/// The [take_mut](https://docs.rs/take_mut) crate offers a sound solution,
/// The [`take_mut`](https://docs.rs/take_mut) crate offers a sound solution,
/// at the cost of either lazily creating a replacement value or aborting
/// on panic, to ensure that the uninitialized value cannot be observed.
pub MEM_REPLACE_WITH_UNINIT,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ declare_clippy_lint! {
/// trait.
///
/// **Why is this bad?** It is recommended style to use collect. See
/// [FromIterator documentation](https://doc.rust-lang.org/std/iter/trait.FromIterator.html)
/// [`FromIterator` documentation](std::iter::FromIterator)
///
/// **Known problems:** None.
///
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ use rustc_span::sym;
declare_clippy_lint! {
/// **What it does:** Checks for types with a `fn new() -> Self` method and no
/// implementation of
/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html).
/// [`Default`](std::default::Default).
///
/// **Why is this bad?** The user might expect to be able to use
/// [`Default`](https://doc.rust-lang.org/std/default/trait.Default.html) as the
/// [`Default`](std::default::Default) as the
/// type can be constructed without arguments.
///
/// **Known problems:** Hopefully none.
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/path_buf_push_overwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
use std::path::{Component, Path};

declare_clippy_lint! {
/// **What it does:*** Checks for [push](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.push)
/// **What it does:*** Checks for [`push`](std::path::PathBuf::push())
/// calls on `PathBuf` that can cause overwrites.
///
/// **Why is this bad?** Calling `push` with a root path at the start can overwrite the
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ declare_clippy_lint! {
/// but has a semantically meaningful name.
/// - You might want to handle `None` returned from [`from_u32`] instead of calling `unwrap`.
///
/// [`from_u32`]: https://doc.rust-lang.org/std/char/fn.from_u32.html
/// [`from_u32_unchecked`]: https://doc.rust-lang.org/std/char/fn.from_u32_unchecked.html
/// [`from_u32`]: std::char::from_u32()
/// [`from_u32_unchecked`]: std::char::from_u32_unchecked()
///
/// **Example:**
/// ```rust
Expand Down Expand Up @@ -162,8 +162,8 @@ declare_clippy_lint! {
/// but has a semantically meaningful name.
/// - You might want to handle errors returned from [`from_utf8`] instead of calling `unwrap`.
///
/// [`from_utf8`]: https://doc.rust-lang.org/std/str/fn.from_utf8.html
/// [`from_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked.html
/// [`from_utf8`]: std::str::from_utf8()
/// [`from_utf8_unchecked`]: std::str::from_utf8_unchecked()
///
/// **Example:**
/// ```rust
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use crate::utils::{

declare_clippy_lint! {
/// **What it does:** Checks for use of `Box<Vec<_>>` anywhere in the code.
/// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information.
/// Check the [`Box` documentation](std::boxed) for more information.
///
/// **Why is this bad?** `Vec` already keeps its contents in a separate area on
/// the heap. So if you `Box` it, you just add another level of indirection
Expand Down Expand Up @@ -68,7 +68,7 @@ declare_clippy_lint! {

declare_clippy_lint! {
/// **What it does:** Checks for use of `Vec<Box<T>>` where T: Sized anywhere in the code.
/// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information.
/// Check the [`Box` documentation](std::boxed) for more information.
///
/// **Why is this bad?** `Vec` already keeps its contents in a separate area on
/// the heap. So if you `Box` its contents, you just add another level of indirection.
Expand Down Expand Up @@ -171,7 +171,7 @@ declare_clippy_lint! {

declare_clippy_lint! {
/// **What it does:** Checks for use of `&Box<T>` anywhere in the code.
/// Check the [Box documentation](https://doc.rust-lang.org/std/boxed/index.html) for more information.
/// Check the [`Box` documentation](std::boxed) for more information.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these links also work on https://rust-lang.github.io/rust-clippy/?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, how is that documentation built? If you're using mdbook then it won't work. I guess there's not much point to the PR then :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mdbook? You wish! We're still using our good ol' python script. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yeah... I don't think we can change this in our lint documentation..

///
/// **Why is this bad?** Any `&Box<T>` can also be a `&T`, which is more
/// general.
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/verbose_file_reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare_clippy_lint! {
/// **What it does:** Checks for use of File::read_to_end and File::read_to_string.
///
/// **Why is this bad?** `fs::{read, read_to_string}` provide the same functionality when `buf` is empty with fewer imports and no intermediate values.
/// See also: [fs::read docs](https://doc.rust-lang.org/std/fs/fn.read.html), [fs::read_to_string docs](https://doc.rust-lang.org/std/fs/fn.read_to_string.html)
/// See also: [`fs::read` docs](std::fs::read()), [`fs::read_to_string` docs](std::fs::read_to_string())
///
/// **Known problems:** None.
///
Expand Down