]> git.lizzy.rs Git - rust.git/blobdiff - CONTRIBUTING.md
Merge pull request #3113 from mikerite/fix-3112
[rust.git] / CONTRIBUTING.md
index b62ccbd93d3571d1a5b00fbc2bbb18b6f56b2ac0..3d1385244a6f89033bf2709088b1a5f346c77776 100644 (file)
@@ -1,11 +1,13 @@
-# Contributing to rust-clippy
+# Contributing to Clippy
 
 Hello fellow Rustacean! Great to see your interest in compiler internals and lints!
 
+**First**: if you're unsure or afraid of _anything_, just ask or submit the issue or pull request anyway. You won't be yelled at for giving it your best effort. The worst that can happen is that you'll be politely asked to change something. We appreciate any sort of contributions, and don't want a wall of rules to get in the way of that.
+
 Clippy welcomes contributions from everyone. There are many ways to contribute to Clippy and the following document explains how
 you can contribute and how to get started.
 If you have any questions about contributing or need help with anything, feel free to ask questions on issues or
-visit the `#clippy` IRC channel on `irc.mozilla.org`.
+visit the `#clippy` IRC channel on `irc.mozilla.org` or meet us in `#wg-clippy` on [Discord](https://discord.gg/rust-lang).
 
 All contributors are expected to follow the [Rust Code of Conduct](http://www.rust-lang.org/conduct.html).
 
@@ -61,7 +63,7 @@ an AST expression). `match_def_path()` in Clippy's `utils` module can also be us
 
 ## Writing code
 
-Compiling clippy from scratch can take almost a minute or more depending on your machine.
+Compiling Clippy from scratch can take almost a minute or more depending on your machine.
 However, since Rust 1.24.0 incremental compilation is enabled by default and compile times for small changes should be quick.
 
 [Llogiq's blog post on lints](https://llogiq.github.io/2015/06/04/workflows.html) is a nice primer
@@ -72,18 +74,14 @@ of this.
 
 ### Author lint
 
-There is also the internal `author` lint to generate clippy code that detects the offending pattern. It does not work for all of the Rust syntax, but can give a good starting point.
+There is also the internal `author` lint to generate Clippy code that detects the offending pattern. It does not work for all of the Rust syntax, but can give a good starting point.
 
 First, create a new UI test file in the `tests/ui/` directory with the pattern you want to match:
 
 ```rust
 // ./tests/ui/my_lint.rs
-
-// The custom_attribute needs to be enabled for the author lint to work
-#![feature(plugin, custom_attribute)]
-
 fn main() {
-    #[clippy(author)]
+    #[clippy::author]
     let arr: [i32; 1] = [7]; // Replace line with the code you want to match
 }
 ```
@@ -95,9 +93,9 @@ a `.stdout` file with the generated code:
 // ./tests/ui/my_lint.stdout
 
 if_chain! {
-    if let Expr_::ExprArray(ref elements) = stmt.node;
+    if let ExprKind::Array(ref elements) = stmt.node;
     if elements.len() == 1;
-    if let Expr_::ExprLit(ref lit) = elements[0].node;
+    if let ExprKind::Lit(ref lit) = elements[0].node;
     if let LitKind::Int(7, _) = lit.node;
     then {
         // report your lint here
@@ -150,7 +148,7 @@ Therefore you should use `tests/ui/update-all-references.sh` (after running
 ### Testing manually
 
 Manually testing against an example file is useful if you have added some
-`println!`s and test suite output becomes unreadable.  To try clippy with your
+`println!`s and test suite output becomes unreadable.  To try Clippy with your
 local modifications, run `cargo run --bin clippy-driver -- -L ./target/debug input.rs` from the
 working copy root.
 
@@ -172,7 +170,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
     reg.register_early_lint_pass(box else_if_without_else::ElseIfWithoutElse);
     // ...
 
-    reg.register_lint_group("clippy_restriction", vec![
+    reg.register_lint_group("clippy::restriction", vec![
         // ...
         else_if_without_else::ELSE_IF_WITHOUT_ELSE,
         // ...
@@ -181,13 +179,13 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
 ```
 
 The [`rustc_plugin::PluginRegistry`][plugin_registry] provides two methods to register lints: [register_early_lint_pass][reg_early_lint_pass] and [register_late_lint_pass][reg_late_lint_pass].
-Both take an object that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in every single lint. 
+Both take an object that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in every single lint.
 It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `util/update_lints.py` and you don't have to add anything by hand. When you are writing your own lint, you can use that script to save you some time.
 
 ```rust
 // ./clippy_lints/src/else_if_without_else.rs
 
-use rustc::lint::*;
+use rustc::lint::{EarlyLintPass, LintArray, LintPass};
 
 // ...