Rerun rustfmt
This commit is contained in:
parent
2f941131bf
commit
ab42f02003
@ -262,7 +262,9 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
||||
ExprTup(ref tup) => self.multi(tup).map(Constant::Tuple),
|
||||
ExprRepeat(ref value, number_id) => {
|
||||
if let Some(lcx) = self.lcx {
|
||||
self.binop_apply(value, &lcx.tcx.map.body(number_id).value, |v, n| Some(Constant::Repeat(Box::new(v), n.as_u64() as usize)))
|
||||
self.binop_apply(value,
|
||||
&lcx.tcx.map.body(number_id).value,
|
||||
|v, n| Some(Constant::Repeat(Box::new(v), n.as_u64() as usize)))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -44,7 +44,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
|
||||
let variant = &var.node;
|
||||
if let Some(body_id) = variant.disr_expr {
|
||||
use rustc_const_eval::*;
|
||||
let bad = match eval_const_expr_partial(cx.tcx, &cx.tcx.map.body(body_id).value, EvalHint::ExprTypeChecked, None) {
|
||||
let bad = match eval_const_expr_partial(cx.tcx,
|
||||
&cx.tcx.map.body(body_id).value,
|
||||
EvalHint::ExprTypeChecked,
|
||||
None) {
|
||||
Ok(ConstVal::Integral(Usize(Us64(i)))) => i as u32 as u64 != i,
|
||||
Ok(ConstVal::Integral(Isize(Is64(i)))) => i as i32 as i64 != i,
|
||||
_ => false,
|
||||
|
@ -141,9 +141,10 @@ impl<'a, 'tcx> Functions {
|
||||
) {
|
||||
let expr = &body.value;
|
||||
if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(nodeid) {
|
||||
let raw_ptrs = iter_input_pats(decl, body).zip(decl.inputs.iter())
|
||||
.filter_map(|(arg, ty)| raw_ptr_arg(arg, ty))
|
||||
.collect::<HashSet<_>>();
|
||||
let raw_ptrs = iter_input_pats(decl, body)
|
||||
.zip(decl.inputs.iter())
|
||||
.filter_map(|(arg, ty)| raw_ptr_arg(arg, ty))
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
if !raw_ptrs.is_empty() {
|
||||
let mut v = DerefVisitor {
|
||||
|
@ -751,8 +751,12 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, name: &str, args: &[hir:
|
||||
) {
|
||||
// don't lint for constant values
|
||||
// FIXME: can we `expect` here instead of match?
|
||||
let promotable = cx.tcx.rvalue_promotable_to_static.borrow()
|
||||
.get(&arg.id).cloned().unwrap_or(true);
|
||||
let promotable = cx.tcx
|
||||
.rvalue_promotable_to_static
|
||||
.borrow()
|
||||
.get(&arg.id)
|
||||
.cloned()
|
||||
.unwrap_or(true);
|
||||
if promotable {
|
||||
return;
|
||||
}
|
||||
@ -1348,19 +1352,18 @@ enum SelfKind {
|
||||
|
||||
impl SelfKind {
|
||||
fn matches(self, ty: &hir::Ty, arg: &hir::Arg, self_ty: &hir::Ty, allow_value_for_ref: bool) -> bool {
|
||||
// Self types in the HIR are desugared to explicit self types. So it will always be `self: SomeType`,
|
||||
// Self types in the HIR are desugared to explicit self types. So it will always be `self:
|
||||
// SomeType`,
|
||||
// where SomeType can be `Self` or an explicit impl self type (e.g. `Foo` if the impl is on `Foo`)
|
||||
// Thus, we only need to test equality against the impl self type or if it is an explicit
|
||||
// `Self`. Furthermore, the only possible types for `self: ` are `&Self`, `Self`, `&mut Self`,
|
||||
// and `Box<Self>`, including the equivalent types with `Foo`.
|
||||
let is_actually_self = |ty| {
|
||||
is_self_ty(ty) || ty == self_ty
|
||||
};
|
||||
let is_actually_self = |ty| is_self_ty(ty) || ty == self_ty;
|
||||
if is_self(arg) {
|
||||
match self {
|
||||
match self {
|
||||
SelfKind::Value => is_actually_self(ty),
|
||||
SelfKind::Ref | SelfKind::RefMut if allow_value_for_ref => is_actually_self(ty),
|
||||
SelfKind::Ref | SelfKind::RefMut=> {
|
||||
SelfKind::Ref | SelfKind::RefMut => {
|
||||
match ty.node {
|
||||
hir::TyRptr(_, ref mt_ty) => {
|
||||
let mutability_match = if self == SelfKind::Ref {
|
||||
@ -1370,10 +1373,10 @@ impl SelfKind {
|
||||
};
|
||||
is_actually_self(&mt_ty.ty) && mutability_match
|
||||
|
||||
}
|
||||
_ => false
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
} else {
|
||||
|
@ -42,7 +42,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
||||
.expect("A function with an unknown type is called. If this happened, the compiler would have \
|
||||
aborted the compilation long ago");
|
||||
if let ExprPath(ref path) = fn_expr.node {
|
||||
check_arguments(cx, arguments, function_type, &print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
|
||||
check_arguments(cx,
|
||||
arguments,
|
||||
function_type,
|
||||
&print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
|
||||
}
|
||||
},
|
||||
ExprMethodCall(ref name, _, ref arguments) => {
|
||||
|
@ -112,7 +112,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
||||
!self.ignore_fn && l_name.node == r_name.node && over(l_tys, r_tys, |l, r| self.eq_ty(l, r)) &&
|
||||
self.eq_exprs(l_args, r_args)
|
||||
},
|
||||
(&ExprRepeat(ref le, ll_id), &ExprRepeat(ref re, rl_id)) => self.eq_expr(le, re) && self.eq_expr(&self.cx.tcx.map.body(ll_id).value, &self.cx.tcx.map.body(rl_id).value),
|
||||
(&ExprRepeat(ref le, ll_id), &ExprRepeat(ref re, rl_id)) => {
|
||||
self.eq_expr(le, re) &&
|
||||
self.eq_expr(&self.cx.tcx.map.body(ll_id).value, &self.cx.tcx.map.body(rl_id).value)
|
||||
},
|
||||
(&ExprRet(ref l), &ExprRet(ref r)) => both(l, r, |l, r| self.eq_expr(l, r)),
|
||||
(&ExprPath(ref l), &ExprPath(ref r)) => self.eq_qpath(l, r),
|
||||
(&ExprStruct(ref l_path, ref lf, ref lo), &ExprStruct(ref r_path, ref rf, ref ro)) => {
|
||||
@ -183,7 +186,8 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
||||
}
|
||||
|
||||
fn eq_path(&self, left: &Path, right: &Path) -> bool {
|
||||
left.is_global() == right.is_global() && over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
|
||||
left.is_global() == right.is_global() &&
|
||||
over(&left.segments, &right.segments, |l, r| self.eq_path_segment(l, r))
|
||||
}
|
||||
|
||||
fn eq_path_parameters(&self, left: &PathParameters, right: &PathParameters) -> bool {
|
||||
@ -211,7 +215,10 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
||||
fn eq_ty(&self, left: &Ty, right: &Ty) -> bool {
|
||||
match (&left.node, &right.node) {
|
||||
(&TySlice(ref l_vec), &TySlice(ref r_vec)) => self.eq_ty(l_vec, r_vec),
|
||||
(&TyArray(ref lt, ll_id), &TyArray(ref rt, rl_id)) => self.eq_ty(lt, rt) && self.eq_expr(&self.cx.tcx.map.body(ll_id).value, &self.cx.tcx.map.body(rl_id).value),
|
||||
(&TyArray(ref lt, ll_id), &TyArray(ref rt, rl_id)) => {
|
||||
self.eq_ty(lt, rt) &&
|
||||
self.eq_expr(&self.cx.tcx.map.body(ll_id).value, &self.cx.tcx.map.body(rl_id).value)
|
||||
},
|
||||
(&TyPtr(ref l_mut), &TyPtr(ref r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(&*l_mut.ty, &*r_mut.ty),
|
||||
(&TyRptr(_, ref l_rmut), &TyRptr(_, ref r_rmut)) => {
|
||||
l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(&*l_rmut.ty, &*r_rmut.ty)
|
||||
|
@ -53,7 +53,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||
match item.vis {
|
||||
hir::Visibility::Public => println!("public"),
|
||||
hir::Visibility::Crate => println!("visible crate wide"),
|
||||
hir::Visibility::Restricted { ref path, .. } => println!("visible in module `{}`", print::to_string(print::NO_ANN, |s| s.print_path(path, false))),
|
||||
hir::Visibility::Restricted { ref path, .. } => {
|
||||
println!("visible in module `{}`",
|
||||
print::to_string(print::NO_ANN, |s| s.print_path(path, false)))
|
||||
},
|
||||
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
|
||||
}
|
||||
if item.defaultness.is_default() {
|
||||
@ -340,7 +343,10 @@ fn print_item(cx: &LateContext, item: &hir::Item) {
|
||||
match item.vis {
|
||||
hir::Visibility::Public => println!("public"),
|
||||
hir::Visibility::Crate => println!("visible crate wide"),
|
||||
hir::Visibility::Restricted { ref path, .. } => println!("visible in module `{}`", print::to_string(print::NO_ANN, |s| s.print_path(path, false))),
|
||||
hir::Visibility::Restricted { ref path, .. } => {
|
||||
println!("visible in module `{}`",
|
||||
print::to_string(print::NO_ANN, |s| s.print_path(path, false)))
|
||||
},
|
||||
hir::Visibility::Inherited => println!("visibility inherited from outer item"),
|
||||
}
|
||||
match item.node {
|
||||
@ -414,7 +420,9 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
|
||||
},
|
||||
hir::PatKind::Struct(ref path, ref fields, ignore) => {
|
||||
println!("{}Struct", ind);
|
||||
println!("{}name: {}", ind, print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
|
||||
println!("{}name: {}",
|
||||
ind,
|
||||
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
|
||||
println!("{}ignore leftover fields: {}", ind, ignore);
|
||||
println!("{}fields:", ind);
|
||||
for field in fields {
|
||||
@ -427,7 +435,9 @@ fn print_pat(cx: &LateContext, pat: &hir::Pat, indent: usize) {
|
||||
},
|
||||
hir::PatKind::TupleStruct(ref path, ref fields, opt_dots_position) => {
|
||||
println!("{}TupleStruct", ind);
|
||||
println!("{}path: {}", ind, print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
|
||||
println!("{}path: {}",
|
||||
ind,
|
||||
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
|
||||
if let Some(dot_position) = opt_dots_position {
|
||||
println!("{}dot position: {}", ind, dot_position);
|
||||
}
|
||||
|
@ -917,6 +917,6 @@ pub fn is_self_ty(slf: &Ty) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<Item=&'tcx Arg> {
|
||||
pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<Item = &'tcx Arg> {
|
||||
(0..decl.inputs.len()).map(move |i| &body.arguments[i])
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user