Skip to content

Commit d0b3616

Browse files
authored
Merge branch 'master' into cast-ref-to-mut
2 parents f239f7d + c63b634 commit d0b3616

Some content is hidden

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

69 files changed

+895
-487
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ matrix:
7171
if: repo =~ /^rust-lang\/rust-clippy$/
7272
- env: INTEGRATION=hyperium/hyper
7373
if: repo =~ /^rust-lang\/rust-clippy$/
74+
- env: INTEGRATION=bluss/rust-itertools
75+
if: repo =~ /^rust-lang\/rust-clippy$/
7476
allow_failures:
7577
- os: windows
7678
env: CARGO_INCREMENTAL=0 BASE_TESTS=true

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,6 @@ All notable changes to this project will be documented in this file.
815815
[`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
816816
[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
817817
[`question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#question_mark
818-
[`random_state`]: https://rust-lang.github.io/rust-clippy/master/index.html#random_state
819818
[`range_minus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_minus_one
820819
[`range_plus_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_plus_one
821820
[`range_step_by_zero`]: https://rust-lang.github.io/rust-clippy/master/index.html#range_step_by_zero

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,15 @@ Therefore you should use `tests/ui/update-all-references.sh` (after running
156156
`cargo test`) and check whether the output looks as you expect with `git diff`. Commit all
157157
`*.stderr` files, too.
158158

159+
If the lint you are working on is making use of structured suggestions, the
160+
test file should include a `// run-rustfix` comment at the top. This will
161+
additionally run [rustfix](https://github.com/rust-lang-nursery/rustfix) for
162+
that test. Rustfix will apply the suggestions from the lint to the code of the
163+
test file and compare that to the contents of a `.fixed` file.
164+
165+
Use `tests/ui/update-all-references.sh` to automatically generate the
166+
`.fixed` file after running `cargo test`.
167+
159168
### Running rustfmt
160169

161170
[Rustfmt](https://github.com/rust-lang/rustfmt) is a tool for formatting Rust code according

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
4343
# end automatic update
4444
regex = "1"
4545
semver = "0.9"
46-
rustc_tools_util = { version = "0.1.0", path = "rustc_tools_util"}
46+
rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
4747

4848
[dev-dependencies]
4949
clippy_dev = { version = "0.0.1", path = "clippy_dev" }
5050
cargo_metadata = "0.6.2"
51-
compiletest_rs = "0.3.16"
51+
compiletest_rs = "0.3.18"
5252
lazy_static = "1.0"
5353
serde_derive = "1.0"
5454
clippy-mini-macro-test = { version = "0.2", path = "mini-macro" }
@@ -61,7 +61,7 @@ derive-new = "0.5"
6161
rustc-workspace-hack = "1.0.0"
6262

6363
[build-dependencies]
64-
rustc_tools_util = { version = "0.1.0", path = "rustc_tools_util"}
64+
rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
6565

6666
[features]
6767
debugging = []

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

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

10-
[There are 292 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
10+
[There are 291 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1111

1212
We have a bunch of lint categories to allow you to choose how much Clippy is supposed to ~~annoy~~ help you:
1313

clippy_lints/src/consts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ use rustc::lint::LateContext;
1717
use rustc::ty::subst::{Subst, Substs};
1818
use rustc::ty::{self, Instance, Ty, TyCtxt};
1919
use rustc::{bug, span_bug};
20+
use rustc_data_structures::sync::Lrc;
2021
use std::cmp::Ordering::{self, Equal};
2122
use std::cmp::PartialOrd;
2223
use std::convert::TryInto;
2324
use std::hash::{Hash, Hasher};
24-
use std::rc::Rc;
2525
use syntax::ast::{FloatTy, LitKind};
2626
use syntax::ptr::P;
2727

@@ -31,7 +31,7 @@ pub enum Constant {
3131
/// a String "abc"
3232
Str(String),
3333
/// a Binary String b"abc"
34-
Binary(Rc<Vec<u8>>),
34+
Binary(Lrc<Vec<u8>>),
3535
/// a single char 'a'
3636
Char(char),
3737
/// an integer's bit representation
@@ -156,7 +156,7 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant {
156156
match *lit {
157157
LitKind::Str(ref is, _) => Constant::Str(is.to_string()),
158158
LitKind::Byte(b) => Constant::Int(u128::from(b)),
159-
LitKind::ByteStr(ref s) => Constant::Binary(Rc::clone(s)),
159+
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
160160
LitKind::Char(c) => Constant::Char(c),
161161
LitKind::Int(n, _) => Constant::Int(n),
162162
LitKind::Float(ref is, _) | LitKind::FloatUnsuffixed(ref is) => match ty.sty {
@@ -304,7 +304,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
304304
};
305305

306306
let result = self.tcx.const_eval(self.param_env.and(gid)).ok()?;
307-
let ret = miri_to_const(self.tcx, result);
307+
let ret = miri_to_const(self.tcx, &result);
308308
if ret.is_some() {
309309
self.needed_resolution = true;
310310
}

clippy_lints/src/enum_clike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
7070
promoted: None,
7171
};
7272
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
73-
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, c)) {
73+
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, &c)) {
7474
let mut ty = cx.tcx.type_of(def_id);
7575
if let ty::Adt(adt, _) = ty.sty {
7676
if adt.is_enum() {

clippy_lints/src/enum_variants.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc::lint::{EarlyContext, EarlyLintPass, Lint, LintArray, LintPass};
1515
use rustc::{declare_tool_lint, lint_array};
1616
use syntax::ast::*;
1717
use syntax::source_map::Span;
18-
use syntax::symbol::LocalInternedString;
18+
use syntax::symbol::{InternedString, LocalInternedString};
1919

2020
/// **What it does:** Detects enumeration variants that are prefixed or suffixed
2121
/// by the same characters.
@@ -111,7 +111,7 @@ declare_clippy_lint! {
111111
}
112112

113113
pub struct EnumVariantNames {
114-
modules: Vec<(LocalInternedString, String)>,
114+
modules: Vec<(InternedString, String)>,
115115
threshold: u64,
116116
}
117117

@@ -308,6 +308,6 @@ impl EarlyLintPass for EnumVariantNames {
308308
};
309309
check_variant(cx, self.threshold, def, &item_name, item_name_chars, item.span, lint);
310310
}
311-
self.modules.push((item_name, item_camel));
311+
self.modules.push((item_name.as_interned_str(), item_camel));
312312
}
313313
}

clippy_lints/src/len_zero.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,15 @@ fn has_is_empty(cx: &LateContext<'_, '_>, expr: &Expr) -> bool {
302302

303303
let ty = &walk_ptrs_ty(cx.tables.expr_ty(expr));
304304
match ty.sty {
305-
ty::Dynamic(ref tt, ..) => cx
306-
.tcx
307-
.associated_items(tt.principal().def_id())
308-
.any(|item| is_is_empty(cx, &item)),
305+
ty::Dynamic(ref tt, ..) => {
306+
if let Some(principal) = tt.principal() {
307+
cx.tcx
308+
.associated_items(principal.def_id())
309+
.any(|item| is_is_empty(cx, &item))
310+
} else {
311+
false
312+
}
313+
},
309314
ty::Projection(ref proj) => has_is_empty_impl(cx, proj.item_def_id),
310315
ty::Adt(id, _) => has_is_empty_impl(cx, id.did),
311316
ty::Array(..) | ty::Slice(..) | ty::Str => true,

clippy_lints/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ pub mod precedence;
180180
pub mod ptr;
181181
pub mod ptr_offset_with_cast;
182182
pub mod question_mark;
183-
pub mod random_state;
184183
pub mod ranges;
185184
pub mod redundant_clone;
186185
pub mod redundant_field_names;
@@ -487,8 +486,8 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
487486
reg.register_late_lint_pass(box ptr_offset_with_cast::Pass);
488487
reg.register_late_lint_pass(box redundant_clone::RedundantClone);
489488
reg.register_late_lint_pass(box slow_vector_initialization::Pass);
490-
reg.register_late_lint_pass(box random_state::Pass);
491489
reg.register_late_lint_pass(box types::RefToMut);
490+
492491

493492
reg.register_lint_group("clippy::restriction", Some("clippy_restriction"), vec![
494493
arithmetic::FLOAT_ARITHMETIC,
@@ -1028,7 +1027,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
10281027
fallible_impl_from::FALLIBLE_IMPL_FROM,
10291028
mutex_atomic::MUTEX_INTEGER,
10301029
needless_borrow::NEEDLESS_BORROW,
1031-
random_state::RANDOM_STATE,
10321030
redundant_clone::REDUNDANT_CLONE,
10331031
types::CAST_REF_TO_MUT,
10341032
unwrap::PANICKING_UNWRAP,

0 commit comments

Comments
 (0)