forked from rust-lang/rust-clippy
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Changes: ```` Rustup to rust-lang/rust#69674 Use visit_place Check for mutation Only fires on temporaries Extend `redundant_clone` to the case that cloned value is not consumed add CR feedback Improve documentation Use `edition:2018` flag more widely Update tests/ui/needless_doc_main.rs Move links to the end of each chapter on adding_lints Move links to the end of each chapter on CONTRIBUTING Clean-up adding_lints.md Clean-up CONTRIBUTING.md needless_doc_main: only check rust code Use `node_type_opt` over `node_type` Fix doc Fix ICE with trivial_bounds feature clippy_lints: readme: don't mention crates.io since it is no longer used to publish clippy. update rust-lang.github.io to rustc-dev-guide.rust-lang.org Improve placeholder in map_unit_fn Fix match single binding when in a let stmt Improve error messages for {option,result}_map_unit_fn Mention the setup instructions in CONTRIBUTING redundant_pattern: take binding (ref, ref mut) into account in suggestion. check_pat: delay creation of the "normal" vec until we reach the branch where is is actually needed deps: bump itertools 0.8 -> 0.9 add lint on File::read_to_string and File::read_to_end transition rustc-guide to rustc-dev-guide Rename macro_use_import -> macro_use_imports warn on macro_use attr Fix deploy script for tag deploys ```` Fixes #69957
- Loading branch information
1 parent
302d2e5
commit b7fc905
Showing
62 changed files
with
928 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
This crate contains Clippy lints. For the main crate, check | ||
[*crates.io*](https://crates.io/crates/clippy) or | ||
[GitHub](https://github.com/rust-lang/rust-clippy). | ||
This crate contains Clippy lints. For the main crate, check [GitHub](https://github.com/rust-lang/rust-clippy). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use crate::utils::{snippet, span_lint_and_sugg}; | ||
use if_chain::if_chain; | ||
use rustc_ast::ast; | ||
use rustc_errors::Applicability; | ||
use rustc_lint::{EarlyContext, EarlyLintPass}; | ||
use rustc_session::{declare_lint_pass, declare_tool_lint}; | ||
use rustc_span::edition::Edition; | ||
|
||
declare_clippy_lint! { | ||
/// **What it does:** Checks for `#[macro_use] use...`. | ||
/// | ||
/// **Why is this bad?** Since the Rust 2018 edition you can import | ||
/// macro's directly, this is considered idiomatic. | ||
/// | ||
/// **Known problems:** This lint does not generate an auto-applicable suggestion. | ||
/// | ||
/// **Example:** | ||
/// ```rust | ||
/// #[macro_use] | ||
/// use lazy_static; | ||
/// ``` | ||
pub MACRO_USE_IMPORTS, | ||
pedantic, | ||
"#[macro_use] is no longer needed" | ||
} | ||
|
||
declare_lint_pass!(MacroUseImports => [MACRO_USE_IMPORTS]); | ||
|
||
impl EarlyLintPass for MacroUseImports { | ||
fn check_item(&mut self, ecx: &EarlyContext<'_>, item: &ast::Item) { | ||
if_chain! { | ||
if ecx.sess.opts.edition == Edition::Edition2018; | ||
if let ast::ItemKind::Use(use_tree) = &item.kind; | ||
if let Some(mac_attr) = item | ||
.attrs | ||
.iter() | ||
.find(|attr| attr.ident().map(|s| s.to_string()) == Some("macro_use".to_string())); | ||
then { | ||
let msg = "`macro_use` attributes are no longer needed in the Rust 2018 edition"; | ||
let help = format!("use {}::<macro name>", snippet(ecx, use_tree.span, "_")); | ||
span_lint_and_sugg( | ||
ecx, | ||
MACRO_USE_IMPORTS, | ||
mac_attr.span, | ||
msg, | ||
"remove the attribute and import the macro directly, try", | ||
help, | ||
Applicability::HasPlaceholders, | ||
); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.