Skip to content

Rustup to 2018-05-11 #2743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.0.198
* Rustup to *rustc 1.27.0-nightly (acd3871ba 2018-05-10)*

## 0.0.197
* Rustup to *rustc 1.27.0-nightly (428ea5f6b 2018-05-06)*

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.197"
version = "0.0.198"
authors = [
"Manish Goregaokar <[email protected]>",
"Andre Bogus <[email protected]>",
Expand Down Expand Up @@ -37,7 +37,7 @@ path = "src/driver.rs"

[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.197", path = "clippy_lints" }
clippy_lints = { version = "0.0.198", path = "clippy_lints" }
# end automatic update
regex = "0.2"
semver = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.197"
version = "0.0.198"
# end automatic update
authors = [
"Manish Goregaokar <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
_ => None,
},
ConstVal::Value(Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n))) => match result.ty.sty {
ty::TyRef(_, tam) => match tam.ty.sty {
ty::TyRef(_, tam, _) => match tam.sty {
ty::TyStr => {
let alloc = tcx
.interpret_interner
Expand Down
16 changes: 8 additions & 8 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ struct FixedOffsetVar {

fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty) -> bool {
let is_slice = match ty.sty {
ty::TyRef(_, ref subty) => is_slice_like(cx, subty.ty),
ty::TyRef(_, subty, _) => is_slice_like(cx, subty),
ty::TySlice(..) | ty::TyArray(..) => true,
_ => false,
};
Expand Down Expand Up @@ -1365,9 +1365,9 @@ fn check_for_loop_over_map_kv<'a, 'tcx>(
if pat.len() == 2 {
let arg_span = arg.span;
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
ty::TyRef(_, ref tam) => match (&pat[0].node, &pat[1].node) {
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", tam.ty, tam.mutbl),
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", tam.ty, MutImmutable),
ty::TyRef(_, ty, mutbl) => match (&pat[0].node, &pat[1].node) {
(key, _) if pat_is_wild(key, body) => (pat[1].span, "value", ty, mutbl),
(_, value) if pat_is_wild(value, body) => (pat[0].span, "key", ty, MutImmutable),
_ => return,
},
_ => return,
Expand Down Expand Up @@ -1705,8 +1705,8 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
for expr in args {
let ty = self.cx.tables.expr_ty_adjusted(expr);
self.prefer_mutable = false;
if let ty::TyRef(_, mutbl) = ty.sty {
if mutbl.mutbl == MutMutable {
if let ty::TyRef(_, _, mutbl) = ty.sty {
if mutbl == MutMutable {
self.prefer_mutable = true;
}
}
Expand All @@ -1717,8 +1717,8 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id();
for (ty, expr) in self.cx.tcx.fn_sig(def_id).inputs().skip_binder().iter().zip(args) {
self.prefer_mutable = false;
if let ty::TyRef(_, mutbl) = ty.sty {
if mutbl.mutbl == MutMutable {
if let ty::TyRef(_, _, mutbl) = ty.sty {
if mutbl == MutMutable {
self.prefer_mutable = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
walk_ptrs_ty_depth(cx.tables.pat_ty(&first_arg.pat)).1 == 1
{
// the argument is not an &mut T
if let ty::TyRef(_, tam) = ty.sty {
if tam.mutbl == MutImmutable {
if let ty::TyRef(_, _, mutbl) = ty.sty {
if mutbl == MutImmutable {
span_help_and_lint(cx, MAP_CLONE, expr.span, &format!(
"you seem to be using .map() to clone the contents of an {}, consider \
using `.cloned()`", type_name),
Expand Down
12 changes: 6 additions & 6 deletions clippy_lints/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
}

match self_ty.sty {
ty::TyRef(_, ty) if ty.ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS {
ty::TyRef(_, ty, _) if ty.sty == ty::TyStr => for &(method, pos) in &PATTERN_METHODS {
if method_call.name == method && args.len() > pos {
lint_single_char_pattern(cx, expr, &args[pos]);
}
Expand Down Expand Up @@ -967,8 +967,8 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, method_span: Span, name:
/// Checks for the `CLONE_ON_COPY` lint.
fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_ty: Ty) {
let ty = cx.tables.expr_ty(expr);
if let ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) = arg_ty.sty {
if let ty::TyRef(_, ty::TypeAndMut { ty: innermost, .. }) = inner.sty {
if let ty::TyRef(_, inner, _) = arg_ty.sty {
if let ty::TyRef(_, innermost, _) = inner.sty {
span_lint_and_then(
cx,
CLONE_DOUBLE_REF,
Expand All @@ -978,7 +978,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t
|db| if let Some(snip) = sugg::Sugg::hir_opt(cx, arg) {
let mut ty = innermost;
let mut n = 0;
while let ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) = ty.sty {
while let ty::TyRef(_, inner, _) = ty.sty {
ty = inner;
n += 1;
}
Expand Down Expand Up @@ -1300,7 +1300,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option<sugg::S
ty::TyAdt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
ty::TyAdt(..) => match_type(cx, ty, &paths::VEC),
ty::TyArray(_, size) => size.val.to_raw_bits().expect("array length") < 32,
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => may_slice(cx, inner),
ty::TyRef(_, inner, _) => may_slice(cx, inner),
_ => false,
}
}
Expand All @@ -1315,7 +1315,7 @@ fn derefs_to_slice(cx: &LateContext, expr: &hir::Expr, ty: Ty) -> Option<sugg::S
match ty.sty {
ty::TySlice(_) => sugg::Sugg::hir_opt(cx, expr),
ty::TyAdt(def, _) if def.is_box() && may_slice(cx, ty.boxed_ty()) => sugg::Sugg::hir_opt(cx, expr),
ty::TyRef(_, ty::TypeAndMut { ty: inner, .. }) => if may_slice(cx, inner) {
ty::TyRef(_, inner, _) => if may_slice(cx, inner) {
sugg::Sugg::hir_opt(cx, expr)
} else {
None
Expand Down
6 changes: 2 additions & 4 deletions clippy_lints/src/mut_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
);
} else if let ty::TyRef(
_,
ty::TypeAndMut {
mutbl: hir::MutMutable,
..
},
_,
hir::MutMutable,
) = self.cx.tables.expr_ty(e).sty
{
span_lint(
Expand Down
6 changes: 2 additions & 4 deletions clippy_lints/src/mut_reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ fn check_arguments<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, arguments: &[Expr], typ
match parameter.sty {
ty::TyRef(
_,
ty::TypeAndMut {
mutbl: MutImmutable,
..
},
_,
MutImmutable,
) |
ty::TyRawPtr(ty::TypeAndMut {
mutbl: MutImmutable,
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/needless_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
}
if_chain! {
if let PatKind::Binding(BindingAnnotation::Ref, _, name, _) = pat.node;
if let ty::TyRef(_, ref tam) = cx.tables.pat_ty(pat).sty;
if tam.mutbl == MutImmutable;
if let ty::TyRef(_, ref tam) = tam.ty.sty;
if let ty::TyRef(_, tam, mutbl) = cx.tables.pat_ty(pat).sty;
if mutbl == MutImmutable;
if let ty::TyRef(_, _, mutbl) = tam.sty;
// only lint immutable refs, because borrowed `&mut T` cannot be moved out
if tam.mutbl == MutImmutable;
if mutbl == MutImmutable;
then {
span_lint_and_then(
cx,
Expand Down
6 changes: 2 additions & 4 deletions clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ fn check_fn(cx: &LateContext, decl: &FnDecl, fn_id: NodeId, opt_body_id: Option<
for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() {
if let ty::TyRef(
_,
ty::TypeAndMut {
ty,
mutbl: MutImmutable,
},
ty,
MutImmutable
) = ty.sty
{
if match_type(cx, ty, &paths::VEC) {
Expand Down
30 changes: 17 additions & 13 deletions clippy_lints/src/transmute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
e.span,
&format!("transmute from a type (`{}`) to itself", from_ty),
),
(&ty::TyRef(_, rty), &ty::TyRawPtr(ptr_ty)) => span_lint_and_then(
(&ty::TyRef(_, rty, rty_mutbl), &ty::TyRawPtr(ptr_ty)) => span_lint_and_then(
cx,
USELESS_TRANSMUTE,
e.span,
"transmute from a reference to a pointer",
|db| if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) {
let sugg = if ptr_ty == rty {
let rty_and_mut = ty::TypeAndMut { ty: rty, mutbl: rty_mutbl };

let sugg = if ptr_ty == rty_and_mut {
arg.as_ty(to_ty)
} else {
arg.as_ty(cx.tcx.mk_ptr(rty)).as_ty(to_ty)
arg.as_ty(cx.tcx.mk_ptr(rty_and_mut)).as_ty(to_ty)
};

db.span_suggestion(e.span, "try", sugg.to_string());
Expand Down Expand Up @@ -284,7 +286,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
to_ty
),
),
(&ty::TyRawPtr(from_pty), &ty::TyRef(_, to_ref_ty)) => span_lint_and_then(
(&ty::TyRawPtr(from_pty), &ty::TyRef(_, to_ref_ty, mutbl)) => span_lint_and_then(
cx,
TRANSMUTE_PTR_TO_REF,
e.span,
Expand All @@ -296,16 +298,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
),
|db| {
let arg = sugg::Sugg::hir(cx, &args[0], "..");
let (deref, cast) = if to_ref_ty.mutbl == Mutability::MutMutable {
let (deref, cast) = if mutbl == Mutability::MutMutable {
("&mut *", "*mut")
} else {
("&*", "*const")
};

let arg = if from_pty.ty == to_ref_ty.ty {
let arg = if from_pty.ty == to_ref_ty {
arg
} else {
arg.as_ty(&format!("{} {}", cast, get_type_snippet(cx, qpath, to_ref_ty.ty)))
arg.as_ty(&format!("{} {}", cast, get_type_snippet(cx, qpath, to_ref_ty)))
};

db.span_suggestion(e.span, "try", sugg::make_unop(deref, arg).to_string());
Expand All @@ -331,13 +333,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
);
},
),
(&ty::TyRef(_, ref ref_from), &ty::TyRef(_, ref ref_to)) => {
(&ty::TyRef(_, ty_from, from_mutbl), &ty::TyRef(_, ty_to, to_mutbl)) => {
if_chain! {
if let (&ty::TySlice(slice_ty), &ty::TyStr) = (&ref_from.ty.sty, &ref_to.ty.sty);
if let (&ty::TySlice(slice_ty), &ty::TyStr) = (&ty_from.sty, &ty_to.sty);
if let ty::TyUint(ast::UintTy::U8) = slice_ty.sty;
if ref_from.mutbl == ref_to.mutbl;
if from_mutbl == to_mutbl;
then {
let postfix = if ref_from.mutbl == Mutability::MutMutable {
let postfix = if from_mutbl == Mutability::MutMutable {
"_mut"
} else {
""
Expand Down Expand Up @@ -367,8 +369,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
e.span,
"transmute from a reference to a reference",
|db| if let Some(arg) = sugg::Sugg::hir_opt(cx, &args[0]) {
let sugg_paren = arg.as_ty(cx.tcx.mk_ptr(*ref_from)).as_ty(cx.tcx.mk_ptr(*ref_to));
let sugg = if ref_to.mutbl == Mutability::MutMutable {
let ty_from_and_mut = ty::TypeAndMut { ty: ty_from, mutbl: from_mutbl };
let ty_to_and_mut = ty::TypeAndMut { ty: ty_to, mutbl: to_mutbl };
let sugg_paren = arg.as_ty(cx.tcx.mk_ptr(ty_from_and_mut)).as_ty(cx.tcx.mk_ptr(ty_to_and_mut));
let sugg = if to_mutbl == Mutability::MutMutable {
sugg_paren.mut_addr_deref()
} else {
sugg_paren.addr_deref()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ pub fn walk_ptrs_hir_ty(ty: &hir::Ty) -> &hir::Ty {
/// Return the base type for references and raw pointers.
pub fn walk_ptrs_ty(ty: Ty) -> Ty {
match ty.sty {
ty::TyRef(_, ref tm) => walk_ptrs_ty(tm.ty),
ty::TyRef(_, ty, _) => walk_ptrs_ty(ty),
_ => ty,
}
}
Expand All @@ -684,7 +684,7 @@ pub fn walk_ptrs_ty(ty: Ty) -> Ty {
pub fn walk_ptrs_ty_depth(ty: Ty) -> (Ty, usize) {
fn inner(ty: Ty, depth: usize) -> (Ty, usize) {
match ty.sty {
ty::TyRef(_, ref tm) => inner(tm.ty, depth + 1),
ty::TyRef(_, ty, _) => inner(ty, depth + 1),
_ => (ty, depth),
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
// search for `&vec![_]` expressions where the adjusted type is `&[_]`
if_chain! {
if let ty::TyRef(_, ref ty) = cx.tables.expr_ty_adjusted(expr).sty;
if let ty::TySlice(..) = ty.ty.sty;
if let ty::TyRef(_, ty, _) = cx.tables.expr_ty_adjusted(expr).sty;
if let ty::TySlice(..) = ty.sty;
if let ExprAddrOf(_, ref addressee) = expr.node;
if let Some(vec_args) = higher::vec_macro(cx, addressee);
then {
Expand Down
6 changes: 3 additions & 3 deletions min_version.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
rustc 1.27.0-nightly (e82261dfb 2018-05-03)
rustc 1.27.0-nightly (acd3871ba 2018-05-10)
binary: rustc
commit-hash: e82261dfbb5feaa2d28d2b138f4aabb2aa52c94b
commit-date: 2018-05-03
commit-hash: acd3871ba17316419c644e17547887787628ec2f
commit-date: 2018-05-10
host: x86_64-unknown-linux-gnu
release: 1.27.0-nightly
LLVM version: 6.0