Skip to content

Commit 0f5be36

Browse files
authored
Merge pull request #2743 from phansch/rustup20180510
Rustup to 2018-05-11
2 parents be3cba8 + 6baca22 commit 0f5be36

15 files changed

+57
-56
lines changed

CHANGELOG.md

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

4+
## 0.0.198
5+
* Rustup to *rustc 1.27.0-nightly (acd3871ba 2018-05-10)*
6+
47
## 0.0.197
58
* Rustup to *rustc 1.27.0-nightly (428ea5f6b 2018-05-06)*
69

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.0.197"
3+
version = "0.0.198"
44
authors = [
55
"Manish Goregaokar <[email protected]>",
66
"Andre Bogus <[email protected]>",
@@ -37,7 +37,7 @@ path = "src/driver.rs"
3737

3838
[dependencies]
3939
# begin automatic update
40-
clippy_lints = { version = "0.0.197", path = "clippy_lints" }
40+
clippy_lints = { version = "0.0.198", path = "clippy_lints" }
4141
# end automatic update
4242
regex = "0.2"
4343
semver = "0.9"

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "clippy_lints"
33
# begin automatic update
4-
version = "0.0.197"
4+
version = "0.0.198"
55
# end automatic update
66
authors = [
77
"Manish Goregaokar <[email protected]>",

clippy_lints/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
426426
_ => None,
427427
},
428428
ConstVal::Value(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n))) => match result.ty.sty {
429-
ty::TyRef(_, tam) => match tam.ty.sty {
429+
ty::TyRef(_, tam, _) => match tam.sty {
430430
ty::TyStr => {
431431
let alloc = tcx
432432
.interpret_interner

clippy_lints/src/loops.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ struct FixedOffsetVar {
743743

744744
fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty) -> bool {
745745
let is_slice = match ty.sty {
746-
ty::TyRef(_, ref subty) => is_slice_like(cx, subty.ty),
746+
ty::TyRef(_, subty, _) => is_slice_like(cx, subty),
747747
ty::TySlice(..) | ty::TyArray(..) => true,
748748
_ => false,
749749
};
@@ -1365,9 +1365,9 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
13651365
if pat.len() == 2 {
13661366
let arg_span = arg.span;
13671367
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
1368-
ty::TyRef(_, ref tam) => match (&pat[0].node, &pat[1].node) {
1369-
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", tam.ty, tam.mutbl),
1370-
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", tam.ty, MutImmutable),
1368+
ty::TyRef(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
1369+
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
1370+
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, MutImmutable),
13711371
_ => return,
13721372
},
13731373
_ => return,
@@ -1705,8 +1705,8 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
17051705
for expr in args {
17061706
let ty = self.cx.tables.expr_ty_adjusted(expr);
17071707
self.prefer_mutable = false;
1708-
if let ty::TyRef(_, mutbl) = ty.sty {
1709-
if mutbl.mutbl == MutMutable {
1708+
if let ty::TyRef(_, _, mutbl) = ty.sty {
1709+
if mutbl == MutMutable {
17101710
self.prefer_mutable = true;
17111711
}
17121712
}
@@ -1717,8 +1717,8 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
17171717
let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id();
17181718
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
17191719
self.prefer_mutable = false;
1720-
if let ty::TyRef(_, mutbl) = ty.sty {
1721-
if mutbl.mutbl == MutMutable {
1720+
if let ty::TyRef(_, _, mutbl) = ty.sty {
1721+
if mutbl == MutMutable {
17221722
self.prefer_mutable = true;
17231723
}
17241724
}

clippy_lints/src/map_clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
5151
walk_ptrs_ty_depth(cx.tables.pat_ty(&first_arg.pat)).1 == 1
5252
{
5353
// the argument is not an &mut T
54-
if let ty::TyRef(_, tam) = ty.sty {
55-
if tam.mutbl == MutImmutable {
54+
if let ty::TyRef(_, _, mutbl) = ty.sty {
55+
if mutbl == MutImmutable {
5656
span_help_and_lint(cx, MAP_CLONE, expr.span, &format!(
5757
"you seem to be using .map() to clone the contents of an {}, consider \
5858
using `.cloned()`", type_name),

clippy_lints/src/methods.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
749749
}
750750

751751
match self_ty.sty {
752-
ty::TyRef(_, ty) if ty.ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS {
752+
ty::TyRef(_, ty, _) if ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS {
753753
if method_call.name == method && args.len() > pos {
754754
lint_single_char_pattern(cx, expr, &args[pos]);
755755
}
@@ -967,8 +967,8 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, method_span: Span, name:
967967
/// Checks for the `CLONE_ON_COPY` lint.
968968
fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_ty: Ty) {
969969
let ty = cx.tables.expr_ty(expr);
970-
if let ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) = arg_ty.sty {
971-
if let ty::TyRef(_, ty::TypeAndMut { ty: innermost, .. }) = inner.sty {
970+
if let ty::TyRef(_, inner, _) = arg_ty.sty {
971+
if let ty::TyRef(_, innermost, _) = inner.sty {
972972
span_lint_and_then(
973973
cx,
974974
CLONE_DOUBLE_REF,
@@ -978,7 +978,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t
978978
|db| if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) {
979979
let mut ty = innermost;
980980
let mut n = 0;
981-
while let ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) = ty.sty {
981+
while let ty::TyRef(_, inner, _) = ty.sty {
982982
ty = inner;
983983
n += 1;
984984
}
@@ -1300,7 +1300,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option<sugg::S
13001300
ty::TyAdt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
13011301
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
13021302
ty::TyArray(_, size) => size.val.to_raw_bits().expect("array length") < 32,
1303-
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => may_slice(cx, inner),
1303+
ty::TyRef(_, inner, _) => may_slice(cx, inner),
13041304
_ => false,
13051305
}
13061306
}
@@ -1315,7 +1315,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option<sugg::S
13151315
match ty.sty {
13161316
ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr),
13171317
ty::TyAdt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => sugg::Sugg::hir_opt(cx, expr),
1318-
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => if may_slice(cx, inner) {
1318+
ty::TyRef(_, inner, _) => if may_slice(cx, inner) {
13191319
sugg::Sugg::hir_opt(cx, expr)
13201320
} else {
13211321
None

clippy_lints/src/mut_mut.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
7272
);
7373
} else if let ty::TyRef(
7474
_,
75-
ty::TypeAndMut {
76-
mutbl: hir::MutMutable,
77-
..
78-
},
75+
_,
76+
hir::MutMutable,
7977
) = self.cx.tables.expr_ty(e).sty
8078
{
8179
span_lint(

clippy_lints/src/mut_reference.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,8 @@ fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], typ
6363
match parameter.sty {
6464
ty::TyRef(
6565
_,
66-
ty::TypeAndMut {
67-
mutbl: MutImmutable,
68-
..
69-
},
66+
_,
67+
MutImmutable,
7068
) |
7169
ty::TyRawPtr(ty::TypeAndMut {
7270
mutbl: MutImmutable,

clippy_lints/src/needless_borrow.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
7777
}
7878
if_chain! {
7979
if let PatKind::Binding(BindingAnnotation::Ref, _, name, _) = pat.node;
80-
if let ty::TyRef(_, ref tam) = cx.tables.pat_ty(pat).sty;
81-
if tam.mutbl == MutImmutable;
82-
if let ty::TyRef(_, ref tam) = tam.ty.sty;
80+
if let ty::TyRef(_, tam, mutbl) = cx.tables.pat_ty(pat).sty;
81+
if mutbl == MutImmutable;
82+
if let ty::TyRef(_, _, mutbl) = tam.sty;
8383
// only lint immutable refs, because borrowed `&mut T` cannot be moved out
84-
if tam.mutbl == MutImmutable;
84+
if mutbl == MutImmutable;
8585
then {
8686
span_lint_and_then(
8787
cx,

clippy_lints/src/ptr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
152152
for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() {
153153
if let ty::TyRef(
154154
_,
155-
ty::TypeAndMut {
156-
ty,
157-
mutbl: MutImmutable,
158-
},
155+
ty,
156+
MutImmutable
159157
) = ty.sty
160158
{
161159
if match_type(cx, ty, &paths::VEC) {

clippy_lints/src/transmute.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,16 +229,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
229229
e.span,
230230
&format!("transmute from a type (`{}`) to itself", from_ty),
231231
),
232-
(&ty::TyRef(_, rty), &ty::TyRawPtr(ptr_ty)) => span_lint_and_then(
232+
(&ty::TyRef(_, rty, rty_mutbl), &ty::TyRawPtr(ptr_ty)) => span_lint_and_then(
233233
cx,
234234
USELESS_TRANSMUTE,
235235
e.span,
236236
"transmute from a reference to a pointer",
237237
|db| if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) {
238-
let sugg = if ptr_ty == rty {
238+
let rty_and_mut = ty::TypeAndMut { ty: rty, mutbl: rty_mutbl };
239+
240+
let sugg = if ptr_ty == rty_and_mut {
239241
arg.as_ty(to_ty)
240242
} else {
241-
arg.as_ty(cx.tcx.mk_ptr(rty)).as_ty(to_ty)
243+
arg.as_ty(cx.tcx.mk_ptr(rty_and_mut)).as_ty(to_ty)
242244
};
243245

244246
db.span_suggestion(e.span, "try", sugg.to_string());
@@ -284,7 +286,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
284286
to_ty
285287
),
286288
),
287-
(&ty::TyRawPtr(from_pty), &ty::TyRef(_, to_ref_ty)) => span_lint_and_then(
289+
(&ty::TyRawPtr(from_pty), &ty::TyRef(_, to_ref_ty, mutbl)) => span_lint_and_then(
288290
cx,
289291
TRANSMUTE_PTR_TO_REF,
290292
e.span,
@@ -296,16 +298,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
296298
),
297299
|db| {
298300
let arg = sugg::Sugg::hir(cx, &args[0], "..");
299-
let (deref, cast) = if to_ref_ty.mutbl == Mutability::MutMutable {
301+
let (deref, cast) = if mutbl == Mutability::MutMutable {
300302
("&mut *", "*mut")
301303
} else {
302304
("&*", "*const")
303305
};
304306

305-
let arg = if from_pty.ty == to_ref_ty.ty {
307+
let arg = if from_pty.ty == to_ref_ty {
306308
arg
307309
} else {
308-
arg.as_ty(&format!("{} {}", cast, get_type_snippet(cx, qpath, to_ref_ty.ty)))
310+
arg.as_ty(&format!("{} {}", cast, get_type_snippet(cx, qpath, to_ref_ty)))
309311
};
310312

311313
db.span_suggestion(e.span, "try", sugg::make_unop(deref, arg).to_string());
@@ -331,13 +333,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
331333
);
332334
},
333335
),
334-
(&ty::TyRef(_, ref ref_from), &ty::TyRef(_, ref ref_to)) => {
336+
(&ty::TyRef(_, ty_from, from_mutbl), &ty::TyRef(_, ty_to, to_mutbl)) => {
335337
if_chain! {
336-
if let (&ty::TySlice(slice_ty), &ty::TyStr) = (&ref_from.ty.sty, &ref_to.ty.sty);
338+
if let (&ty::TySlice(slice_ty), &ty::TyStr) = (&ty_from.sty, &ty_to.sty);
337339
if let ty::TyUint(ast::UintTy::U8) = slice_ty.sty;
338-
if ref_from.mutbl == ref_to.mutbl;
340+
if from_mutbl == to_mutbl;
339341
then {
340-
let postfix = if ref_from.mutbl == Mutability::MutMutable {
342+
let postfix = if from_mutbl == Mutability::MutMutable {
341343
"_mut"
342344
} else {
343345
""
@@ -367,8 +369,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
367369
e.span,
368370
"transmute from a reference to a reference",
369371
|db| if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) {
370-
let sugg_paren = arg.as_ty(cx.tcx.mk_ptr(*ref_from)).as_ty(cx.tcx.mk_ptr(*ref_to));
371-
let sugg = if ref_to.mutbl == Mutability::MutMutable {
372+
let ty_from_and_mut = ty::TypeAndMut { ty: ty_from, mutbl: from_mutbl };
373+
let ty_to_and_mut = ty::TypeAndMut { ty: ty_to, mutbl: to_mutbl };
374+
let sugg_paren = arg.as_ty(cx.tcx.mk_ptr(ty_from_and_mut)).as_ty(cx.tcx.mk_ptr(ty_to_and_mut));
375+
let sugg = if to_mutbl == Mutability::MutMutable {
372376
sugg_paren.mut_addr_deref()
373377
} else {
374378
sugg_paren.addr_deref()

clippy_lints/src/utils/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty {
674674
/// Return the base type for references and raw pointers.
675675
pub fn walk_ptrs_ty(ty: Ty) -> Ty {
676676
match ty.sty {
677-
ty::TyRef(_, ref tm) => walk_ptrs_ty(tm.ty),
677+
ty::TyRef(_, ty, _) => walk_ptrs_ty(ty),
678678
_ => ty,
679679
}
680680
}
@@ -684,7 +684,7 @@ pub fn walk_ptrs_ty(ty: Ty) -> Ty {
684684
pub fn walk_ptrs_ty_depth(ty: Ty) -> (Ty, usize) {
685685
fn inner(ty: Ty, depth: usize) -> (Ty, usize) {
686686
match ty.sty {
687-
ty::TyRef(_, ref tm) => inner(tm.ty, depth + 1),
687+
ty::TyRef(_, ty, _) => inner(ty, depth + 1),
688688
_ => (ty, depth),
689689
}
690690
}

clippy_lints/src/vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
3535
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
3636
// search for `&vec![_]` expressions where the adjusted type is `&[_]`
3737
if_chain! {
38-
if let ty::TyRef(_, ref ty) = cx.tables.expr_ty_adjusted(expr).sty;
39-
if let ty::TySlice(..) = ty.ty.sty;
38+
if let ty::TyRef(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty;
39+
if let ty::TySlice(..) = ty.sty;
4040
if let ExprAddrOf(_, ref addressee) = expr.node;
4141
if let Some(vec_args) = higher::vec_macro(cx, addressee);
4242
then {

min_version.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
rustc 1.27.0-nightly (e82261dfb 2018-05-03)
1+
rustc 1.27.0-nightly (acd3871ba 2018-05-10)
22
binary: rustc
3-
commit-hash: e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b
4-
commit-date: 2018-05-03
3+
commit-hash: acd3871ba17316419c644e17547887787628ec2f
4+
commit-date: 2018-05-10
55
host: x86_64-unknown-linux-gnu
66
release: 1.27.0-nightly
77
LLVM version: 6.0

0 commit comments

Comments
 (0)