Skip to content

Commit 4827bdc

Browse files
author
Michael Wright
committed
Merge branch 'master' into issue_2741
2 parents 7df5601 + 9f8624e commit 4827bdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1563
-716
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ matrix:
4848
- env: INTEGRATION=serde-rs/serde
4949
- env: INTEGRATION=Geal/nom
5050
- env: INTEGRATION=hyperium/hyper
51-
allow_failures:
5251
- env: INTEGRATION=rust-lang/cargo
5352
- env: INTEGRATION=rust-lang-nursery/rls
5453

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## 0.0.210
5+
* Rustup to *rustc 1.28.0-nightly (01cc982e9 2018-06-24)*
6+
7+
## 0.0.209
8+
* Rustup to *rustc 1.28.0-nightly (523097979 2018-06-18)*
9+
410
## 0.0.208
511
* Rustup to *rustc 1.28.0-nightly (86a8f1a63 2018-06-17)*
612

@@ -635,6 +641,7 @@ All notable changes to this project will be documented in this file.
635641
[`crosspointer_transmute`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#crosspointer_transmute
636642
[`cyclomatic_complexity`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#cyclomatic_complexity
637643
[`decimal_literal_representation`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#decimal_literal_representation
644+
[`default_trait_access`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#default_trait_access
638645
[`deprecated_semver`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#deprecated_semver
639646
[`deref_addrof`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#deref_addrof
640647
[`derive_hash_xor_eq`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#derive_hash_xor_eq
@@ -775,6 +782,7 @@ All notable changes to this project will be documented in this file.
775782
[`out_of_bounds_indexing`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#out_of_bounds_indexing
776783
[`overflow_check_conditional`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#overflow_check_conditional
777784
[`panic_params`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#panic_params
785+
[`panicking_unwrap`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#panicking_unwrap
778786
[`partialeq_ne_impl`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#partialeq_ne_impl
779787
[`possible_missing_comma`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#possible_missing_comma
780788
[`precedence`]: https://rust-lang-nursery.github.io/rust-clippy/master/index.html#precedence

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cargo-features = ["edition"]
22

33
[package]
44
name = "clippy"
5-
version = "0.0.208"
5+
version = "0.0.210"
66
authors = [
77
"Manish Goregaokar <[email protected]>",
88
"Andre Bogus <[email protected]>",
@@ -40,7 +40,7 @@ path = "src/driver.rs"
4040

4141
[dependencies]
4242
# begin automatic update
43-
clippy_lints = { version = "0.0.208", path = "clippy_lints" }
43+
clippy_lints = { version = "0.0.210", path = "clippy_lints" }
4444
# end automatic update
4545
regex = "1"
4646
semver = "0.9"

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
We are currently in the process of discussing Clippy 1.0 via the RFC process in https://github.com/rust-lang/rfcs/pull/2476 . The RFC's goal is to clarify policies around lint categorizations and the policy around which lints should be in the compiler and which lints should be in clippy. Please leave your thoughts on the RFC PR.
2+
13
# rust-clippy
24

35
[![Build Status](https://travis-ci.org/rust-lang-nursery/rust-clippy.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/rust-clippy)
4-
[![Windows build status](https://ci.appveyor.com/api/projects/status/github/rust-lang-nursery/rust-clippy?svg=true)](https://ci.appveyor.com/project/rust-lang-nursery/rust-clippy)
6+
[![Windows Build status](https://ci.appveyor.com/api/projects/status/id677xpw1dguo7iw?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/rust-clippy)
57
[![Current Version](https://meritbadge.herokuapp.com/clippy)](https://crates.io/crates/clippy)
68
[![License: MPL-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
79

810
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
911

10-
[There are 268 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
12+
[There are 270 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
1113

1214
We have a bunch of lint categories to allow you to choose how much clippy is supposed to ~~annoy~~ help you:
1315

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cargo-features = ["edition"]
33
[package]
44
name = "clippy_lints"
55
# begin automatic update
6-
version = "0.0.208"
6+
version = "0.0.210"
77
# end automatic update
88
authors = [
99
"Manish Goregaokar <[email protected]>",

clippy_lints/src/array_indexing.rs

Lines changed: 0 additions & 123 deletions
This file was deleted.

clippy_lints/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
207207
}
208208

209209
fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool {
210-
if let ItemFn(_, _, _, _, _, eid) = item.node {
210+
if let ItemFn(_, _, _, eid) = item.node {
211211
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
212212
} else {
213213
true
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
use rustc::hir::*;
2+
use rustc::lint::*;
3+
use rustc::ty::TypeVariants;
4+
5+
use crate::utils::{any_parent_is_automatically_derived, match_def_path, opt_def_id, paths, span_lint_and_sugg};
6+
7+
8+
/// **What it does:** Checks for literal calls to `Default::default()`.
9+
///
10+
/// **Why is this bad?** It's more clear to the reader to use the name of the type whose default is
11+
/// being gotten than the generic `Default`.
12+
///
13+
/// **Known problems:** None.
14+
///
15+
/// **Example:**
16+
/// ```rust
17+
/// // Bad
18+
/// let s: String = Default::default();
19+
///
20+
/// // Good
21+
/// let s = String::default();
22+
/// ```
23+
declare_clippy_lint! {
24+
pub DEFAULT_TRAIT_ACCESS,
25+
style,
26+
"checks for literal calls to Default::default()"
27+
}
28+
29+
#[derive(Copy, Clone)]
30+
pub struct DefaultTraitAccess;
31+
32+
impl LintPass for DefaultTraitAccess {
33+
fn get_lints(&self) -> LintArray {
34+
lint_array!(DEFAULT_TRAIT_ACCESS)
35+
}
36+
}
37+
38+
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DefaultTraitAccess {
39+
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
40+
if_chain! {
41+
if let ExprCall(ref path, ..) = expr.node;
42+
if !any_parent_is_automatically_derived(cx.tcx, expr.id);
43+
if let ExprPath(ref qpath) = path.node;
44+
if let Some(def_id) = opt_def_id(cx.tables.qpath_def(qpath, path.hir_id));
45+
if match_def_path(cx.tcx, def_id, &paths::DEFAULT_TRAIT_METHOD);
46+
then {
47+
match qpath {
48+
QPath::Resolved(..) => {
49+
// TODO: Work out a way to put "whatever the imported way of referencing
50+
// this type in this file" rather than a fully-qualified type.
51+
let expr_ty = cx.tables.expr_ty(expr);
52+
if let TypeVariants::TyAdt(..) = expr_ty.sty {
53+
let replacement = format!("{}::default()", expr_ty);
54+
span_lint_and_sugg(
55+
cx,
56+
DEFAULT_TRAIT_ACCESS,
57+
expr.span,
58+
&format!("Calling {} is more clear than this expression", replacement),
59+
"try",
60+
replacement);
61+
}
62+
},
63+
QPath::TypeRelative(..) => {},
64+
}
65+
}
66+
}
67+
}
68+
}

clippy_lints/src/eval_order_dependence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'a, 'tcx> DivergenceVisitor<'a, 'tcx> {
124124
impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
125125
fn visit_expr(&mut self, e: &'tcx Expr) {
126126
match e.node {
127-
ExprAgain(_) | ExprBreak(_, _) | ExprRet(_) => self.report_diverging_sub_expr(e),
127+
ExprContinue(_) | ExprBreak(_, _) | ExprRet(_) => self.report_diverging_sub_expr(e),
128128
ExprCall(ref func, _) => {
129129
let typ = self.cx.tables.expr_ty(func);
130130
match typ.sty {

clippy_lints/src/functions.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
9292
};
9393

9494
let unsafety = match kind {
95-
hir::intravisit::FnKind::ItemFn(_, _, unsafety, _, _, _, _) => unsafety,
96-
hir::intravisit::FnKind::Method(_, sig, _, _) => sig.unsafety,
95+
hir::intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _, _) => unsafety,
96+
hir::intravisit::FnKind::Method(_, sig, _, _) => sig.header.unsafety,
9797
hir::intravisit::FnKind::Closure(_) => return,
9898
};
9999

100100
// don't warn for implementations, it's not their fault
101101
if !is_impl {
102102
// don't lint extern functions decls, it's not their fault either
103103
match kind {
104-
hir::intravisit::FnKind::Method(_, &hir::MethodSig { abi: Abi::Rust, .. }, _, _) |
105-
hir::intravisit::FnKind::ItemFn(_, _, _, _, Abi::Rust, _, _) => self.check_arg_number(cx, decl, span),
104+
hir::intravisit::FnKind::Method(_, &hir::MethodSig { header: hir::FnHeader { abi: Abi::Rust, .. }, .. }, _, _) |
105+
hir::intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }, _, _) => self.check_arg_number(cx, decl, span),
106106
_ => {},
107107
}
108108
}
@@ -113,13 +113,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
113113
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
114114
if let hir::TraitItemKind::Method(ref sig, ref eid) = item.node {
115115
// don't lint extern functions decls, it's not their fault
116-
if sig.abi == Abi::Rust {
116+
if sig.header.abi == Abi::Rust {
117117
self.check_arg_number(cx, &sig.decl, item.span);
118118
}
119119

120120
if let hir::TraitMethod::Provided(eid) = *eid {
121121
let body = cx.tcx.hir.body(eid);
122-
self.check_raw_ptr(cx, sig.unsafety, &sig.decl, body, item.id);
122+
self.check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.id);
123123
}
124124
}
125125
}

0 commit comments

Comments
 (0)