Update references in doc directory

This commit is contained in:
Samuel E. Moelius III 2021-02-18 06:08:46 -05:00
parent 33ee598a9f
commit c7869b82a2
2 changed files with 9 additions and 8 deletions

View File

@ -292,7 +292,7 @@ the next section. Let's worry about the details later and emit our lint for
Depending on how complex we want our lint message to be, we can choose from a Depending on how complex we want our lint message to be, we can choose from a
variety of lint emission functions. They can all be found in variety of lint emission functions. They can all be found in
[`clippy_lints/src/utils/diagnostics.rs`][diagnostics]. [`clippy_utils/src/diagnostics.rs`][diagnostics].
`span_lint_and_help` seems most appropriate in this case. It allows us to `span_lint_and_help` seems most appropriate in this case. It allows us to
provide an extra help message and we can't really suggest a better name provide an extra help message and we can't really suggest a better name
@ -321,7 +321,7 @@ When code or an identifier must appear in a message or label, it should be
surrounded with single grave accents \`. surrounded with single grave accents \`.
[check_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html#method.check_fn [check_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html#method.check_fn
[diagnostics]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/diagnostics.rs [diagnostics]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/diagnostics.rs
[the rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/diagnostics.html [the rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/diagnostics.html
## Adding the lint logic ## Adding the lint logic
@ -537,7 +537,7 @@ directory. Adding a configuration to a lint can be useful for thresholds or to c
behavior that can be seen as a false positive for some users. Adding a configuration is done behavior that can be seen as a false positive for some users. Adding a configuration is done
in the following steps: in the following steps:
1. Adding a new configuration entry to [clippy_lints::utils::conf](/clippy_lints/src/utils/conf.rs) 1. Adding a new configuration entry to [clippy_utils::conf](/clippy_utils/src/conf.rs)
like this: like this:
```rust ```rust
/// Lint: LINT_NAME. <The configuration field doc comment> /// Lint: LINT_NAME. <The configuration field doc comment>
@ -636,7 +636,7 @@ documentation currently. This is unfortunate, but in most cases you can probably
get away with copying things from existing similar lints. If you are stuck, get away with copying things from existing similar lints. If you are stuck,
don't hesitate to ask on [Zulip] or in the issue/PR. don't hesitate to ask on [Zulip] or in the issue/PR.
[utils]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/mod.rs [utils]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/lib.rs
[if_chain]: https://docs.rs/if_chain/*/if_chain/ [if_chain]: https://docs.rs/if_chain/*/if_chain/
[from_expansion]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html#method.from_expansion [from_expansion]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html#method.from_expansion
[in_external_macro]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/fn.in_external_macro.html [in_external_macro]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/fn.in_external_macro.html

View File

@ -78,7 +78,7 @@ impl LateLintPass<'_> for MyStructLint {
There are two ways to do this, depending if the target trait is part of lang items. There are two ways to do this, depending if the target trait is part of lang items.
```rust ```rust
use crate::utils::{implements_trait, match_trait_method, paths}; use clippy_utils::{implements_trait, match_trait_method, paths};
impl LateLintPass<'_> for MyStructLint { impl LateLintPass<'_> for MyStructLint {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
@ -112,7 +112,7 @@ We access lang items through the type context `tcx`. `tcx` is of type [`TyCtxt`]
To check if our type defines a method called `some_method`: To check if our type defines a method called `some_method`:
```rust ```rust
use crate::utils::{is_type_diagnostic_item, return_ty}; use clippy_utils::{is_type_diagnostic_item, return_ty};
impl<'tcx> LateLintPass<'tcx> for MyTypeImpl { impl<'tcx> LateLintPass<'tcx> for MyTypeImpl {
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
@ -135,7 +135,7 @@ impl<'tcx> LateLintPass<'tcx> for MyTypeImpl {
# Dealing with macros # Dealing with macros
There are several helpers in Clippy's utils to deal with macros: There are several helpers in [`clippy_utils`][utils] to deal with macros:
- `in_macro()`: detect if the given span is expanded by a macro - `in_macro()`: detect if the given span is expanded by a macro
@ -199,4 +199,5 @@ assert_eq!(differing_macro_contexts(x_is_some_span, x_unwrap_span), true);
[LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html [LateContext]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/struct.LateContext.html
[TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html [TyCtxt]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html
[pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty [pat_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TypeckResults.html#method.pat_ty
[paths]: ../clippy_lints/src/utils/paths.rs [paths]: ../clippy_utils/src/paths.rs
[utils]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/lib.rs