Skip to content

Commit c224067

Browse files
committed
Update clippy submodule
1 parent f2be26f commit c224067

21 files changed

+72
-76
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ clippy_lints = { version = "0.0.212", path = "clippy_lints" }
4242
# end automatic update
4343
regex = "1"
4444
semver = "0.9"
45-
rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
45+
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
4646

4747
[dev-dependencies]
4848
cargo_metadata = "0.7.1"
@@ -58,7 +58,7 @@ derive-new = "0.5"
5858
rustc-workspace-hack = "1.0.0"
5959

6060
[build-dependencies]
61-
rustc_tools_util = { version = "0.1.1", path = "rustc_tools_util"}
61+
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util"}
6262

6363
[features]
6464
debugging = []

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ fn main() {
1212
"cargo:rustc-env=COMMIT_DATE={}",
1313
rustc_tools_util::get_commit_date().unwrap_or_default()
1414
);
15+
println!(
16+
"cargo:rustc-env=RUSTC_RELEASE_CHANNEL={}",
17+
rustc_tools_util::get_channel().unwrap_or_default()
18+
);
1519
}

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ toml = "0.5"
2929
unicode-normalization = "0.1"
3030
pulldown-cmark = "0.5.0"
3131
url = "1.7.0"
32-
if_chain = "0.1.3"
32+
if_chain = "1.0.0"
3333
smallvec = { version = "0.6.5", features = ["union"] }
3434

3535
[features]

clippy_lints/src/const_static_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl StaticConst {
4747
if let Some(lifetime) = *optional_lifetime {
4848
match borrow_type.ty.node {
4949
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Array(..) | TyKind::Tup(..) => {
50-
if lifetime.ident.name == syntax::symbol::keywords::StaticLifetime.name() {
50+
if lifetime.ident.name == syntax::symbol::kw::StaticLifetime {
5151
let snip = snippet(cx, borrow_type.ty.span, "<type>");
5252
let sugg = format!("&{}", snip);
5353
span_lint_and_then(

clippy_lints/src/consts.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc::{bug, span_bug};
1111
use rustc_data_structures::sync::Lrc;
1212
use std::cmp::Ordering::{self, Equal};
1313
use std::cmp::PartialOrd;
14-
use std::convert::TryFrom;
1514
use std::convert::TryInto;
1615
use std::hash::{Hash, Hasher};
1716
use syntax::ast::{FloatTy, LitKind};
@@ -251,7 +250,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
251250
if let ExprKind::Path(qpath) = &callee.node;
252251
let res = self.tables.qpath_res(qpath, callee.hir_id);
253252
if let Some(def_id) = res.opt_def_id();
254-
let def_path = self.lcx.get_def_path(def_id)
253+
let get_def_path = self.lcx.get_def_path(def_id);
254+
let def_path = get_def_path
255255
.iter()
256256
.map(LocalInternedString::get)
257257
.collect::<Vec<_>>();
@@ -340,7 +340,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
340340
};
341341

342342
let result = self.lcx.tcx.const_eval(self.param_env.and(gid)).ok()?;
343-
let result = miri_to_const(self.lcx.tcx, &result);
343+
let result = miri_to_const(&result);
344344
if result.is_some() {
345345
self.needed_resolution = true;
346346
}
@@ -465,7 +465,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
465465
}
466466
}
467467

468-
pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'tcx>) -> Option<Constant> {
468+
pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
469469
use rustc::mir::interpret::{ConstValue, Scalar};
470470
match result.val {
471471
ConstValue::Scalar(Scalar::Bits { bits: b, .. }) => match result.ty.sty {
@@ -486,16 +486,11 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
486486
// FIXME: implement other conversions.
487487
_ => None,
488488
},
489-
ConstValue::Slice(Scalar::Ptr(ptr), n) => match result.ty.sty {
489+
ConstValue::Slice { data, start, end } => match result.ty.sty {
490490
ty::Ref(_, tam, _) => match tam.sty {
491-
ty::Str => {
492-
let alloc = tcx.alloc_map.lock().unwrap_memory(ptr.alloc_id);
493-
let offset = ptr.offset.bytes().try_into().expect("too-large pointer offset");
494-
let n = usize::try_from(n).unwrap();
495-
String::from_utf8(alloc.bytes[offset..(offset + n)].to_owned())
496-
.ok()
497-
.map(Constant::Str)
498-
},
491+
ty::Str => String::from_utf8(data.bytes[start..end].to_owned())
492+
.ok()
493+
.map(Constant::Str),
499494
_ => None,
500495
},
501496
_ => None,

clippy_lints/src/enum_clike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
5656
promoted: None,
5757
};
5858
let constant = cx.tcx.const_eval(param_env.and(c_id)).ok();
59-
if let Some(Constant::Int(val)) = constant.and_then(|c| miri_to_const(cx.tcx, &c)) {
59+
if let Some(Constant::Int(val)) = constant.and_then(miri_to_const) {
6060
let mut ty = cx.tcx.type_of(def_id);
6161
if let ty::Adt(adt, _) = ty.sty {
6262
if adt.is_enum() {

clippy_lints/src/lifetimes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintC
66
use rustc::{declare_lint_pass, declare_tool_lint};
77
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
88
use syntax::source_map::Span;
9-
use syntax::symbol::keywords;
9+
use syntax::symbol::kw;
1010

1111
use crate::reexport::*;
1212
use crate::utils::{last_path_segment, span_lint};
@@ -476,9 +476,7 @@ struct BodyLifetimeChecker {
476476
impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
477477
// for lifetimes as parameters of generics
478478
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
479-
if lifetime.name.ident().name != keywords::Invalid.name()
480-
&& lifetime.name.ident().name != syntax::symbol::keywords::StaticLifetime.name()
481-
{
479+
if lifetime.name.ident().name != kw::Invalid && lifetime.name.ident().name != kw::StaticLifetime {
482480
self.lifetimes_used_in_body = true;
483481
}
484482
}

clippy_lints/src/use_self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::ty;
88
use rustc::ty::{DefIdTree, Ty};
99
use rustc::{declare_lint_pass, declare_tool_lint};
1010
use rustc_errors::Applicability;
11-
use syntax_pos::symbol::keywords::SelfUpper;
11+
use syntax_pos::symbol::kw;
1212

1313
use crate::utils::span_lint_and_sugg;
1414

@@ -220,7 +220,7 @@ struct UseSelfVisitor<'a, 'tcx: 'a> {
220220

221221
impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
222222
fn visit_path(&mut self, path: &'tcx Path, _id: HirId) {
223-
if path.segments.last().expect(SEGMENTS_MSG).ident.name != SelfUpper.name() {
223+
if path.segments.last().expect(SEGMENTS_MSG).ident.name != kw::SelfUpper {
224224
if self.item_path.res == path.res {
225225
span_use_self_lint(self.cx, path);
226226
} else if let Res::Def(DefKind::Ctor(def::CtorOf::Struct, CtorKind::Fn), ctor_did) = path.res {

clippy_lints/src/utils/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ use rustc::ty::{
3939
subst::Kind,
4040
Binder, Ty, TyCtxt,
4141
};
42-
use rustc_data_structures::sync::Lrc;
4342
use rustc_errors::Applicability;
43+
use smallvec::SmallVec;
4444
use syntax::ast::{self, LitKind};
4545
use syntax::attr;
4646
use syntax::ext::hygiene::ExpnFormat;
4747
use syntax::source_map::{Span, DUMMY_SP};
48-
use syntax::symbol::{keywords, Symbol};
48+
use syntax::symbol::{kw, Symbol};
4949

5050
use crate::reexport::*;
5151

@@ -248,7 +248,8 @@ pub fn path_to_res(cx: &LateContext<'_, '_>, path: &[&str]) -> Option<(def::Res)
248248
None => return None,
249249
};
250250

251-
for item in mem::replace(&mut items, Lrc::new(vec![])).iter() {
251+
let result = SmallVec::<[_; 8]>::new();
252+
for item in mem::replace(&mut items, cx.tcx.arena.alloc_slice(&result)).iter() {
252253
if item.ident.name.as_str() == *segment {
253254
if path_it.peek().is_none() {
254255
return Some(item.res);
@@ -839,7 +840,7 @@ pub fn remove_blocks(expr: &Expr) -> &Expr {
839840

840841
pub fn is_self(slf: &Arg) -> bool {
841842
if let PatKind::Binding(.., name, _) = slf.pat.node {
842-
name.name == keywords::SelfLower.name()
843+
name.name == kw::SelfLower
843844
} else {
844845
false
845846
}

clippy_lints/src/utils/sugg.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ impl<'a> Sugg<'a> {
136136
| ast::ExprKind::Closure(..)
137137
| ast::ExprKind::If(..)
138138
| ast::ExprKind::IfLet(..)
139-
| ast::ExprKind::ObsoleteInPlace(..)
140139
| ast::ExprKind::Unary(..)
141140
| ast::ExprKind::Match(..) => Sugg::MaybeParen(snippet),
142141
ast::ExprKind::Async(..)
@@ -385,7 +384,6 @@ pub fn make_assoc(op: AssocOp, lhs: &Sugg<'_>, rhs: &Sugg<'_>) -> Sugg<'static>
385384
rhs
386385
),
387386
AssocOp::Assign => format!("{} = {}", lhs, rhs),
388-
AssocOp::ObsoleteInPlace => format!("in ({}) {}", lhs, rhs),
389387
AssocOp::AssignOp(op) => format!("{} {}= {}", lhs, token_to_string(&token::BinOp(op)), rhs),
390388
AssocOp::As => format!("{} as {}", lhs, rhs),
391389
AssocOp::DotDot => format!("{}..{}", lhs, rhs),
@@ -425,7 +423,7 @@ fn associativity(op: &AssocOp) -> Associativity {
425423
use syntax::util::parser::AssocOp::*;
426424

427425
match *op {
428-
ObsoleteInPlace | Assign | AssignOp(_) => Associativity::Right,
426+
Assign | AssignOp(_) => Associativity::Right,
429427
Add | BitAnd | BitOr | BitXor | LAnd | LOr | Multiply | As | Colon => Associativity::Both,
430428
Divide | Equal | Greater | GreaterEqual | Less | LessEqual | Modulus | NotEqual | ShiftLeft | ShiftRight
431429
| Subtract => Associativity::Left,

0 commit comments

Comments
 (0)