Run Rustfix on librustc_mir

This commit is contained in:
Manish Goregaokar 2018-02-23 10:15:26 -08:00
parent fb7980d796
commit 8d730ed527
11 changed files with 36 additions and 36 deletions

View file

@ -176,7 +176,7 @@ impl<'gcx, 'tcx> UseFinder<'gcx, 'tcx> {
None
}
fn def_use(&self, location: Location, thing: &MirVisitable<'tcx>) -> (bool, bool) {
fn def_use(&self, location: Location, thing: &dyn MirVisitable<'tcx>) -> (bool, bool) {
let mut visitor = DefUseVisitor {
defined: false,
used: false,

View file

@ -260,10 +260,10 @@ fn dump_annotation<'a, 'gcx, 'tcx>(
fn for_each_region_constraint(
closure_region_requirements: &ClosureRegionRequirements,
with_msg: &mut FnMut(&str) -> io::Result<()>,
with_msg: &mut dyn FnMut(&str) -> io::Result<()>,
) -> io::Result<()> {
for req in &closure_region_requirements.outlives_requirements {
let subject: &Debug = match &req.subject {
let subject: &dyn Debug = match &req.subject {
ClosureOutlivesSubject::Region(subject) => subject,
ClosureOutlivesSubject::Ty(ty) => ty,
};

View file

@ -23,7 +23,7 @@ const REGION_WIDTH: usize = 8;
impl<'tcx> RegionInferenceContext<'tcx> {
/// Write out our state into the `.mir` files.
pub(crate) fn dump_mir(&self, out: &mut Write) -> io::Result<()> {
pub(crate) fn dump_mir(&self, out: &mut dyn Write) -> io::Result<()> {
writeln!(out, "| Free Region Mapping")?;
for region in self.regions() {
@ -67,7 +67,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
/// inference resulted in the values that it did when debugging.
fn for_each_constraint(
&self,
with_msg: &mut FnMut(&str) -> io::Result<()>,
with_msg: &mut dyn FnMut(&str) -> io::Result<()>,
) -> io::Result<()> {
for region in self.definitions.indices() {
let value = self.liveness_constraints.region_value_str(region);

View file

@ -20,7 +20,7 @@ use super::*;
impl<'tcx> RegionInferenceContext<'tcx> {
/// Write out the region constraint graph.
pub(crate) fn dump_graphviz(&self, mut w: &mut Write) -> io::Result<()> {
pub(crate) fn dump_graphviz(&self, mut w: &mut dyn Write) -> io::Result<()> {
dot::render(self, &mut w)
}
}

View file

@ -127,7 +127,7 @@ fn type_check_internal<'gcx, 'tcx>(
mir: &Mir<'tcx>,
region_bound_pairs: &[(ty::Region<'tcx>, GenericKind<'tcx>)],
implicit_region_bound: Option<ty::Region<'tcx>>,
extra: &mut FnMut(&mut TypeChecker<'_, 'gcx, 'tcx>),
extra: &mut dyn FnMut(&mut TypeChecker<'_, 'gcx, 'tcx>),
) -> MirTypeckRegionConstraints<'tcx> {
let mut checker = TypeChecker::new(
infcx,
@ -231,7 +231,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
self.cx.infcx.tcx
}
fn sanitize_type(&mut self, parent: &fmt::Debug, ty: Ty<'tcx>) -> Ty<'tcx> {
fn sanitize_type(&mut self, parent: &dyn fmt::Debug, ty: Ty<'tcx>) -> Ty<'tcx> {
if ty.has_escaping_regions() || ty.references_error() {
span_mirbug_and_err!(self, parent, "bad type {:?}", ty)
} else {
@ -516,7 +516,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
fn field_ty(
&mut self,
parent: &fmt::Debug,
parent: &dyn fmt::Debug,
base_ty: PlaceTy<'tcx>,
field: Field,
location: Location,
@ -1171,7 +1171,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
fn assert_iscleanup(
&mut self,
mir: &Mir<'tcx>,
ctxt: &fmt::Debug,
ctxt: &dyn fmt::Debug,
bb: BasicBlock,
iscleanuppad: bool,
) {

View file

@ -61,7 +61,7 @@ pub(crate) struct DataflowBuilder<'a, 'tcx: 'a, BD> where BD: BitDenotation
pub(crate) struct DebugFormatted(String);
impl DebugFormatted {
pub fn new(input: &fmt::Debug) -> DebugFormatted {
pub fn new(input: &dyn fmt::Debug) -> DebugFormatted {
DebugFormatted(format!("{:?}", input))
}
}

View file

@ -168,7 +168,7 @@ impl Error for ConstEvalError {
}
}
fn cause(&self) -> Option<&Error> {
fn cause(&self) -> Option<&dyn Error> {
None
}
}

View file

@ -49,7 +49,7 @@ impl fmt::Display for Disambiguator {
pub fn on_mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
pass_num: &fmt::Display,
pass_num: &dyn fmt::Display,
pass_name: &str,
source: MirSource,
mir: &Mir<'tcx>,

View file

@ -161,7 +161,7 @@ pub macro run_passes($tcx:ident, $mir:ident, $def_id:ident, $suite_index:expr; $
promoted
};
let mut index = 0;
let mut run_pass = |pass: &MirPass| {
let mut run_pass = |pass: &dyn MirPassPassPass| {
let run_hooks = |mir: &_, index, is_after| {
dump_mir::on_mir_pass($tcx, &format_args!("{:03}-{:03}", suite_index, index),
&pass.name(), source, mir, is_after);

View file

@ -425,12 +425,12 @@ pub fn write_mir_fn<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
src: MirSource,
mir: &Mir<'tcx>,
w: &mut Write,
w: &mut dyn Write,
result: &LivenessResult,
) -> io::Result<()> {
write_mir_intro(tcx, src, mir, w)?;
for block in mir.basic_blocks().indices() {
let print = |w: &mut Write, prefix, result: &IndexVec<BasicBlock, LocalSet>| {
let print = |w: &mut dyn Write, prefix, result: &IndexVec<BasicBlock, LocalSet>| {
let live: Vec<String> = mir.local_decls
.indices()
.filter(|i| result[block].contains(i))

View file

@ -72,14 +72,14 @@ pub enum PassWhere {
/// or `typeck` and `bar` both appear in the name.
pub fn dump_mir<'a, 'gcx, 'tcx, F>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pass_num: Option<&Display>,
pass_num: Option<&dyn Display>,
pass_name: &str,
disambiguator: &Display,
disambiguator: &dyn Display,
source: MirSource,
mir: &Mir<'tcx>,
extra_data: F,
) where
F: FnMut(PassWhere, &mut Write) -> io::Result<()>,
F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>,
{
if !dump_enabled(tcx, pass_name, source) {
return;
@ -127,15 +127,15 @@ pub fn dump_enabled<'a, 'gcx, 'tcx>(
fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
pass_num: Option<&Display>,
pass_num: Option<&dyn Display>,
pass_name: &str,
node_path: &str,
disambiguator: &Display,
disambiguator: &dyn Display,
source: MirSource,
mir: &Mir<'tcx>,
mut extra_data: F,
) where
F: FnMut(PassWhere, &mut Write) -> io::Result<()>,
F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>,
{
let _: io::Result<()> = do catch {
let mut file = create_dump_file(tcx, "mir", pass_num, pass_name, disambiguator, source)?;
@ -169,9 +169,9 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(
fn dump_path(
tcx: TyCtxt<'_, '_, '_>,
extension: &str,
pass_num: Option<&Display>,
pass_num: Option<&dyn Display>,
pass_name: &str,
disambiguator: &Display,
disambiguator: &dyn Display,
source: MirSource,
) -> PathBuf {
let promotion_id = match source.promoted {
@ -217,9 +217,9 @@ fn dump_path(
pub(crate) fn create_dump_file(
tcx: TyCtxt<'_, '_, '_>,
extension: &str,
pass_num: Option<&Display>,
pass_num: Option<&dyn Display>,
pass_name: &str,
disambiguator: &Display,
disambiguator: &dyn Display,
source: MirSource,
) -> io::Result<fs::File> {
let file_path = dump_path(tcx, extension, pass_num, pass_name, disambiguator, source);
@ -233,7 +233,7 @@ pub(crate) fn create_dump_file(
pub fn write_mir_pretty<'a, 'gcx, 'tcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
single: Option<DefId>,
w: &mut Write,
w: &mut dyn Write,
) -> io::Result<()> {
writeln!(
w,
@ -274,10 +274,10 @@ pub fn write_mir_fn<'a, 'gcx, 'tcx, F>(
src: MirSource,
mir: &Mir<'tcx>,
extra_data: &mut F,
w: &mut Write,
w: &mut dyn Write,
) -> io::Result<()>
where
F: FnMut(PassWhere, &mut Write) -> io::Result<()>,
F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>,
{
write_mir_intro(tcx, src, mir, w)?;
for block in mir.basic_blocks().indices() {
@ -298,10 +298,10 @@ pub fn write_basic_block<'cx, 'gcx, 'tcx, F>(
block: BasicBlock,
mir: &Mir<'tcx>,
extra_data: &mut F,
w: &mut Write,
w: &mut dyn Write,
) -> io::Result<()>
where
F: FnMut(PassWhere, &mut Write) -> io::Result<()>,
F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>,
{
let data = &mir[block];
@ -362,7 +362,7 @@ where
/// a statement.
fn write_extra<'cx, 'gcx, 'tcx, F>(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
write: &mut Write,
write: &mut dyn Write,
mut visit_op: F,
) -> io::Result<()>
where
@ -450,7 +450,7 @@ fn write_scope_tree(
tcx: TyCtxt,
mir: &Mir,
scope_tree: &FxHashMap<VisibilityScope, Vec<VisibilityScope>>,
w: &mut Write,
w: &mut dyn Write,
parent: VisibilityScope,
depth: usize,
) -> io::Result<()> {
@ -515,7 +515,7 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>(
tcx: TyCtxt<'a, 'gcx, 'tcx>,
src: MirSource,
mir: &Mir,
w: &mut Write,
w: &mut dyn Write,
) -> io::Result<()> {
write_mir_sig(tcx, src, mir, w)?;
writeln!(w, "{{")?;
@ -553,7 +553,7 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>(
Ok(())
}
fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut Write) -> io::Result<()> {
fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
let id = tcx.hir.as_local_node_id(src.def_id).unwrap();
let body_owner_kind = tcx.hir.body_owner_kind(id);
match (body_owner_kind, src.promoted) {
@ -597,7 +597,7 @@ fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut Write) -> io::R
Ok(())
}
fn write_temp_decls(mir: &Mir, w: &mut Write) -> io::Result<()> {
fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
// Compiler-introduced temporary types.
for temp in mir.temps_iter() {
writeln!(