Fix tidy
This commit is contained in:
parent
5b0cf56f32
commit
19730cc996
@ -519,7 +519,13 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
// visit_enum_def() takes care of visiting the Item's NodeId
|
||||
visitor.visit_enum_def(enum_definition, type_parameters, item.id, item.span)
|
||||
}
|
||||
ItemKind::Impl(.., ref type_parameters, ref opt_trait_reference, ref typ, ref impl_item_refs) => {
|
||||
ItemKind::Impl(
|
||||
..,
|
||||
ref type_parameters,
|
||||
ref opt_trait_reference,
|
||||
ref typ,
|
||||
ref impl_item_refs
|
||||
) => {
|
||||
visitor.visit_id(item.id);
|
||||
visitor.visit_generics(type_parameters);
|
||||
walk_list!(visitor, visit_trait_ref, opt_trait_reference);
|
||||
|
@ -3877,7 +3877,9 @@ impl<'a> LoweringContext<'a> {
|
||||
let expr = opt_expr
|
||||
.as_ref()
|
||||
.map(|x| self.lower_expr(x))
|
||||
.unwrap_or_else(|| self.expr(e.span, hir::ExprKind::Tup(hir_vec![]), ThinVec::new()));
|
||||
.unwrap_or_else(||
|
||||
self.expr(e.span, hir::ExprKind::Tup(hir_vec![]), ThinVec::new())
|
||||
);
|
||||
hir::ExprKind::Yield(P(expr))
|
||||
}
|
||||
|
||||
@ -4053,11 +4055,18 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
P(self.expr(
|
||||
head_sp,
|
||||
hir::ExprKind::Match(next_expr, arms, hir::MatchSource::ForLoopDesugar),
|
||||
hir::ExprKind::Match(
|
||||
next_expr,
|
||||
arms,
|
||||
hir::MatchSource::ForLoopDesugar
|
||||
),
|
||||
ThinVec::new(),
|
||||
))
|
||||
};
|
||||
let match_stmt = respan(head_sp, hir::StmtKind::Expr(match_expr, self.next_id().node_id));
|
||||
let match_stmt = respan(
|
||||
head_sp,
|
||||
hir::StmtKind::Expr(match_expr, self.next_id().node_id)
|
||||
);
|
||||
|
||||
let next_expr = P(self.expr_ident(head_sp, next_ident, next_pat.id));
|
||||
|
||||
@ -4076,7 +4085,10 @@ impl<'a> LoweringContext<'a> {
|
||||
|
||||
let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
|
||||
let body_expr = P(self.expr_block(body_block, ThinVec::new()));
|
||||
let body_stmt = respan(body.span, hir::StmtKind::Expr(body_expr, self.next_id().node_id));
|
||||
let body_stmt = respan(
|
||||
body.span,
|
||||
hir::StmtKind::Expr(body_expr, self.next_id().node_id)
|
||||
);
|
||||
|
||||
let loop_block = P(self.block_all(
|
||||
e.span,
|
||||
|
@ -486,7 +486,10 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
}
|
||||
|
||||
// live nodes required for interesting control flow:
|
||||
hir::ExprKind::If(..) | hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) => {
|
||||
hir::ExprKind::If(..) |
|
||||
hir::ExprKind::Match(..) |
|
||||
hir::ExprKind::While(..) |
|
||||
hir::ExprKind::Loop(..) => {
|
||||
ir.add_live_node_for_node(expr.hir_id, ExprNode(expr.span));
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
@ -496,15 +499,30 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
|
||||
}
|
||||
|
||||
// otherwise, live nodes are not required:
|
||||
hir::ExprKind::Index(..) | hir::ExprKind::Field(..) |
|
||||
hir::ExprKind::Array(..) | hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) |
|
||||
hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) | hir::ExprKind::AddrOf(..) |
|
||||
hir::ExprKind::Cast(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Break(..) |
|
||||
hir::ExprKind::Continue(_) | hir::ExprKind::Lit(_) | hir::ExprKind::Ret(..) |
|
||||
hir::ExprKind::Block(..) | hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) |
|
||||
hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) |
|
||||
hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) | hir::ExprKind::Yield(..) |
|
||||
hir::ExprKind::Type(..) | hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => {
|
||||
hir::ExprKind::Index(..) |
|
||||
hir::ExprKind::Field(..) |
|
||||
hir::ExprKind::Array(..) |
|
||||
hir::ExprKind::Call(..) |
|
||||
hir::ExprKind::MethodCall(..) |
|
||||
hir::ExprKind::Tup(..) |
|
||||
hir::ExprKind::Binary(..) |
|
||||
hir::ExprKind::AddrOf(..) |
|
||||
hir::ExprKind::Cast(..) |
|
||||
hir::ExprKind::Unary(..) |
|
||||
hir::ExprKind::Break(..) |
|
||||
hir::ExprKind::Continue(_) |
|
||||
hir::ExprKind::Lit(_) |
|
||||
hir::ExprKind::Ret(..) |
|
||||
hir::ExprKind::Block(..) |
|
||||
hir::ExprKind::Assign(..) |
|
||||
hir::ExprKind::AssignOp(..) |
|
||||
hir::ExprKind::Struct(..) |
|
||||
hir::ExprKind::Repeat(..) |
|
||||
hir::ExprKind::InlineAsm(..) |
|
||||
hir::ExprKind::Box(..) |
|
||||
hir::ExprKind::Yield(..) |
|
||||
hir::ExprKind::Type(..) |
|
||||
hir::ExprKind::Path(hir::QPath::TypeRelative(..)) => {
|
||||
intravisit::walk_expr(ir, expr);
|
||||
}
|
||||
}
|
||||
|
@ -279,13 +279,20 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
||||
// These are normal, nothing reachable about these
|
||||
// inherently and their children are already in the
|
||||
// worklist, as determined by the privacy pass
|
||||
hir::ItemKind::ExternCrate(_) | hir::ItemKind::Use(..) |
|
||||
hir::ItemKind::ExternCrate(_) |
|
||||
hir::ItemKind::Use(..) |
|
||||
hir::ItemKind::Existential(..) |
|
||||
hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Mod(..) | hir::ItemKind::ForeignMod(..) |
|
||||
hir::ItemKind::Impl(..) | hir::ItemKind::Trait(..) | hir::ItemKind::TraitAlias(..) |
|
||||
hir::ItemKind::Struct(..) | hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Union(..) | hir::ItemKind::GlobalAsm(..) => {}
|
||||
hir::ItemKind::Ty(..) |
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Mod(..) |
|
||||
hir::ItemKind::ForeignMod(..) |
|
||||
hir::ItemKind::Impl(..) |
|
||||
hir::ItemKind::Trait(..) |
|
||||
hir::ItemKind::TraitAlias(..) |
|
||||
hir::ItemKind::Struct(..) |
|
||||
hir::ItemKind::Enum(..) |
|
||||
hir::ItemKind::Union(..) |
|
||||
hir::ItemKind::GlobalAsm(..) => {}
|
||||
}
|
||||
}
|
||||
hir_map::NodeTraitItem(trait_method) => {
|
||||
|
@ -675,7 +675,9 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
|
||||
// ^ ^ this gets resolved in the scope of
|
||||
// the exist_ty generics
|
||||
let (generics, bounds) = match self.tcx.hir.expect_item(id).node {
|
||||
hir::ItemKind::Existential(hir::ExistTy{ ref generics, ref bounds, .. }) => (
|
||||
hir::ItemKind::Existential(
|
||||
hir::ExistTy { ref generics, ref bounds, .. }
|
||||
) => (
|
||||
generics,
|
||||
bounds,
|
||||
),
|
||||
|
@ -285,7 +285,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
|
||||
fn is_comparison(binop: hir::BinOp) -> bool {
|
||||
match binop.node {
|
||||
hir::BinOpKind::Eq | hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Ne | hir::BinOpKind::Ge | hir::BinOpKind::Gt => true,
|
||||
hir::BinOpKind::Eq |
|
||||
hir::BinOpKind::Lt |
|
||||
hir::BinOpKind::Le |
|
||||
hir::BinOpKind::Ne |
|
||||
hir::BinOpKind::Ge |
|
||||
hir::BinOpKind::Gt => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -102,16 +102,29 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
||||
// attribute which does exist on the comparison trait methods
|
||||
hir::ExprKind::Binary(bin_op, ..) => {
|
||||
match bin_op.node {
|
||||
hir::BinOpKind::Eq | hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Ne | hir::BinOpKind::Ge | hir::BinOpKind::Gt => {
|
||||
hir::BinOpKind::Eq |
|
||||
hir::BinOpKind::Lt |
|
||||
hir::BinOpKind::Le |
|
||||
hir::BinOpKind::Ne |
|
||||
hir::BinOpKind::Ge |
|
||||
hir::BinOpKind::Gt => {
|
||||
Some("comparison")
|
||||
},
|
||||
hir::BinOpKind::Add | hir::BinOpKind::Sub | hir::BinOpKind::Div | hir::BinOpKind::Mul | hir::BinOpKind::Rem => {
|
||||
hir::BinOpKind::Add |
|
||||
hir::BinOpKind::Sub |
|
||||
hir::BinOpKind::Div |
|
||||
hir::BinOpKind::Mul |
|
||||
hir::BinOpKind::Rem => {
|
||||
Some("arithmetic operation")
|
||||
},
|
||||
hir::BinOpKind::And | hir::BinOpKind::Or => {
|
||||
Some("logical operation")
|
||||
},
|
||||
hir::BinOpKind::BitXor | hir::BinOpKind::BitAnd | hir::BinOpKind::BitOr | hir::BinOpKind::Shl | hir::BinOpKind::Shr => {
|
||||
hir::BinOpKind::BitXor |
|
||||
hir::BinOpKind::BitAnd |
|
||||
hir::BinOpKind::BitOr |
|
||||
hir::BinOpKind::Shl |
|
||||
hir::BinOpKind::Shr => {
|
||||
Some("bitwise operation")
|
||||
},
|
||||
}
|
||||
|
@ -263,7 +263,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
//
|
||||
// &
|
||||
// - let's call the lifetime of this reference `'1`
|
||||
(ty::TyRef(region, referent_ty, _), hir::TyKind::Rptr(_lifetime, referent_hir_ty)) => {
|
||||
(
|
||||
ty::TyRef(region, referent_ty, _),
|
||||
hir::TyKind::Rptr(_lifetime, referent_hir_ty),
|
||||
) => {
|
||||
if region.to_region_vid() == needle_fr {
|
||||
let region_name = self.synthesize_region_name(counter);
|
||||
|
||||
@ -287,7 +290,10 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
}
|
||||
|
||||
// Match up something like `Foo<'1>`
|
||||
(ty::TyAdt(_adt_def, substs), hir::TyKind::Path(hir::QPath::Resolved(None, path))) => {
|
||||
(
|
||||
ty::TyAdt(_adt_def, substs),
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, path)),
|
||||
) => {
|
||||
if let Some(last_segment) = path.segments.last() {
|
||||
if let Some(name) = self.match_adt_and_segment(
|
||||
substs,
|
||||
|
@ -238,7 +238,9 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
|
||||
args: vec![fun.to_ref(), tupled_args.to_ref()],
|
||||
}
|
||||
} else {
|
||||
let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = fun.node {
|
||||
let adt_data = if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) =
|
||||
fun.node
|
||||
{
|
||||
// Tuple-like ADTs are represented as ExprKind::Call. We convert them here.
|
||||
expr_ty.ty_adt_def().and_then(|adt_def| {
|
||||
match path.def {
|
||||
|
@ -216,9 +216,15 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
hir::ItemKind::Existential(..) |
|
||||
hir::ItemKind::Use(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::GlobalAsm(..) | hir::ItemKind::Ty(..) | hir::ItemKind::Mod(..) | hir::ItemKind::TraitAlias(..) |
|
||||
hir::ItemKind::Fn(..) | hir::ItemKind::ExternCrate(..) => {}
|
||||
hir::ItemKind::Use(..) |
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::GlobalAsm(..) |
|
||||
hir::ItemKind::Ty(..) |
|
||||
hir::ItemKind::Mod(..) |
|
||||
hir::ItemKind::TraitAlias(..) |
|
||||
hir::ItemKind::Fn(..) |
|
||||
hir::ItemKind::ExternCrate(..) => {}
|
||||
}
|
||||
|
||||
// Mark all items in interfaces of reachable items as reachable
|
||||
@ -373,7 +379,8 @@ impl<'a, 'tcx> Visitor<'tcx> for EmbargoVisitor<'a, 'tcx> {
|
||||
loop {
|
||||
let module = if module_id == ast::CRATE_NODE_ID {
|
||||
&self.tcx.hir.krate().module
|
||||
} else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node {
|
||||
} else if let hir::ItemKind::Mod(ref module) = self.tcx.hir.expect_item(module_id).node
|
||||
{
|
||||
module
|
||||
} else {
|
||||
unreachable!()
|
||||
|
@ -306,7 +306,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if self.can_coerce(ref_ty, expected) {
|
||||
if let Ok(src) = cm.span_to_snippet(sp) {
|
||||
let sugg_expr = match expr.node { // parenthesize if needed (Issue #46756)
|
||||
hir::ExprKind::Cast(_, _) | hir::ExprKind::Binary(_, _, _) => format!("({})", src),
|
||||
hir::ExprKind::Cast(_, _) |
|
||||
hir::ExprKind::Binary(_, _, _) => format!("({})", src),
|
||||
_ => src,
|
||||
};
|
||||
if let Some(sugg) = self.can_use_as_ref(expr) {
|
||||
|
@ -389,7 +389,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if let Some(expr) = rcvr_expr {
|
||||
if let Ok(expr_string) = tcx.sess.codemap().span_to_snippet(expr.span) {
|
||||
report_function!(expr.span, expr_string);
|
||||
} else if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) = expr.node {
|
||||
} else if let hir::ExprKind::Path(hir::QPath::Resolved(_, ref path)) =
|
||||
expr.node
|
||||
{
|
||||
if let Some(segment) = path.segments.last() {
|
||||
report_function!(expr.span, segment.ident);
|
||||
}
|
||||
|
@ -363,10 +363,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
hir::BinOpKind::BitOr => Some("std::ops::BitOr"),
|
||||
hir::BinOpKind::Shl => Some("std::ops::Shl"),
|
||||
hir::BinOpKind::Shr => Some("std::ops::Shr"),
|
||||
hir::BinOpKind::Eq | hir::BinOpKind::Ne => Some("std::cmp::PartialEq"),
|
||||
hir::BinOpKind::Lt | hir::BinOpKind::Le | hir::BinOpKind::Gt | hir::BinOpKind::Ge =>
|
||||
Some("std::cmp::PartialOrd"),
|
||||
_ => None
|
||||
hir::BinOpKind::Eq |
|
||||
hir::BinOpKind::Ne => Some("std::cmp::PartialEq"),
|
||||
hir::BinOpKind::Lt |
|
||||
hir::BinOpKind::Le |
|
||||
hir::BinOpKind::Gt |
|
||||
hir::BinOpKind::Ge => Some("std::cmp::PartialOrd"),
|
||||
_ => None
|
||||
};
|
||||
if let Some(missing_trait) = missing_trait {
|
||||
if op.node == hir::BinOpKind::Add &&
|
||||
|
@ -117,7 +117,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
|
||||
// operating on scalars, we clear the overload.
|
||||
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr) {
|
||||
match e.node {
|
||||
hir::ExprKind::Unary(hir::UnNeg, ref inner) | hir::ExprKind::Unary(hir::UnNot, ref inner) => {
|
||||
hir::ExprKind::Unary(hir::UnNeg, ref inner) |
|
||||
hir::ExprKind::Unary(hir::UnNot, ref inner) => {
|
||||
let inner_ty = self.fcx.node_ty(inner.hir_id);
|
||||
let inner_ty = self.fcx.resolve_type_vars_if_possible(&inner_ty);
|
||||
|
||||
|
@ -420,7 +420,10 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
|
||||
}
|
||||
},
|
||||
hir::ItemKind::Existential(..) => {}
|
||||
hir::ItemKind::Ty(..) | hir::ItemKind::Static(..) | hir::ItemKind::Const(..) | hir::ItemKind::Fn(..) => {
|
||||
hir::ItemKind::Ty(..) |
|
||||
hir::ItemKind::Static(..) |
|
||||
hir::ItemKind::Const(..) |
|
||||
hir::ItemKind::Fn(..) => {
|
||||
tcx.generics_of(def_id);
|
||||
tcx.type_of(def_id);
|
||||
tcx.predicates_of(def_id);
|
||||
@ -840,7 +843,8 @@ fn generics_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
generics
|
||||
}
|
||||
|
||||
ItemKind::Trait(_, _, ref generics, ..) | ItemKind::TraitAlias(ref generics, ..) => {
|
||||
ItemKind::Trait(_, _, ref generics, ..) |
|
||||
ItemKind::TraitAlias(ref generics, ..) => {
|
||||
// Add in the self type parameter.
|
||||
//
|
||||
// Something of a hack: use the node id for the trait, also as
|
||||
|
Loading…
x
Reference in New Issue
Block a user