From c7869b82a282c93a84794686b4e8ba1c4d15bfe2 Mon Sep 17 00:00:00 2001 From: "Samuel E. Moelius III" Date: Thu, 18 Feb 2021 06:08:46 -0500 Subject: [PATCH] Update references in doc directory --- doc/adding_lints.md | 8 ++++---- doc/common_tools_writing_lints.md | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/adding_lints.md b/doc/adding_lints.md index e12e75d4a2b..f62c2d29c70 100644 --- a/doc/adding_lints.md +++ b/doc/adding_lints.md @@ -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 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 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 \`. [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 ## 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 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: ```rust /// Lint: LINT_NAME. @@ -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, 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/ [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 diff --git a/doc/common_tools_writing_lints.md b/doc/common_tools_writing_lints.md index d56079a4ab7..abac1227b4f 100644 --- a/doc/common_tools_writing_lints.md +++ b/doc/common_tools_writing_lints.md @@ -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. ```rust -use crate::utils::{implements_trait, match_trait_method, paths}; +use clippy_utils::{implements_trait, match_trait_method, paths}; impl LateLintPass<'_> for MyStructLint { 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`: ```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 { 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 -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 @@ -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 [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 -[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