Skip to content

Commit 7531a08

Browse files
committed
Auto merge of #4788 - Manishearth:rustup, r=flip1995
Rustup to rustc 1.40.0-nightly (50f8aad 2019-11-07) changelog: Deprecate [`into_iter_on_array`] lint r? @phansch @oli-obk
2 parents 43a3796 + 08fd397 commit 7531a08

27 files changed

+124
-166
lines changed

README.md

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

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

9-
[There are 332 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
9+
[There are 331 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
1010

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

clippy_lints/src/approx_const.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc::hir::*;
33
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
44
use rustc::{declare_lint_pass, declare_tool_lint};
55
use std::f64::consts as f64;
6-
use syntax::ast::{FloatTy, LitKind};
6+
use syntax::ast::{FloatTy, LitFloatType, LitKind};
77
use syntax::symbol;
88

99
declare_clippy_lint! {
@@ -62,9 +62,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ApproxConstant {
6262

6363
fn check_lit(cx: &LateContext<'_, '_>, lit: &LitKind, e: &Expr) {
6464
match *lit {
65-
LitKind::Float(s, FloatTy::F32) => check_known_consts(cx, e, s, "f32"),
66-
LitKind::Float(s, FloatTy::F64) => check_known_consts(cx, e, s, "f64"),
67-
LitKind::FloatUnsuffixed(s) => check_known_consts(cx, e, s, "f{32, 64}"),
65+
LitKind::Float(s, LitFloatType::Suffixed(fty)) => match fty {
66+
FloatTy::F32 => check_known_consts(cx, e, s, "f32"),
67+
FloatTy::F64 => check_known_consts(cx, e, s, "f64"),
68+
},
69+
LitKind::Float(s, LitFloatType::Unsuffixed) => check_known_consts(cx, e, s, "f{32, 64}"),
6870
_ => (),
6971
}
7072
}

clippy_lints/src/attrs.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc::ty;
1515
use rustc::{declare_lint_pass, declare_tool_lint};
1616
use rustc_errors::Applicability;
1717
use semver::Version;
18-
use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
18+
use syntax::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
1919
use syntax::source_map::Span;
2020
use syntax_pos::symbol::Symbol;
2121

@@ -417,11 +417,14 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
417417
}
418418

419419
for attr in attrs {
420-
if attr.is_sugared_doc {
421-
return;
422-
}
420+
let attr_item = if let AttrKind::Normal(ref attr) = attr.kind {
421+
attr
422+
} else {
423+
continue;
424+
};
425+
423426
if attr.style == AttrStyle::Outer {
424-
if attr.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
427+
if attr_item.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
425428
return;
426429
}
427430

clippy_lints/src/consts.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
161161
LitKind::ByteStr(ref s) => Constant::Binary(Lrc::clone(s)),
162162
LitKind::Char(c) => Constant::Char(c),
163163
LitKind::Int(n, _) => Constant::Int(n),
164-
LitKind::Float(ref is, FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
165-
LitKind::Float(ref is, FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
166-
LitKind::FloatUnsuffixed(ref is) => match ty.expect("type of float is known").kind {
164+
LitKind::Float(ref is, LitFloatType::Suffixed(fty)) => match fty {
165+
FloatTy::F32 => Constant::F32(is.as_str().parse().unwrap()),
166+
FloatTy::F64 => Constant::F64(is.as_str().parse().unwrap()),
167+
},
168+
LitKind::Float(ref is, LitFloatType::Unsuffixed) => match ty.expect("type of float is known").kind {
167169
ty::Float(FloatTy::F32) => Constant::F32(is.as_str().parse().unwrap()),
168170
ty::Float(FloatTy::F64) => Constant::F64(is.as_str().parse().unwrap()),
169171
_ => bug!(),

clippy_lints/src/deprecated_lints.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,12 @@ declare_deprecated_lint! {
130130
pub UNUSED_COLLECT,
131131
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
132132
}
133+
134+
declare_deprecated_lint! {
135+
/// **What it does:** Nothing. This lint has been deprecated.
136+
///
137+
/// **Deprecation reason:** This lint has been uplifted to rustc and is now called
138+
/// `array_into_iter`.
139+
pub INTO_ITER_ON_ARRAY,
140+
"this lint has been uplifted to rustc and is now called `array_into_iter`"
141+
}

clippy_lints/src/doc.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
66
use rustc::{declare_tool_lint, impl_lint_pass};
77
use rustc_data_structures::fx::FxHashSet;
88
use std::ops::Range;
9-
use syntax::ast::Attribute;
9+
use syntax::ast::{AttrKind, Attribute};
1010
use syntax::source_map::{BytePos, Span};
1111
use syntax_pos::Pos;
1212
use url::Url;
@@ -247,13 +247,11 @@ pub fn check_attrs<'a>(cx: &LateContext<'_, '_>, valid_idents: &FxHashSet<String
247247
let mut spans = vec![];
248248

249249
for attr in attrs {
250-
if attr.is_sugared_doc {
251-
if let Some(ref current) = attr.value_str() {
252-
let current = current.to_string();
253-
let (current, current_spans) = strip_doc_comment_decoration(&current, attr.span);
254-
spans.extend_from_slice(&current_spans);
255-
doc.push_str(&current);
256-
}
250+
if let AttrKind::DocComment(ref comment) = attr.kind {
251+
let comment = comment.to_string();
252+
let (comment, current_spans) = strip_doc_comment_decoration(&comment, attr.span);
253+
spans.extend_from_slice(&current_spans);
254+
doc.push_str(&comment);
257255
} else if attr.check_name(sym!(doc)) {
258256
// ignore mix of sugared and non-sugared doc
259257
return true; // don't trigger the safety check

clippy_lints/src/excessive_precision.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExcessivePrecision {
4343
let ty = cx.tables.expr_ty(expr);
4444
if let ty::Float(fty) = ty.kind;
4545
if let hir::ExprKind::Lit(ref lit) = expr.kind;
46-
if let LitKind::Float(sym, _) | LitKind::FloatUnsuffixed(sym) = lit.node;
46+
if let LitKind::Float(sym, _) = lit.node;
4747
if let Some(sugg) = Self::check(sym, fty);
4848
then {
4949
span_lint_and_sugg(

clippy_lints/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
430430
"clippy::unused_collect",
431431
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint",
432432
);
433+
store.register_removed(
434+
"clippy::into_iter_on_array",
435+
"this lint has been uplifted to rustc and is now called `array_into_iter`",
436+
);
433437
// end deprecated lints, do not remove this comment, it’s used in `update_lints`
434438

435439
// begin register lints, do not remove this comment, it’s used in `update_lints`
@@ -584,7 +588,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
584588
&methods::FLAT_MAP_IDENTITY,
585589
&methods::GET_UNWRAP,
586590
&methods::INEFFICIENT_TO_STRING,
587-
&methods::INTO_ITER_ON_ARRAY,
588591
&methods::INTO_ITER_ON_REF,
589592
&methods::ITER_CLONED_COLLECT,
590593
&methods::ITER_NTH,
@@ -1142,7 +1145,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
11421145
LintId::of(&methods::FILTER_NEXT),
11431146
LintId::of(&methods::FLAT_MAP_IDENTITY),
11441147
LintId::of(&methods::INEFFICIENT_TO_STRING),
1145-
LintId::of(&methods::INTO_ITER_ON_ARRAY),
11461148
LintId::of(&methods::INTO_ITER_ON_REF),
11471149
LintId::of(&methods::ITER_CLONED_COLLECT),
11481150
LintId::of(&methods::ITER_NTH),
@@ -1481,7 +1483,6 @@ pub fn register_plugins(store: &mut lint::LintStore, sess: &Session, conf: &Conf
14811483
LintId::of(&mem_discriminant::MEM_DISCRIMINANT_NON_ENUM),
14821484
LintId::of(&mem_replace::MEM_REPLACE_WITH_UNINIT),
14831485
LintId::of(&methods::CLONE_DOUBLE_REF),
1484-
LintId::of(&methods::INTO_ITER_ON_ARRAY),
14851486
LintId::of(&methods::TEMPORARY_CSTRING_AS_PTR),
14861487
LintId::of(&methods::UNINIT_ASSUMED_INIT),
14871488
LintId::of(&minmax::MIN_MAX),

clippy_lints/src/literal_representation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl LiteralDigitGrouping {
373373
}
374374
}
375375
},
376-
LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => {
376+
LitKind::Float(..) => {
377377
// Lint floating-point literals.
378378
if_chain! {
379379
if let Some(src) = snippet_opt(cx, lit.span);

clippy_lints/src/main_recursion.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc::hir::{Crate, Expr, ExprKind, QPath};
22
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
33
use rustc::{declare_tool_lint, impl_lint_pass};
4+
use syntax::ast::AttrKind;
45
use syntax::symbol::sym;
56

67
use crate::utils::{is_entrypoint_fn, snippet, span_help_and_lint};
@@ -34,7 +35,13 @@ impl_lint_pass!(MainRecursion => [MAIN_RECURSION]);
3435

3536
impl LateLintPass<'_, '_> for MainRecursion {
3637
fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) {
37-
self.has_no_std_attr = krate.attrs.iter().any(|attr| attr.path == sym::no_std);
38+
self.has_no_std_attr = krate.attrs.iter().any(|attr| {
39+
if let AttrKind::Normal(ref attr) = attr.kind {
40+
attr.path == sym::no_std
41+
} else {
42+
false
43+
}
44+
});
3845
}
3946

4047
fn check_expr_post(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) {

0 commit comments

Comments
 (0)