Various pattern cleanups
This commit is contained in:
parent
fde1b76b4b
commit
2b0c8fff8a
9 changed files with 47 additions and 68 deletions
|
@ -1179,13 +1179,10 @@ fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
|
||||||
for (op, _) in &mut asm.operands {
|
for (op, _) in &mut asm.operands {
|
||||||
match op {
|
match op {
|
||||||
InlineAsmOperand::In { expr, .. }
|
InlineAsmOperand::In { expr, .. }
|
||||||
|
| InlineAsmOperand::Out { expr: Some(expr), .. }
|
||||||
| InlineAsmOperand::InOut { expr, .. }
|
| InlineAsmOperand::InOut { expr, .. }
|
||||||
| InlineAsmOperand::Sym { expr, .. } => vis.visit_expr(expr),
|
| InlineAsmOperand::Sym { expr, .. } => vis.visit_expr(expr),
|
||||||
InlineAsmOperand::Out { expr, .. } => {
|
InlineAsmOperand::Out { expr: None, .. } => {}
|
||||||
if let Some(expr) = expr {
|
|
||||||
vis.visit_expr(expr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||||
vis.visit_expr(in_expr);
|
vis.visit_expr(in_expr);
|
||||||
if let Some(out_expr) = out_expr {
|
if let Some(out_expr) = out_expr {
|
||||||
|
|
|
@ -714,13 +714,10 @@ fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm) {
|
||||||
for (op, _) in &asm.operands {
|
for (op, _) in &asm.operands {
|
||||||
match op {
|
match op {
|
||||||
InlineAsmOperand::In { expr, .. }
|
InlineAsmOperand::In { expr, .. }
|
||||||
|
| InlineAsmOperand::Out { expr: Some(expr), .. }
|
||||||
| InlineAsmOperand::InOut { expr, .. }
|
| InlineAsmOperand::InOut { expr, .. }
|
||||||
| InlineAsmOperand::Sym { expr, .. } => visitor.visit_expr(expr),
|
| InlineAsmOperand::Sym { expr, .. } => visitor.visit_expr(expr),
|
||||||
InlineAsmOperand::Out { expr, .. } => {
|
InlineAsmOperand::Out { expr: None, .. } => {}
|
||||||
if let Some(expr) = expr {
|
|
||||||
visitor.visit_expr(expr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||||
visitor.visit_expr(in_expr);
|
visitor.visit_expr(in_expr);
|
||||||
if let Some(out_expr) = out_expr {
|
if let Some(out_expr) = out_expr {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![cfg_attr(bootstrap, feature(bindings_after_at))]
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(destructuring_assignment)]
|
#![feature(destructuring_assignment)]
|
||||||
|
|
|
@ -1664,13 +1664,10 @@ impl Debug for Statement<'_> {
|
||||||
AscribeUserType(box (ref place, ref c_ty), ref variance) => {
|
AscribeUserType(box (ref place, ref c_ty), ref variance) => {
|
||||||
write!(fmt, "AscribeUserType({:?}, {:?}, {:?})", place, variance, c_ty)
|
write!(fmt, "AscribeUserType({:?}, {:?}, {:?})", place, variance, c_ty)
|
||||||
}
|
}
|
||||||
Coverage(box ref coverage) => {
|
Coverage(box self::Coverage { ref kind, code_region: Some(ref rgn) }) => {
|
||||||
if let Some(rgn) = &coverage.code_region {
|
write!(fmt, "Coverage::{:?} for {:?}", kind, rgn)
|
||||||
write!(fmt, "Coverage::{:?} for {:?}", coverage.kind, rgn)
|
|
||||||
} else {
|
|
||||||
write!(fmt, "Coverage::{:?}", coverage.kind)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Coverage(box ref coverage) => write!(fmt, "Coverage::{:?}", coverage.kind),
|
||||||
CopyNonOverlapping(box crate::mir::CopyNonOverlapping {
|
CopyNonOverlapping(box crate::mir::CopyNonOverlapping {
|
||||||
ref src,
|
ref src,
|
||||||
ref dst,
|
ref dst,
|
||||||
|
|
|
@ -587,14 +587,12 @@ macro_rules! make_mir_visitor {
|
||||||
InlineAsmOperand::In { value, .. } => {
|
InlineAsmOperand::In { value, .. } => {
|
||||||
self.visit_operand(value, location);
|
self.visit_operand(value, location);
|
||||||
}
|
}
|
||||||
InlineAsmOperand::Out { place, .. } => {
|
InlineAsmOperand::Out { place: Some(place), .. } => {
|
||||||
if let Some(place) = place {
|
self.visit_place(
|
||||||
self.visit_place(
|
place,
|
||||||
place,
|
PlaceContext::MutatingUse(MutatingUseContext::Store),
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Store),
|
location,
|
||||||
location,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
InlineAsmOperand::InOut { in_value, out_place, .. } => {
|
InlineAsmOperand::InOut { in_value, out_place, .. } => {
|
||||||
self.visit_operand(in_value, location);
|
self.visit_operand(in_value, location);
|
||||||
|
@ -610,7 +608,8 @@ macro_rules! make_mir_visitor {
|
||||||
| InlineAsmOperand::SymFn { value } => {
|
| InlineAsmOperand::SymFn { value } => {
|
||||||
self.visit_constant(value, location);
|
self.visit_constant(value, location);
|
||||||
}
|
}
|
||||||
InlineAsmOperand::SymStatic { def_id: _ } => {}
|
InlineAsmOperand::Out { place: None, .. }
|
||||||
|
| InlineAsmOperand::SymStatic { def_id: _ } => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use rustc_hir::def::CtorKind;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::RangeEnd;
|
use rustc_hir::RangeEnd;
|
||||||
use rustc_index::newtype_index;
|
use rustc_index::newtype_index;
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_middle::infer::canonical::Canonical;
|
use rustc_middle::infer::canonical::Canonical;
|
||||||
use rustc_middle::middle::region;
|
use rustc_middle::middle::region;
|
||||||
use rustc_middle::mir::{
|
use rustc_middle::mir::{
|
||||||
|
@ -716,17 +716,9 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
|
||||||
PatKind::Variant { adt_def, variant_index, .. } => {
|
PatKind::Variant { adt_def, variant_index, .. } => {
|
||||||
Some(&adt_def.variants[variant_index])
|
Some(&adt_def.variants[variant_index])
|
||||||
}
|
}
|
||||||
_ => {
|
_ => self.ty.ty_adt_def().and_then(|adt| {
|
||||||
if let ty::Adt(adt, _) = self.ty.kind() {
|
if !adt.is_enum() { Some(adt.non_enum_variant()) } else { None }
|
||||||
if !adt.is_enum() {
|
}),
|
||||||
Some(&adt.variants[VariantIdx::new(0)])
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(variant) = variant {
|
if let Some(variant) = variant {
|
||||||
|
|
|
@ -927,27 +927,29 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
}
|
}
|
||||||
|
|
||||||
match ct.val {
|
match ct.val {
|
||||||
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }) => {
|
ty::ConstKind::Unevaluated(ty::Unevaluated {
|
||||||
if let Some(promoted) = promoted {
|
def,
|
||||||
p!(print_value_path(def.did, substs));
|
substs,
|
||||||
p!(write("::{:?}", promoted));
|
promoted: Some(promoted),
|
||||||
} else {
|
}) => {
|
||||||
match self.tcx().def_kind(def.did) {
|
p!(print_value_path(def.did, substs));
|
||||||
DefKind::Static | DefKind::Const | DefKind::AssocConst => {
|
p!(write("::{:?}", promoted));
|
||||||
p!(print_value_path(def.did, substs))
|
}
|
||||||
}
|
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted: None }) => {
|
||||||
_ => {
|
match self.tcx().def_kind(def.did) {
|
||||||
if def.is_local() {
|
DefKind::Static | DefKind::Const | DefKind::AssocConst => {
|
||||||
let span = self.tcx().def_span(def.did);
|
p!(print_value_path(def.did, substs))
|
||||||
if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span)
|
}
|
||||||
{
|
_ => {
|
||||||
p!(write("{}", snip))
|
if def.is_local() {
|
||||||
} else {
|
let span = self.tcx().def_span(def.did);
|
||||||
print_underscore!()
|
if let Ok(snip) = self.tcx().sess.source_map().span_to_snippet(span) {
|
||||||
}
|
p!(write("{}", snip))
|
||||||
} else {
|
} else {
|
||||||
print_underscore!()
|
print_underscore!()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
print_underscore!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2164,14 +2164,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
hir::InlineAsmOperand::In { expr, .. } => {
|
hir::InlineAsmOperand::In { expr, .. } => {
|
||||||
self.check_expr_asm_operand(expr, true);
|
self.check_expr_asm_operand(expr, true);
|
||||||
}
|
}
|
||||||
hir::InlineAsmOperand::Out { expr, .. } => {
|
hir::InlineAsmOperand::Out { expr: Some(expr), .. }
|
||||||
if let Some(expr) = expr {
|
| hir::InlineAsmOperand::InOut { expr, .. } => {
|
||||||
self.check_expr_asm_operand(expr, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hir::InlineAsmOperand::InOut { expr, .. } => {
|
|
||||||
self.check_expr_asm_operand(expr, false);
|
self.check_expr_asm_operand(expr, false);
|
||||||
}
|
}
|
||||||
|
hir::InlineAsmOperand::Out { expr: None, .. } => {}
|
||||||
hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||||
self.check_expr_asm_operand(in_expr, true);
|
self.check_expr_asm_operand(in_expr, true);
|
||||||
if let Some(out_expr) = out_expr {
|
if let Some(out_expr) = out_expr {
|
||||||
|
|
|
@ -334,12 +334,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||||
match op {
|
match op {
|
||||||
hir::InlineAsmOperand::In { expr, .. }
|
hir::InlineAsmOperand::In { expr, .. }
|
||||||
| hir::InlineAsmOperand::Sym { expr, .. } => self.consume_expr(expr),
|
| hir::InlineAsmOperand::Sym { expr, .. } => self.consume_expr(expr),
|
||||||
hir::InlineAsmOperand::Out { expr, .. } => {
|
hir::InlineAsmOperand::Out { expr: Some(expr), .. }
|
||||||
if let Some(expr) = expr {
|
| hir::InlineAsmOperand::InOut { expr, .. } => {
|
||||||
self.mutate_expr(expr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hir::InlineAsmOperand::InOut { expr, .. } => {
|
|
||||||
self.mutate_expr(expr);
|
self.mutate_expr(expr);
|
||||||
}
|
}
|
||||||
hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
hir::InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||||
|
@ -348,7 +344,8 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
||||||
self.mutate_expr(out_expr);
|
self.mutate_expr(out_expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::InlineAsmOperand::Const { .. } => {}
|
hir::InlineAsmOperand::Out { expr: None, .. }
|
||||||
|
| hir::InlineAsmOperand::Const { .. } => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue