From 725af308093818dc4386a06457eb1e452c7afee1 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 06:28:15 +0900 Subject: [PATCH 1/4] librustc_mir => 2018 --- src/librustc_mir/Cargo.toml | 3 +- src/librustc_mir/borrow_check/borrow_set.rs | 10 ++--- .../borrow_check/error_reporting.rs | 38 ++++++++++------- src/librustc_mir/borrow_check/flows.rs | 18 ++++---- src/librustc_mir/borrow_check/mod.rs | 26 ++++++------ src/librustc_mir/borrow_check/move_errors.rs | 12 +++--- .../borrow_check/mutability_errors.rs | 12 +++--- .../borrow_check/nll/constraint_generation.rs | 10 ++--- .../borrow_check/nll/constraints/graph.rs | 6 +-- .../borrow_check/nll/constraints/mod.rs | 4 +- .../nll/explain_borrow/find_use.rs | 6 +-- .../borrow_check/nll/explain_borrow/mod.rs | 20 ++++----- src/librustc_mir/borrow_check/nll/facts.rs | 4 +- .../borrow_check/nll/invalidation.rs | 24 +++++------ src/librustc_mir/borrow_check/nll/mod.rs | 38 ++++++++--------- .../nll/region_infer/error_reporting/mod.rs | 12 +++--- .../error_reporting/region_name.rs | 8 ++-- .../region_infer/error_reporting/var_name.rs | 4 +- .../borrow_check/nll/region_infer/graphviz.rs | 3 +- .../borrow_check/nll/region_infer/mod.rs | 12 +++--- .../nll/type_check/constraint_conversion.rs | 10 ++--- .../nll/type_check/free_region_relations.rs | 8 ++-- .../nll/type_check/input_output.rs | 2 +- .../nll/type_check/liveness/liveness_map.rs | 6 +-- .../nll/type_check/liveness/local_use_map.rs | 6 +-- .../nll/type_check/liveness/mod.rs | 16 +++---- .../nll/type_check/liveness/trace.rs | 20 ++++----- .../borrow_check/nll/type_check/mod.rs | 42 +++++++++---------- .../borrow_check/nll/type_check/relate_tys.rs | 4 +- src/librustc_mir/borrow_check/path_utils.rs | 10 ++--- src/librustc_mir/borrow_check/place_ext.rs | 2 +- .../borrow_check/places_conflict.rs | 6 +-- src/librustc_mir/borrow_check/used_muts.rs | 2 +- src/librustc_mir/build/block.rs | 8 ++-- src/librustc_mir/build/cfg.rs | 2 +- src/librustc_mir/build/expr/as_constant.rs | 4 +- src/librustc_mir/build/expr/as_operand.rs | 6 +-- src/librustc_mir/build/expr/as_place.rs | 8 ++-- src/librustc_mir/build/expr/as_rvalue.rs | 6 +-- src/librustc_mir/build/expr/as_temp.rs | 4 +- src/librustc_mir/build/expr/category.rs | 2 +- src/librustc_mir/build/expr/into.rs | 6 +-- src/librustc_mir/build/expr/stmt.rs | 6 +-- src/librustc_mir/build/into.rs | 6 +-- src/librustc_mir/build/matches/mod.rs | 10 ++--- src/librustc_mir/build/matches/simplify.rs | 6 +-- src/librustc_mir/build/matches/test.rs | 8 ++-- src/librustc_mir/build/matches/util.rs | 6 +-- src/librustc_mir/build/misc.rs | 2 +- src/librustc_mir/build/mod.rs | 18 ++++---- src/librustc_mir/build/scope.rs | 4 +- src/librustc_mir/const_eval.rs | 2 +- src/librustc_mir/dataflow/at_location.rs | 8 ++-- .../dataflow/drop_flag_effects.rs | 2 +- src/librustc_mir/dataflow/graphviz.rs | 22 +++++----- .../dataflow/impls/borrowed_locals.rs | 6 +-- src/librustc_mir/dataflow/impls/borrows.rs | 26 ++++++------ src/librustc_mir/dataflow/impls/mod.rs | 24 +++++------ .../dataflow/impls/storage_liveness.rs | 6 +-- src/librustc_mir/dataflow/mod.rs | 12 +++--- src/librustc_mir/dataflow/move_paths/mod.rs | 19 +++++---- src/librustc_mir/hair/cx/block.rs | 6 +-- src/librustc_mir/hair/cx/expr.rs | 10 ++--- src/librustc_mir/hair/cx/mod.rs | 8 ++-- src/librustc_mir/hair/cx/to_ref.rs | 2 +- src/librustc_mir/hair/pattern/_match.rs | 8 ++-- src/librustc_mir/hair/pattern/check_match.rs | 22 +++++----- src/librustc_mir/hair/pattern/mod.rs | 8 ++-- src/librustc_mir/interpret/eval_context.rs | 2 +- src/librustc_mir/interpret/snapshot.rs | 14 +++---- src/librustc_mir/interpret/terminator.rs | 6 +-- src/librustc_mir/interpret/traits.rs | 2 +- src/librustc_mir/interpret/visitor.rs | 2 +- src/librustc_mir/lib.rs | 20 +++------ src/librustc_mir/lints.rs | 2 +- src/librustc_mir/monomorphize/collector.rs | 4 +- src/librustc_mir/monomorphize/item.rs | 2 +- src/librustc_mir/monomorphize/partitioning.rs | 22 +++++----- src/librustc_mir/shim.rs | 14 +++---- src/librustc_mir/transform/add_call_guards.rs | 4 +- .../transform/add_moves_for_packed_drops.rs | 6 +-- src/librustc_mir/transform/add_retag.rs | 2 +- src/librustc_mir/transform/check_unsafety.rs | 10 +++-- .../transform/cleanup_post_borrowck.rs | 2 +- src/librustc_mir/transform/const_prop.rs | 8 ++-- src/librustc_mir/transform/copy_prop.rs | 6 +-- src/librustc_mir/transform/deaggregator.rs | 2 +- src/librustc_mir/transform/dump_mir.rs | 6 +-- src/librustc_mir/transform/elaborate_drops.rs | 24 +++++------ src/librustc_mir/transform/erase_regions.rs | 2 +- src/librustc_mir/transform/generator.rs | 20 ++++----- src/librustc_mir/transform/inline.rs | 6 +-- src/librustc_mir/transform/instcombine.rs | 2 +- src/librustc_mir/transform/lower_128bit.rs | 5 +-- src/librustc_mir/transform/mod.rs | 6 +-- src/librustc_mir/transform/no_landing_pads.rs | 2 +- src/librustc_mir/transform/promote_consts.rs | 3 +- src/librustc_mir/transform/qualify_consts.rs | 8 ++-- .../transform/remove_noop_landing_pads.rs | 8 ++-- src/librustc_mir/transform/rustc_peek.rs | 26 ++++++------ src/librustc_mir/transform/simplify.rs | 6 +-- .../transform/simplify_branches.rs | 2 +- .../transform/uniform_array_move_out.rs | 4 +- src/librustc_mir/util/borrowck_errors.rs | 6 +-- src/librustc_mir/util/def_use.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 2 +- src/librustc_mir/util/graphviz.rs | 11 +++-- src/librustc_mir/util/liveness.rs | 4 +- src/librustc_mir/util/patch.rs | 4 +- src/librustc_mir/util/pretty.rs | 23 ++++++---- 110 files changed, 514 insertions(+), 505 deletions(-) diff --git a/src/librustc_mir/Cargo.toml b/src/librustc_mir/Cargo.toml index f0234c48c3eca..44a6b41cdfe45 100644 --- a/src/librustc_mir/Cargo.toml +++ b/src/librustc_mir/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_mir" version = "0.0.0" +edition = "2018" [lib] name = "rustc_mir" @@ -12,7 +13,7 @@ crate-type = ["dylib"] arena = { path = "../libarena" } bitflags = "1.0" either = "1.5.0" -graphviz = { path = "../libgraphviz" } +dot = { path = "../libgraphviz", package = "graphviz" } log = "0.4" log_settings = "0.1.1" polonius-engine = "0.6.2" diff --git a/src/librustc_mir/borrow_check/borrow_set.rs b/src/librustc_mir/borrow_check/borrow_set.rs index ecbc6118bc37c..2788f5d4325a9 100644 --- a/src/librustc_mir/borrow_check/borrow_set.rs +++ b/src/librustc_mir/borrow_check/borrow_set.rs @@ -1,7 +1,7 @@ -use borrow_check::place_ext::PlaceExt; -use borrow_check::nll::ToRegionVid; -use dataflow::indexes::BorrowIndex; -use dataflow::move_paths::MoveData; +use crate::borrow_check::place_ext::PlaceExt; +use crate::borrow_check::nll::ToRegionVid; +use crate::dataflow::indexes::BorrowIndex; +use crate::dataflow::move_paths::MoveData; use rustc::mir::traversal; use rustc::mir::visit::{ PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext @@ -72,7 +72,7 @@ crate struct BorrowData<'tcx> { } impl<'tcx> fmt::Display for BorrowData<'tcx> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { let kind = match self.kind { mir::BorrowKind::Shared => "", mir::BorrowKind::Shallow => "shallow ", diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index b070031756798..afb26963217ff 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -1,7 +1,7 @@ -use borrow_check::nll::explain_borrow::BorrowExplanation; -use borrow_check::nll::region_infer::{RegionName, RegionNameSource}; -use borrow_check::prefixes::IsPrefixOf; -use borrow_check::WriteKind; +use crate::borrow_check::nll::explain_borrow::BorrowExplanation; +use crate::borrow_check::nll::region_infer::{RegionName, RegionNameSource}; +use crate::borrow_check::prefixes::IsPrefixOf; +use crate::borrow_check::WriteKind; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::middle::region::ScopeTree; @@ -22,10 +22,10 @@ use syntax_pos::Span; use super::borrow_set::BorrowData; use super::{Context, MirBorrowckCtxt}; use super::{InitializationRequiringAction, PrefixSet}; -use dataflow::drop_flag_effects; -use dataflow::move_paths::indexes::MoveOutIndex; -use dataflow::move_paths::MovePathIndex; -use util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::dataflow::drop_flag_effects; +use crate::dataflow::move_paths::indexes::MoveOutIndex; +use crate::dataflow::move_paths::MovePathIndex; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; #[derive(Debug)] struct MoveSite { @@ -1726,7 +1726,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } /// End-user visible description of the `field`nth field of `base` - fn describe_field(&self, base: &Place, field: Field) -> String { + fn describe_field(&self, base: &Place<'_>, field: Field) -> String { match *base { Place::Local(local) => { let local = &self.mir.local_decls[local]; @@ -1751,7 +1751,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } /// End-user visible description of the `field_index`nth field of `ty` - fn describe_field_from_ty(&self, ty: &ty::Ty, field: Field) -> String { + fn describe_field_from_ty(&self, ty: &ty::Ty<'_>, field: Field) -> String { if ty.is_box() { // If the type is a box, the field is described from the boxed type self.describe_field_from_ty(&ty.boxed_ty(), field) @@ -1860,7 +1860,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn annotate_argument_and_return_for_borrow( &self, borrow: &BorrowData<'tcx>, - ) -> Option { + ) -> Option> { // Define a fallback for when we can't match a closure. let fallback = || { let is_closure = self.infcx.tcx.is_closure(self.mir_def_id); @@ -2081,7 +2081,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { &self, did: DefId, sig: ty::PolyFnSig<'tcx>, - ) -> Option { + ) -> Option> { debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig); let is_closure = self.infcx.tcx.is_closure(did); let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?; @@ -2368,14 +2368,22 @@ impl UseSpans { } // Add a span label to the arguments of the closure, if it exists. - pub(super) fn args_span_label(self, err: &mut DiagnosticBuilder, message: impl Into) { + pub(super) fn args_span_label( + self, + err: &mut DiagnosticBuilder<'_>, + message: impl Into, + ) { if let UseSpans::ClosureUse { args_span, .. } = self { err.span_label(args_span, message); } } // Add a span label to the use of the captured variable, if it exists. - pub(super) fn var_span_label(self, err: &mut DiagnosticBuilder, message: impl Into) { + pub(super) fn var_span_label( + self, + err: &mut DiagnosticBuilder<'_>, + message: impl Into, + ) { if let UseSpans::ClosureUse { var_span, .. } = self { err.span_label(var_span, message); } @@ -2563,7 +2571,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// Helper to retrieve span(s) of given borrow from the current MIR /// representation - pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData) -> UseSpans { + pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData<'_>) -> UseSpans { let span = self.mir.source_info(borrow.reserve_location).span; self.borrow_spans(span, borrow.reserve_location) } diff --git a/src/librustc_mir/borrow_check/flows.rs b/src/librustc_mir/borrow_check/flows.rs index 4eeb19c4e7a67..8de39f0efc1a5 100644 --- a/src/librustc_mir/borrow_check/flows.rs +++ b/src/librustc_mir/borrow_check/flows.rs @@ -7,16 +7,16 @@ use rustc::mir::{BasicBlock, Location}; use rustc::ty::RegionVid; use rustc_data_structures::bit_set::BitIter; -use borrow_check::location::LocationIndex; +use crate::borrow_check::location::LocationIndex; use polonius_engine::Output; -use dataflow::move_paths::indexes::BorrowIndex; -use dataflow::move_paths::HasMoveData; -use dataflow::Borrows; -use dataflow::EverInitializedPlaces; -use dataflow::{FlowAtLocation, FlowsAtLocation}; -use dataflow::MaybeUninitializedPlaces; +use crate::dataflow::move_paths::indexes::BorrowIndex; +use crate::dataflow::move_paths::HasMoveData; +use crate::dataflow::Borrows; +use crate::dataflow::EverInitializedPlaces; +use crate::dataflow::{FlowAtLocation, FlowsAtLocation}; +use crate::dataflow::MaybeUninitializedPlaces; use either::Either; use std::fmt; use std::rc::Rc; @@ -57,7 +57,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> { } } - crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter)) { + crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<'_, BorrowIndex>)) { self.borrows.with_iter_outgoing(op) } } @@ -93,7 +93,7 @@ impl<'b, 'gcx, 'tcx> FlowsAtLocation for Flows<'b, 'gcx, 'tcx> { } impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let mut s = String::new(); s.push_str("borrows in effect: ["); diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 5597e4a6c597e..45a8c9e8e6909 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -1,6 +1,6 @@ //! This query borrow-checks the MIR to (further) ensure it is not broken. -use borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; @@ -25,16 +25,16 @@ use std::collections::BTreeMap; use syntax_pos::Span; -use dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex}; -use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError}; -use dataflow::Borrows; -use dataflow::DataflowResultsConsumer; -use dataflow::FlowAtLocation; -use dataflow::MoveDataParamEnv; -use dataflow::{do_dataflow, DebugFormatted}; -use dataflow::EverInitializedPlaces; -use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; -use util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex}; +use crate::dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError}; +use crate::dataflow::Borrows; +use crate::dataflow::DataflowResultsConsumer; +use crate::dataflow::FlowAtLocation; +use crate::dataflow::MoveDataParamEnv; +use crate::dataflow::{do_dataflow, DebugFormatted}; +use crate::dataflow::EverInitializedPlaces; +use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; use self::borrow_set::{BorrowData, BorrowSet}; use self::flows::Flows; @@ -59,7 +59,7 @@ mod used_muts; pub(crate) mod nll; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { mir_borrowck, ..*providers @@ -108,7 +108,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC } let opt_closure_req = tcx.infer_ctxt().enter(|infcx| { - let input_mir: &Mir = &input_mir.borrow(); + let input_mir: &Mir<'_> = &input_mir.borrow(); do_mir_borrowck(&infcx, input_mir, def_id) }); debug!("mir_borrowck done"); diff --git a/src/librustc_mir/borrow_check/move_errors.rs b/src/librustc_mir/borrow_check/move_errors.rs index 8539b5c26cee8..f7d46925e17df 100644 --- a/src/librustc_mir/borrow_check/move_errors.rs +++ b/src/librustc_mir/borrow_check/move_errors.rs @@ -6,13 +6,13 @@ use rustc::ty; use rustc_errors::{DiagnosticBuilder,Applicability}; use syntax_pos::Span; -use borrow_check::MirBorrowckCtxt; -use borrow_check::prefixes::PrefixSet; -use dataflow::move_paths::{ +use crate::borrow_check::MirBorrowckCtxt; +use crate::borrow_check::prefixes::PrefixSet; +use crate::dataflow::move_paths::{ IllegalMoveOrigin, IllegalMoveOriginKind, InitLocation, LookupResult, MoveError, MovePathIndex, }; -use util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; // Often when desugaring a pattern match we may have many individual moves in // MIR that are all part of one operation from the user's point-of-view. For @@ -63,7 +63,7 @@ enum BorrowedContentSource { } impl Display for BorrowedContentSource { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { BorrowedContentSource::Arc => write!(f, "an `Arc`"), BorrowedContentSource::Rc => write!(f, "an `Rc`"), @@ -240,7 +240,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> { fn report(&mut self, error: GroupedMoveError<'tcx>) { let (mut err, err_span) = { - let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind) = + let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind<'_>) = match error { GroupedMoveError::MovesFromPlace { span, diff --git a/src/librustc_mir/borrow_check/mutability_errors.rs b/src/librustc_mir/borrow_check/mutability_errors.rs index 9d3ce7693ea86..dad8d903cf9fe 100644 --- a/src/librustc_mir/borrow_check/mutability_errors.rs +++ b/src/librustc_mir/borrow_check/mutability_errors.rs @@ -8,11 +8,11 @@ use rustc_data_structures::indexed_vec::Idx; use syntax_pos::Span; use syntax_pos::symbol::keywords; -use dataflow::move_paths::InitLocation; -use borrow_check::MirBorrowckCtxt; -use util::borrowck_errors::{BorrowckErrors, Origin}; -use util::collect_writes::FindAssignments; -use util::suggest_ref_mut; +use crate::dataflow::move_paths::InitLocation; +use crate::borrow_check::MirBorrowckCtxt; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; +use crate::util::collect_writes::FindAssignments; +use crate::util::suggest_ref_mut; use rustc_errors::Applicability; #[derive(Copy, Clone, Debug, Eq, PartialEq)] @@ -611,7 +611,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>( }) } -fn is_closure_or_generator(ty: ty::Ty) -> bool { +fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool { ty.is_closure() || ty.is_generator() } diff --git a/src/librustc_mir/borrow_check/nll/constraint_generation.rs b/src/librustc_mir/borrow_check/nll/constraint_generation.rs index 588f46cb77fe2..c02c2b4934cf4 100644 --- a/src/librustc_mir/borrow_check/nll/constraint_generation.rs +++ b/src/librustc_mir/borrow_check/nll/constraint_generation.rs @@ -1,8 +1,8 @@ -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::LocationTable; -use borrow_check::nll::ToRegionVid; -use borrow_check::nll::facts::AllFacts; -use borrow_check::nll::region_infer::values::LivenessValues; +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::facts::AllFacts; +use crate::borrow_check::nll::region_infer::values::LivenessValues; use rustc::infer::InferCtxt; use rustc::mir::visit::TyContext; use rustc::mir::visit::Visitor; diff --git a/src/librustc_mir/borrow_check/nll/constraints/graph.rs b/src/librustc_mir/borrow_check/nll/constraints/graph.rs index fe9ccb489e425..2479dfd1c7093 100644 --- a/src/librustc_mir/borrow_check/nll/constraints/graph.rs +++ b/src/librustc_mir/borrow_check/nll/constraints/graph.rs @@ -1,6 +1,6 @@ -use borrow_check::nll::type_check::Locations; -use borrow_check::nll::constraints::ConstraintIndex; -use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; +use crate::borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::constraints::ConstraintIndex; +use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; use rustc::mir::ConstraintCategory; use rustc::ty::RegionVid; use rustc_data_structures::graph; diff --git a/src/librustc_mir/borrow_check/nll/constraints/mod.rs b/src/librustc_mir/borrow_check/nll/constraints/mod.rs index 146bd65dd1143..d3f9743dfed77 100644 --- a/src/librustc_mir/borrow_check/nll/constraints/mod.rs +++ b/src/librustc_mir/borrow_check/nll/constraints/mod.rs @@ -2,7 +2,7 @@ use rustc::mir::ConstraintCategory; use rustc::ty::RegionVid; use rustc_data_structures::graph::scc::Sccs; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::type_check::Locations; use std::fmt; use std::ops::Deref; @@ -84,7 +84,7 @@ pub struct OutlivesConstraint { } impl fmt::Debug for OutlivesConstraint { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { write!( formatter, "({:?}: {:?}) due to {:?}", diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs index 53035dae4f35c..c5aaf5b811ed7 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs @@ -1,13 +1,13 @@ use std::collections::VecDeque; use std::rc::Rc; -use borrow_check::nll::region_infer::{Cause, RegionInferenceContext}; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext}; +use crate::borrow_check::nll::ToRegionVid; +use crate::util::liveness::{self, DefUse}; use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor}; use rustc::mir::{Local, Location, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::fx::FxHashSet; -use util::liveness::{self, DefUse}; crate fn find<'tcx>( mir: &Mir<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs index 968c0f53a4852..8e57d107aa61e 100644 --- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs +++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs @@ -1,8 +1,8 @@ -use borrow_check::borrow_set::BorrowData; -use borrow_check::error_reporting::UseSpans; -use borrow_check::nll::ConstraintDescription; -use borrow_check::nll::region_infer::{Cause, RegionName}; -use borrow_check::{Context, MirBorrowckCtxt, WriteKind}; +use crate::borrow_check::borrow_set::BorrowData; +use crate::borrow_check::error_reporting::UseSpans; +use crate::borrow_check::nll::ConstraintDescription; +use crate::borrow_check::nll::region_infer::{Cause, RegionName}; +use crate::borrow_check::{Context, MirBorrowckCtxt, WriteKind}; use rustc::ty::{self, TyCtxt}; use rustc::mir::{ CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand, @@ -14,7 +14,7 @@ use syntax_pos::Span; mod find_use; -pub(in borrow_check) enum BorrowExplanation { +pub(in crate::borrow_check) enum BorrowExplanation { UsedLater(LaterUseKind, Span), UsedLaterInLoop(LaterUseKind, Span), UsedLaterWhenDropped { @@ -33,7 +33,7 @@ pub(in borrow_check) enum BorrowExplanation { } #[derive(Clone, Copy)] -pub(in borrow_check) enum LaterUseKind { +pub(in crate::borrow_check) enum LaterUseKind { TraitCapture, ClosureCapture, Call, @@ -42,13 +42,13 @@ pub(in borrow_check) enum LaterUseKind { } impl BorrowExplanation { - pub(in borrow_check) fn is_explained(&self) -> bool { + pub(in crate::borrow_check) fn is_explained(&self) -> bool { match self { BorrowExplanation::Unexplained => false, _ => true, } } - pub(in borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>( + pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>( &self, tcx: TyCtxt<'cx, 'gcx, 'tcx>, mir: &Mir<'tcx>, @@ -187,7 +187,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// - second half is the place being accessed /// /// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points - pub(in borrow_check) fn explain_why_borrow_contains_point( + pub(in crate::borrow_check) fn explain_why_borrow_contains_point( &self, context: Context, borrow: &BorrowData<'tcx>, diff --git a/src/librustc_mir/borrow_check/nll/facts.rs b/src/librustc_mir/borrow_check/nll/facts.rs index bc33a1c9c65aa..9672d3e78cd50 100644 --- a/src/librustc_mir/borrow_check/nll/facts.rs +++ b/src/librustc_mir/borrow_check/nll/facts.rs @@ -1,5 +1,5 @@ -use borrow_check::location::{LocationIndex, LocationTable}; -use dataflow::indexes::BorrowIndex; +use crate::borrow_check::location::{LocationIndex, LocationTable}; +use crate::dataflow::indexes::BorrowIndex; use polonius_engine::AllFacts as PoloniusAllFacts; use polonius_engine::Atom; use rustc::ty::{RegionVid, TyCtxt}; diff --git a/src/librustc_mir/borrow_check/nll/invalidation.rs b/src/librustc_mir/borrow_check/nll/invalidation.rs index 112b39952559b..3df6b797a44fb 100644 --- a/src/librustc_mir/borrow_check/nll/invalidation.rs +++ b/src/librustc_mir/borrow_check/nll/invalidation.rs @@ -1,15 +1,15 @@ -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::LocationTable; -use borrow_check::{JustWrite, WriteAndRead}; -use borrow_check::{AccessDepth, Deep, Shallow}; -use borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write}; -use borrow_check::{Context, ContextKind}; -use borrow_check::{LocalMutationIsAllowed, MutateMode}; -use borrow_check::ArtificialField; -use borrow_check::{ReadKind, WriteKind}; -use borrow_check::nll::facts::AllFacts; -use borrow_check::path_utils::*; -use dataflow::move_paths::indexes::BorrowIndex; +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::{JustWrite, WriteAndRead}; +use crate::borrow_check::{AccessDepth, Deep, Shallow}; +use crate::borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write}; +use crate::borrow_check::{Context, ContextKind}; +use crate::borrow_check::{LocalMutationIsAllowed, MutateMode}; +use crate::borrow_check::ArtificialField; +use crate::borrow_check::{ReadKind, WriteKind}; +use crate::borrow_check::nll::facts::AllFacts; +use crate::borrow_check::path_utils::*; +use crate::dataflow::move_paths::indexes::BorrowIndex; use rustc::ty::TyCtxt; use rustc::mir::visit::Visitor; use rustc::mir::{BasicBlock, Location, Mir, Place, Rvalue}; diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index a092c3b8ecde2..128d54c9f49d7 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -1,13 +1,14 @@ -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::{LocationIndex, LocationTable}; -use borrow_check::nll::facts::AllFactsExt; -use borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints}; -use borrow_check::nll::type_check::liveness::liveness_map::NllLivenessMap; -use borrow_check::nll::region_infer::values::RegionValueElements; -use dataflow::indexes::BorrowIndex; -use dataflow::move_paths::MoveData; -use dataflow::FlowAtLocation; -use dataflow::MaybeInitializedPlaces; +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::{LocationIndex, LocationTable}; +use crate::borrow_check::nll::facts::AllFactsExt; +use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::type_check::liveness::liveness_map::NllLivenessMap; +use crate::borrow_check::nll::region_infer::values::RegionValueElements; +use crate::dataflow::indexes::BorrowIndex; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::FlowAtLocation; +use crate::dataflow::MaybeInitializedPlaces; +use crate::transform::MirSource; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir}; @@ -19,12 +20,11 @@ use std::io; use std::path::PathBuf; use std::rc::Rc; use std::str::FromStr; -use transform::MirSource; use self::mir_util::PassWhere; use polonius_engine::{Algorithm, Output}; -use util as mir_util; -use util::pretty; +use crate::util as mir_util; +use crate::util::pretty; mod constraint_generation; pub mod explain_borrow; @@ -45,7 +45,7 @@ use self::universal_regions::UniversalRegions; /// scraping out the set of universal regions (e.g., region parameters) /// declared on the function. That set will need to be given to /// `compute_regions`. -pub(in borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( +pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( infcx: &InferCtxt<'cx, 'gcx, 'tcx>, def_id: DefId, param_env: ty::ParamEnv<'tcx>, @@ -68,7 +68,7 @@ pub(in borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>( /// Computes the (non-lexical) regions from the input MIR. /// /// This may result in errors being reported. -pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( +pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>( infcx: &InferCtxt<'cx, 'gcx, 'tcx>, def_id: DefId, universal_regions: UniversalRegions<'tcx>, @@ -211,8 +211,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( infcx: &InferCtxt<'a, 'gcx, 'tcx>, source: MirSource, mir: &Mir<'tcx>, - regioncx: &RegionInferenceContext, - closure_region_requirements: &Option, + regioncx: &RegionInferenceContext<'_>, + closure_region_requirements: &Option>, ) { if !mir_util::dump_enabled(infcx.tcx, "nll", source) { return; @@ -273,7 +273,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>( mir: &Mir<'tcx>, mir_def_id: DefId, regioncx: &RegionInferenceContext<'tcx>, - closure_region_requirements: &Option, + closure_region_requirements: &Option>, errors_buffer: &mut Vec, ) { let tcx = infcx.tcx; @@ -322,7 +322,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>( } fn for_each_region_constraint( - closure_region_requirements: &ClosureRegionRequirements, + closure_region_requirements: &ClosureRegionRequirements<'_>, with_msg: &mut dyn FnMut(&str) -> io::Result<()>, ) -> io::Result<()> { for req in &closure_region_requirements.outlives_requirements { diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index 550668a7ceece..3498e3437676c 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -1,8 +1,9 @@ -use borrow_check::nll::constraints::OutlivesConstraint; -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::type_check::Locations; -use borrow_check::nll::universal_regions::DefiningTy; -use borrow_check::nll::ConstraintDescription; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::universal_regions::DefiningTy; +use crate::borrow_check::nll::ConstraintDescription; +use crate::util::borrowck_errors::{BorrowckErrors, Origin}; use rustc::hir::def_id::DefId; use rustc::infer::error_reporting::nice_region_error::NiceRegionError; use rustc::infer::InferCtxt; @@ -15,7 +16,6 @@ use std::collections::VecDeque; use syntax::errors::Applicability; use syntax::symbol::keywords; use syntax_pos::Span; -use util::borrowck_errors::{BorrowckErrors, Origin}; mod region_name; mod var_name; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs index bff8015511242..2c4f359f65fa5 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs @@ -1,7 +1,7 @@ use std::fmt::{self, Display}; -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::universal_regions::DefiningTy; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::universal_regions::DefiningTy; +use crate::borrow_check::nll::ToRegionVid; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::infer::InferCtxt; @@ -109,7 +109,7 @@ impl RegionName { } impl Display for RegionName { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.name) } } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs index c2f2e99c0a55b..bd7b8829c7b4f 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs @@ -1,5 +1,5 @@ -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::ToRegionVid; use rustc::mir::{Local, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::indexed_vec::Idx; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs index 2da158be432be..cffc66ac7ddfd 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs @@ -3,8 +3,7 @@ //! data to rendered labels. use super::*; -use borrow_check::nll::constraints::OutlivesConstraint; -use dot; +use crate::borrow_check::nll::constraints::OutlivesConstraint; use std::borrow::Cow; use std::io::{self, Write}; diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs index fee5dc8646587..7fe657702d756 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs @@ -1,9 +1,11 @@ use super::universal_regions::UniversalRegions; -use borrow_check::nll::constraints::graph::NormalConstraintGraph; -use borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint}; -use borrow_check::nll::region_infer::values::{PlaceholderIndices, RegionElement, ToElementIndex}; -use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations; -use borrow_check::nll::type_check::Locations; +use crate::borrow_check::nll::constraints::graph::NormalConstraintGraph; +use crate::borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint}; +use crate::borrow_check::nll::region_infer::values::{ + PlaceholderIndices, RegionElement, ToElementIndex +}; +use crate::borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations; +use crate::borrow_check::nll::type_check::Locations; use rustc::hir::def_id::DefId; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::region_constraints::{GenericKind, VarInfos, VerifyBound}; diff --git a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs index b7555e57a62bb..1a72205ad7ae1 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs @@ -1,8 +1,8 @@ -use borrow_check::nll::constraints::OutlivesConstraint; -use borrow_check::nll::region_infer::TypeTest; -use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; -use borrow_check::nll::universal_regions::UniversalRegions; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::region_infer::TypeTest; +use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::universal_regions::UniversalRegions; +use crate::borrow_check::nll::ToRegionVid; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::outlives::env::RegionBoundPairs; use rustc::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate}; diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs index b19dc9091cb86..f549aea81f69f 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs @@ -1,7 +1,7 @@ -use borrow_check::nll::type_check::constraint_conversion; -use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; -use borrow_check::nll::universal_regions::UniversalRegions; -use borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::type_check::constraint_conversion; +use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints}; +use crate::borrow_check::nll::universal_regions::UniversalRegions; +use crate::borrow_check::nll::ToRegionVid; use rustc::infer::canonical::QueryRegionConstraint; use rustc::infer::outlives::free_region_map::FreeRegionRelations; use rustc::infer::region_constraints::GenericKind; diff --git a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs index ef0f7e1b217a9..50828c294fa1b 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/input_output.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/input_output.rs @@ -7,7 +7,7 @@ //! `RETURN_PLACE` the MIR arguments) are always fully normalized (and //! contain revealed `impl Trait` values). -use borrow_check::nll::universal_regions::UniversalRegions; +use crate::borrow_check::nll::universal_regions::UniversalRegions; use rustc::infer::LateBoundRegionConversionTime; use rustc::mir::*; use rustc::ty::Ty; diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs index dda74e6a6a688..5e2e4407cbecd 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs @@ -6,13 +6,13 @@ //! liveness code so that it only operates over variables with regions in their //! types, instead of all variables. -use borrow_check::nll::ToRegionVid; -use borrow_check::nll::facts::{AllFacts, AllFactsExt}; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::nll::facts::{AllFacts, AllFactsExt}; +use crate::util::liveness::LiveVariableMap; use rustc::mir::{Local, Mir}; use rustc::ty::{RegionVid, TyCtxt}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use util::liveness::LiveVariableMap; /// Map between Local and LiveVar indices: the purpose of this /// map is to define the subset of local variables for which we need diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs index 3f13cc8b64778..e9765d2798cd7 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs @@ -1,10 +1,10 @@ -use borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements}; -use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; +use crate::borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements}; +use crate::borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; +use crate::util::liveness::{categorize, DefUse, LiveVariableMap}; use rustc::mir::visit::{PlaceContext, Visitor}; use rustc::mir::{Local, Location, Mir}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::vec_linked_list as vll; -use util::liveness::{categorize, DefUse, LiveVariableMap}; /// A map that cross references each local with the locations where it /// is defined (assigned), used, or dropped. Used during liveness diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs index 633695a9b9ce5..a5510ba6936cc 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs @@ -1,11 +1,11 @@ -use borrow_check::location::LocationTable; -use borrow_check::nll::region_infer::values::RegionValueElements; -use borrow_check::nll::constraints::ConstraintSet; -use borrow_check::nll::NllLivenessMap; -use borrow_check::nll::universal_regions::UniversalRegions; -use dataflow::move_paths::MoveData; -use dataflow::MaybeInitializedPlaces; -use dataflow::FlowAtLocation; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::region_infer::values::RegionValueElements; +use crate::borrow_check::nll::constraints::ConstraintSet; +use crate::borrow_check::nll::NllLivenessMap; +use crate::borrow_check::nll::universal_regions::UniversalRegions; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::MaybeInitializedPlaces; +use crate::dataflow::FlowAtLocation; use rustc::mir::Mir; use rustc::ty::RegionVid; use rustc_data_structures::fx::FxHashSet; diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index 77e8dd9d130e3..d058be03f55e6 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -1,12 +1,13 @@ -use borrow_check::location::LocationTable; -use borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements}; -use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; -use borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap; -use borrow_check::nll::type_check::NormalizeLocation; -use borrow_check::nll::type_check::TypeChecker; -use dataflow::move_paths::indexes::MovePathIndex; -use dataflow::move_paths::MoveData; -use dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces}; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements}; +use crate::borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap}; +use crate::borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap; +use crate::borrow_check::nll::type_check::NormalizeLocation; +use crate::borrow_check::nll::type_check::TypeChecker; +use crate::dataflow::move_paths::indexes::MovePathIndex; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces}; +use crate::util::liveness::LiveVariableMap; use rustc::infer::canonical::QueryRegionConstraint; use rustc::mir::{BasicBlock, ConstraintCategory, Local, Location, Mir}; use rustc::traits::query::dropck_outlives::DropckOutlivesResult; @@ -16,7 +17,6 @@ use rustc::ty::{Ty, TypeFoldable}; use rustc_data_structures::bit_set::HybridBitSet; use rustc_data_structures::fx::FxHashMap; use std::rc::Rc; -use util::liveness::LiveVariableMap; /// This is the heart of the liveness computation. For each variable X /// that requires a liveness computation, it walks over all the uses diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 3e6aa358ee0d1..19ff47f9c390d 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -2,24 +2,25 @@ #![allow(unreachable_code)] -use borrow_check::borrow_set::BorrowSet; -use borrow_check::location::LocationTable; -use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; -use borrow_check::nll::facts::AllFacts; -use borrow_check::nll::region_infer::values::LivenessValues; -use borrow_check::nll::region_infer::values::PlaceholderIndex; -use borrow_check::nll::region_infer::values::PlaceholderIndices; -use borrow_check::nll::region_infer::values::RegionValueElements; -use borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest}; -use borrow_check::nll::renumber; -use borrow_check::nll::type_check::free_region_relations::{ +use crate::borrow_check::borrow_set::BorrowSet; +use crate::borrow_check::location::LocationTable; +use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint}; +use crate::borrow_check::nll::facts::AllFacts; +use crate::borrow_check::nll::region_infer::values::LivenessValues; +use crate::borrow_check::nll::region_infer::values::PlaceholderIndex; +use crate::borrow_check::nll::region_infer::values::PlaceholderIndices; +use crate::borrow_check::nll::region_infer::values::RegionValueElements; +use crate::borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest}; +use crate::borrow_check::nll::renumber; +use crate::borrow_check::nll::type_check::free_region_relations::{ CreateResult, UniversalRegionRelations, }; -use borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions}; -use borrow_check::nll::ToRegionVid; -use dataflow::move_paths::MoveData; -use dataflow::FlowAtLocation; -use dataflow::MaybeInitializedPlaces; +use crate::borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions}; +use crate::borrow_check::nll::ToRegionVid; +use crate::dataflow::move_paths::MoveData; +use crate::dataflow::FlowAtLocation; +use crate::dataflow::MaybeInitializedPlaces; +use crate::transform::{MirPass, MirSource}; use either::Either; use rustc::hir; use rustc::hir::def_id::DefId; @@ -46,7 +47,6 @@ use rustc::ty::layout::VariantIdx; use std::rc::Rc; use std::{fmt, iter}; use syntax_pos::{Span, DUMMY_SP}; -use transform::{MirPass, MirSource}; macro_rules! span_mirbug { ($context:expr, $elem:expr, $($message:tt)*) => ({ @@ -210,7 +210,7 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>( extra(&mut checker) } -fn translate_outlives_facts(cx: &mut BorrowCheckContext) { +fn translate_outlives_facts(cx: &mut BorrowCheckContext<'_, '_>) { if let Some(facts) = cx.all_facts { let location_table = cx.location_table; facts @@ -235,7 +235,7 @@ fn translate_outlives_facts(cx: &mut BorrowCheckContext) { } } -fn mirbug(tcx: TyCtxt, span: Span, msg: &str) { +fn mirbug(tcx: TyCtxt<'_, '_, '_>, span: Span, msg: &str) { // We sometimes see MIR failures (notably predicate failures) due to // the fact that we check rvalue sized predicates here. So use `delay_span_bug` // to avoid reporting bugs in those cases. @@ -266,7 +266,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> { } } - fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { + fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext<'_>, location: Location) { self.sanitize_place(place, location, context); } @@ -447,7 +447,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { &mut self, place: &Place<'tcx>, location: Location, - context: PlaceContext, + context: PlaceContext<'_>, ) -> PlaceTy<'tcx> { debug!("sanitize_place: {:?}", place); let place_ty = match *place { diff --git a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs index 74ad7d988cc1a..1748e30089021 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs @@ -1,5 +1,5 @@ -use borrow_check::nll::constraints::OutlivesConstraint; -use borrow_check::nll::type_check::{BorrowCheckContext, Locations}; +use crate::borrow_check::nll::constraints::OutlivesConstraint; +use crate::borrow_check::nll::type_check::{BorrowCheckContext, Locations}; use rustc::infer::nll_relate::{TypeRelating, TypeRelatingDelegate, NormalizationStrategy}; use rustc::infer::{InferCtxt, NLLRegionVariableOrigin}; use rustc::mir::ConstraintCategory; diff --git a/src/librustc_mir/borrow_check/path_utils.rs b/src/librustc_mir/borrow_check/path_utils.rs index 6875aced8d231..1cea9f662d351 100644 --- a/src/librustc_mir/borrow_check/path_utils.rs +++ b/src/librustc_mir/borrow_check/path_utils.rs @@ -1,8 +1,8 @@ -use borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation}; -use borrow_check::places_conflict; -use borrow_check::Context; -use borrow_check::AccessDepth; -use dataflow::indexes::BorrowIndex; +use crate::borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation}; +use crate::borrow_check::places_conflict; +use crate::borrow_check::Context; +use crate::borrow_check::AccessDepth; +use crate::dataflow::indexes::BorrowIndex; use rustc::mir::{BasicBlock, Location, Mir, Place}; use rustc::mir::{ProjectionElem, BorrowKind}; use rustc::ty::TyCtxt; diff --git a/src/librustc_mir/borrow_check/place_ext.rs b/src/librustc_mir/borrow_check/place_ext.rs index 4d0b25b1024a3..bad236a6f5256 100644 --- a/src/librustc_mir/borrow_check/place_ext.rs +++ b/src/librustc_mir/borrow_check/place_ext.rs @@ -2,7 +2,7 @@ use rustc::hir; use rustc::mir::ProjectionElem; use rustc::mir::{Local, Mir, Place, Mutability}; use rustc::ty::{self, TyCtxt}; -use borrow_check::borrow_set::LocalsStateAtExit; +use crate::borrow_check::borrow_set::LocalsStateAtExit; /// Extension methods for the `Place` type. crate trait PlaceExt<'tcx> { diff --git a/src/librustc_mir/borrow_check/places_conflict.rs b/src/librustc_mir/borrow_check/places_conflict.rs index ac7182abb36da..cd33f22bf3cb7 100644 --- a/src/librustc_mir/borrow_check/places_conflict.rs +++ b/src/librustc_mir/borrow_check/places_conflict.rs @@ -1,6 +1,6 @@ -use borrow_check::ArtificialField; -use borrow_check::Overlap; -use borrow_check::{Deep, Shallow, AccessDepth}; +use crate::borrow_check::ArtificialField; +use crate::borrow_check::Overlap; +use crate::borrow_check::{Deep, Shallow, AccessDepth}; use rustc::hir; use rustc::mir::{BorrowKind, Mir, Place}; use rustc::mir::{Projection, ProjectionElem}; diff --git a/src/librustc_mir/borrow_check/used_muts.rs b/src/librustc_mir/borrow_check/used_muts.rs index 0ff7ff4de10de..8c7359bdee768 100644 --- a/src/librustc_mir/borrow_check/used_muts.rs +++ b/src/librustc_mir/borrow_check/used_muts.rs @@ -3,7 +3,7 @@ use rustc::mir::{BasicBlock, Local, Location, Place, Statement, StatementKind, T use rustc_data_structures::fx::FxHashSet; -use borrow_check::MirBorrowckCtxt; +use crate::borrow_check::MirBorrowckCtxt; impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { /// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes diff --git a/src/librustc_mir/build/block.rs b/src/librustc_mir/build/block.rs index f3d89a7a02515..7d93e131a6ca9 100644 --- a/src/librustc_mir/build/block.rs +++ b/src/librustc_mir/build/block.rs @@ -1,7 +1,7 @@ -use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use build::ForGuard::OutsideGuard; -use build::matches::ArmHasGuard; -use hair::*; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::build::ForGuard::OutsideGuard; +use crate::build::matches::ArmHasGuard; +use crate::hair::*; use rustc::mir::*; use rustc::hir; use syntax_pos::Span; diff --git a/src/librustc_mir/build/cfg.rs b/src/librustc_mir/build/cfg.rs index a9e468db1d1b7..778d1e71cedfc 100644 --- a/src/librustc_mir/build/cfg.rs +++ b/src/librustc_mir/build/cfg.rs @@ -1,6 +1,6 @@ //! Routines for manipulating the control-flow graph. -use build::CFG; +use crate::build::CFG; use rustc::mir::*; impl<'tcx> CFG<'tcx> { diff --git a/src/librustc_mir/build/expr/as_constant.rs b/src/librustc_mir/build/expr/as_constant.rs index 31e0c0daa3fa6..614668170d5be 100644 --- a/src/librustc_mir/build/expr/as_constant.rs +++ b/src/librustc_mir/build/expr/as_constant.rs @@ -1,7 +1,7 @@ //! See docs in build/expr/mod.rs -use build::Builder; -use hair::*; +use crate::build::Builder; +use crate::hair::*; use rustc::mir::*; use rustc::ty::CanonicalUserTypeAnnotation; diff --git a/src/librustc_mir/build/expr/as_operand.rs b/src/librustc_mir/build/expr/as_operand.rs index 1f653575a7fbf..38fae8539c8d7 100644 --- a/src/librustc_mir/build/expr/as_operand.rs +++ b/src/librustc_mir/build/expr/as_operand.rs @@ -1,8 +1,8 @@ //! See docs in build/expr/mod.rs -use build::expr::category::Category; -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::expr::category::Category; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::middle::region; use rustc::mir::*; diff --git a/src/librustc_mir/build/expr/as_place.rs b/src/librustc_mir/build/expr/as_place.rs index 6bd61ab53fd21..ed444191226a1 100644 --- a/src/librustc_mir/build/expr/as_place.rs +++ b/src/librustc_mir/build/expr/as_place.rs @@ -1,9 +1,9 @@ //! See docs in build/expr/mod.rs -use build::expr::category::Category; -use build::ForGuard::{OutsideGuard, RefWithinGuard}; -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::expr::category::Category; +use crate::build::ForGuard::{OutsideGuard, RefWithinGuard}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::mir::interpret::EvalErrorKind::BoundsCheck; use rustc::mir::*; use rustc::ty::{CanonicalUserTypeAnnotation, Variance}; diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 3de2f47578650..06658675f70f4 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -3,9 +3,9 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; -use build::expr::category::{Category, RvalueFunc}; -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::middle::region; use rustc::mir::interpret::EvalErrorKind; use rustc::mir::*; diff --git a/src/librustc_mir/build/expr/as_temp.rs b/src/librustc_mir/build/expr/as_temp.rs index df271ff6e4016..efa1a4895e0c0 100644 --- a/src/librustc_mir/build/expr/as_temp.rs +++ b/src/librustc_mir/build/expr/as_temp.rs @@ -1,7 +1,7 @@ //! See docs in build/expr/mod.rs -use build::{BlockAnd, BlockAndExtension, Builder}; -use hair::*; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::hair::*; use rustc::middle::region; use rustc::mir::*; diff --git a/src/librustc_mir/build/expr/category.rs b/src/librustc_mir/build/expr/category.rs index 53f84a495696c..ca7d435e62229 100644 --- a/src/librustc_mir/build/expr/category.rs +++ b/src/librustc_mir/build/expr/category.rs @@ -1,4 +1,4 @@ -use hair::*; +use crate::hair::*; #[derive(Debug, PartialEq)] pub enum Category { diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 2ffff68137dd2..05231bc7b3f16 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -1,8 +1,8 @@ //! See docs in build/expr/mod.rs -use build::expr::category::{Category, RvalueFunc}; -use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use hair::*; +use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::hair::*; use rustc::mir::*; use rustc::ty; diff --git a/src/librustc_mir/build/expr/stmt.rs b/src/librustc_mir/build/expr/stmt.rs index 1cbc60586c356..aadc2368f5aec 100644 --- a/src/librustc_mir/build/expr/stmt.rs +++ b/src/librustc_mir/build/expr/stmt.rs @@ -1,6 +1,6 @@ -use build::scope::BreakableScope; -use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; -use hair::*; +use crate::build::scope::BreakableScope; +use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; +use crate::hair::*; use rustc::mir::*; impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { diff --git a/src/librustc_mir/build/into.rs b/src/librustc_mir/build/into.rs index 1b29126082067..67b6540febea8 100644 --- a/src/librustc_mir/build/into.rs +++ b/src/librustc_mir/build/into.rs @@ -4,11 +4,11 @@ //! wrapped up as expressions (e.g., blocks). To make this ergonomic, we use this //! latter `EvalInto` trait. -use build::{BlockAnd, Builder}; -use hair::*; +use crate::build::{BlockAnd, Builder}; +use crate::hair::*; use rustc::mir::*; -pub(in build) trait EvalInto<'tcx> { +pub(in crate::build) trait EvalInto<'tcx> { fn eval_into<'a, 'gcx>(self, builder: &mut Builder<'a, 'gcx, 'tcx>, destination: &Place<'tcx>, diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 2f1e8c03f2f7e..cf051ba2e0fa6 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -3,11 +3,11 @@ //! includes the high-level algorithm, the submodules contain the //! details. -use build::scope::{CachedBlock, DropKind}; -use build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard}; -use build::{BlockAnd, BlockAndExtension, Builder}; -use build::{GuardFrame, GuardFrameLocal, LocalsForNode}; -use hair::*; +use crate::build::scope::{CachedBlock, DropKind}; +use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard}; +use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode}; +use crate::hair::*; use rustc::mir::*; use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty}; use rustc::ty::layout::VariantIdx; diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs index c219fd2218223..6be9ccb27036e 100644 --- a/src/librustc_mir/build/matches/simplify.rs +++ b/src/librustc_mir/build/matches/simplify.rs @@ -12,9 +12,9 @@ //! sort of test: for example, testing which variant an enum is, or //! testing a value against a constant. -use build::Builder; -use build::matches::{Ascription, Binding, MatchPair, Candidate}; -use hair::*; +use crate::build::Builder; +use crate::build::matches::{Ascription, Binding, MatchPair, Candidate}; +use crate::hair::*; use rustc::ty; use rustc::ty::layout::{Integer, IntegerExt, Size}; use syntax::attr::{SignedInt, UnsignedInt}; diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 696c173b048ad..395858c07b606 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -5,10 +5,10 @@ // identify what tests are needed, perform the tests, and then filter // the candidates based on the result. -use build::Builder; -use build::matches::{Candidate, MatchPair, Test, TestKind}; -use hair::*; -use hair::pattern::compare_const_vals; +use crate::build::Builder; +use crate::build::matches::{Candidate, MatchPair, Test, TestKind}; +use crate::hair::*; +use crate::hair::pattern::compare_const_vals; use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::fx::FxHashMap; use rustc::ty::{self, Ty}; diff --git a/src/librustc_mir/build/matches/util.rs b/src/librustc_mir/build/matches/util.rs index b5a1a388e9cbc..ed12c1b3bc9c1 100644 --- a/src/librustc_mir/build/matches/util.rs +++ b/src/librustc_mir/build/matches/util.rs @@ -1,6 +1,6 @@ -use build::Builder; -use build::matches::MatchPair; -use hair::*; +use crate::build::Builder; +use crate::build::matches::MatchPair; +use crate::hair::*; use rustc::mir::*; use std::u32; use std::convert::TryInto; diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index c849c02242840..1634c36d34acf 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -1,7 +1,7 @@ //! Miscellaneous builder routines that are not specific to building any particular //! kind of thing. -use build::Builder; +use crate::build::Builder; use rustc::ty::{self, Ty}; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index f38648fda0e36..a52b032aeb508 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -1,7 +1,10 @@ -use build; -use build::scope::{CachedBlock, DropKind}; -use hair::cx::Cx; -use hair::{LintLevel, BindingMode, PatternKind}; +use crate::build; +use crate::build::scope::{CachedBlock, DropKind}; +use crate::hair::cx::Cx; +use crate::hair::{LintLevel, BindingMode, PatternKind}; +use crate::shim; +use crate::transform::MirSource; +use crate::util as mir_util; use rustc::hir; use rustc::hir::Node; use rustc::hir::def_id::DefId; @@ -13,7 +16,6 @@ use rustc::ty::subst::Substs; use rustc::util::nodemap::NodeMap; use rustc_target::spec::PanicStrategy; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -use shim; use std::mem; use std::u32; use rustc_target::spec::abi::Abi; @@ -21,8 +23,6 @@ use syntax::ast; use syntax::attr::{self, UnwindAttr}; use syntax::symbol::keywords; use syntax_pos::Span; -use transform::MirSource; -use util as mir_util; use super::lints; @@ -161,7 +161,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t }; globalizer.visit_mir(&mut mir); let mir = unsafe { - mem::transmute::>(mir) + mem::transmute::, Mir<'tcx>>(mir) }; mir_util::dump_mir(tcx, None, "mir_map", &0, @@ -241,7 +241,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; globalizer.visit_mir(&mut mir); let mir = unsafe { - mem::transmute::>(mir) + mem::transmute::, Mir<'tcx>>(mir) }; mir_util::dump_mir(tcx, None, "mir_map", &0, diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index 78abba5f885b2..3872f5db26278 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -77,8 +77,8 @@ should go to. */ -use build::{BlockAnd, BlockAndExtension, Builder, CFG}; -use hair::LintLevel; +use crate::build::{BlockAnd, BlockAndExtension, Builder, CFG}; +use crate::hair::LintLevel; use rustc::middle::region; use rustc::ty::Ty; use rustc::hir; diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index f83a930353b73..d1b4486dd9345 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -190,7 +190,7 @@ enum ConstEvalError { } impl fmt::Display for ConstEvalError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::ConstEvalError::*; match *self { NeedsRfc(ref msg) => { diff --git a/src/librustc_mir/dataflow/at_location.rs b/src/librustc_mir/dataflow/at_location.rs index 375bc4fead443..d0b9fbc99f03f 100644 --- a/src/librustc_mir/dataflow/at_location.rs +++ b/src/librustc_mir/dataflow/at_location.rs @@ -4,8 +4,8 @@ use rustc::mir::{BasicBlock, Location}; use rustc_data_structures::bit_set::{BitIter, BitSet, HybridBitSet}; -use dataflow::{BitDenotation, BlockSets, DataflowResults}; -use dataflow::move_paths::{HasMoveData, MovePathIndex}; +use crate::dataflow::{BitDenotation, BlockSets, DataflowResults}; +use crate::dataflow::move_paths::{HasMoveData, MovePathIndex}; use std::iter; @@ -115,7 +115,7 @@ where } /// Returns an iterator over the elements present in the current state. - pub fn iter_incoming(&self) -> iter::Peekable> { + pub fn iter_incoming(&self) -> iter::Peekable> { self.curr_state.iter().peekable() } @@ -124,7 +124,7 @@ where /// Invokes `f` with an iterator over the resulting state. pub fn with_iter_outgoing(&self, f: F) where - F: FnOnce(BitIter), + F: FnOnce(BitIter<'_, BD::Idx>), { let mut curr_state = self.curr_state.clone(); curr_state.union(&self.stmt_gen); diff --git a/src/librustc_mir/dataflow/drop_flag_effects.rs b/src/librustc_mir/dataflow/drop_flag_effects.rs index 22fb7a3bc470e..49499cf928d74 100644 --- a/src/librustc_mir/dataflow/drop_flag_effects.rs +++ b/src/librustc_mir/dataflow/drop_flag_effects.rs @@ -1,6 +1,6 @@ use rustc::mir::{self, Mir, Location}; use rustc::ty::{self, TyCtxt}; -use util::elaborate_drops::DropFlagState; +use crate::util::elaborate_drops::DropFlagState; use super::{MoveDataParamEnv}; use super::indexes::MovePathIndex; diff --git a/src/librustc_mir/dataflow/graphviz.rs b/src/librustc_mir/dataflow/graphviz.rs index 34752baa020e2..9d9f18d4b0dcf 100644 --- a/src/librustc_mir/dataflow/graphviz.rs +++ b/src/librustc_mir/dataflow/graphviz.rs @@ -3,8 +3,6 @@ use syntax::ast::NodeId; use rustc::mir::{BasicBlock, Mir}; -use dot; - use std::fs; use std::io; use std::marker::PhantomData; @@ -59,7 +57,7 @@ pub type Node = BasicBlock; #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub struct Edge { source: BasicBlock, index: usize } -fn outgoing(mir: &Mir, bb: BasicBlock) -> Vec { +fn outgoing(mir: &Mir<'_>, bb: BasicBlock) -> Vec { (0..mir[bb].terminator().successors().count()) .map(|index| Edge { source: bb, index: index}).collect() } @@ -70,18 +68,18 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P> { type Node = Node; type Edge = Edge; - fn graph_id(&self) -> dot::Id { + fn graph_id(&self) -> dot::Id<'_> { dot::Id::new(format!("graph_for_node_{}", self.mbcx.node_id())) .unwrap() } - fn node_id(&self, n: &Node) -> dot::Id { + fn node_id(&self, n: &Node) -> dot::Id<'_> { dot::Id::new(format!("bb_{}", n.index())) .unwrap() } - fn node_label(&self, n: &Node) -> dot::LabelText { + fn node_label(&self, n: &Node) -> dot::LabelText<'_> { // Node label is something like this: // +---------+----------------------------------+------------------+------------------+ // | ENTRY | MIR | GEN | KILL | @@ -105,7 +103,7 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P> } - fn node_shape(&self, _n: &Node) -> Option { + fn node_shape(&self, _n: &Node) -> Option> { Some(dot::LabelText::label("none")) } @@ -125,7 +123,7 @@ where MWF: MirWithFlowState<'tcx>, n: &Node, w: &mut W, block: BasicBlock, - mir: &Mir) -> io::Result<()> { + mir: &Mir<'_>) -> io::Result<()> { // Header rows const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"]; const HDR_FMT: &str = "bgcolor=\"grey\""; @@ -150,7 +148,7 @@ where MWF: MirWithFlowState<'tcx>, n: &Node, w: &mut W, block: BasicBlock, - mir: &Mir) + mir: &Mir<'_>) -> io::Result<()> { let i = n.index(); @@ -200,7 +198,7 @@ where MWF: MirWithFlowState<'tcx>, n: &Node, w: &mut W, block: BasicBlock, - mir: &Mir) + mir: &Mir<'_>) -> io::Result<()> { let i = n.index(); @@ -241,7 +239,7 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P> { type Node = Node; type Edge = Edge; - fn nodes(&self) -> dot::Nodes { + fn nodes(&self) -> dot::Nodes<'_, Node> { self.mbcx.mir() .basic_blocks() .indices() @@ -249,7 +247,7 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P> .into() } - fn edges(&self) -> dot::Edges { + fn edges(&self) -> dot::Edges<'_, Edge> { let mir = self.mbcx.mir(); mir.basic_blocks() diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index 9d03e35a35069..51d628ce6c5c2 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -2,7 +2,7 @@ pub use super::*; use rustc::mir::*; use rustc::mir::visit::Visitor; -use dataflow::BitDenotation; +use crate::dataflow::BitDenotation; /// This calculates if any part of a MIR local could have previously been borrowed. /// This means that once a local has been borrowed, its bit will be set @@ -38,7 +38,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> { } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Local>, loc: Location) { let stmt = &self.mir[loc.block].statements[loc.statement_index]; @@ -54,7 +54,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> { } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Local>, loc: Location) { BorrowedLocalsVisitor { sets, diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 72218e29cfd20..beb0b3187082b 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -1,5 +1,5 @@ -use borrow_check::borrow_set::{BorrowSet, BorrowData}; -use borrow_check::place_ext::PlaceExt; +use crate::borrow_check::borrow_set::{BorrowSet, BorrowData}; +use crate::borrow_check::place_ext::PlaceExt; use rustc::mir::{self, Location, Place, Mir}; use rustc::ty::TyCtxt; @@ -9,11 +9,11 @@ use rustc_data_structures::bit_set::{BitSet, BitSetOperator}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use dataflow::{BitDenotation, BlockSets, InitialFlow}; -pub use dataflow::indexes::BorrowIndex; -use borrow_check::nll::region_infer::RegionInferenceContext; -use borrow_check::nll::ToRegionVid; -use borrow_check::places_conflict; +use crate::dataflow::{BitDenotation, BlockSets, InitialFlow}; +pub use crate::dataflow::indexes::BorrowIndex; +use crate::borrow_check::nll::region_infer::RegionInferenceContext; +use crate::borrow_check::nll::ToRegionVid; +use crate::borrow_check::places_conflict; use std::rc::Rc; @@ -163,7 +163,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { /// Add all borrows to the kill set, if those borrows are out of scope at `location`. /// That means they went out of a nonlexical scope fn kill_loans_out_of_scope_at_location(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { // NOTE: The state associated with a given `location` // reflects the dataflow on entry to the statement. @@ -184,7 +184,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { /// Kill any borrows that conflict with `place`. fn kill_borrows_on_place( &self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, place: &Place<'tcx> ) { debug!("kill_borrows_on_place: place={:?}", place); @@ -243,13 +243,13 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { } fn before_statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { debug!("Borrows::before_statement_effect sets: {:?} location: {:?}", sets, location); self.kill_loans_out_of_scope_at_location(sets, location); } - fn statement_effect(&self, sets: &mut BlockSets, location: Location) { + fn statement_effect(&self, sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { debug!("Borrows::statement_effect: sets={:?} location={:?}", sets, location); let block = &self.mir.basic_blocks().get(location.block).unwrap_or_else(|| { @@ -307,13 +307,13 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for Borrows<'a, 'gcx, 'tcx> { } fn before_terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, BorrowIndex>, location: Location) { debug!("Borrows::before_terminator_effect sets: {:?} location: {:?}", sets, location); self.kill_loans_out_of_scope_at_location(sets, location); } - fn terminator_effect(&self, _: &mut BlockSets, _: Location) {} + fn terminator_effect(&self, _: &mut BlockSets<'_, BorrowIndex>, _: Location) {} fn propagate_call_return( &self, diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 1ccda3a12e433..c8965b9f7f4c7 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -9,7 +9,7 @@ use rustc_data_structures::indexed_vec::Idx; use super::MoveDataParamEnv; -use util::elaborate_drops::DropFlagState; +use crate::util::elaborate_drops::DropFlagState; use super::move_paths::{HasMoveData, MoveData, MovePathIndex, InitIndex}; use super::move_paths::{LookupResult, InitKind}; @@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> HasMoveData<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tcx> impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { - fn update_bits(sets: &mut BlockSets, path: MovePathIndex, + fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { match state { @@ -262,7 +262,7 @@ impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> { } impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { - fn update_bits(sets: &mut BlockSets, path: MovePathIndex, + fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { match state { @@ -273,7 +273,7 @@ impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> { } impl<'a, 'gcx, 'tcx> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> { - fn update_bits(sets: &mut BlockSets, path: MovePathIndex, + fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex, state: DropFlagState) { match state { @@ -300,7 +300,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 't } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -311,7 +311,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeInitializedPlaces<'a, 'gcx, 't } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -358,7 +358,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -369,7 +369,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for MaybeUninitializedPlaces<'a, 'gcx, } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -414,7 +414,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'gc } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -425,7 +425,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for DefinitelyInitializedPlaces<'a, 'gc } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, MovePathIndex>, location: Location) { drop_flag_effects_for_location( @@ -464,7 +464,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, InitIndex>, location: Location) { let (_, mir, move_data) = (self.tcx, self.mir, self.move_data()); let stmt = &mir[location.block].statements[location.statement_index]; @@ -511,7 +511,7 @@ impl<'a, 'gcx, 'tcx> BitDenotation<'tcx> for EverInitializedPlaces<'a, 'gcx, 'tc } fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, InitIndex>, location: Location) { let (mir, move_data) = (self.mir, self.move_data()); diff --git a/src/librustc_mir/dataflow/impls/storage_liveness.rs b/src/librustc_mir/dataflow/impls/storage_liveness.rs index 9c17076e6fde0..6b8eb6f17f6c1 100644 --- a/src/librustc_mir/dataflow/impls/storage_liveness.rs +++ b/src/librustc_mir/dataflow/impls/storage_liveness.rs @@ -1,7 +1,7 @@ pub use super::*; use rustc::mir::*; -use dataflow::BitDenotation; +use crate::dataflow::BitDenotation; #[derive(Copy, Clone)] pub struct MaybeStorageLive<'a, 'tcx: 'a> { @@ -31,7 +31,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> { } fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Local>, loc: Location) { let stmt = &self.mir[loc.block].statements[loc.statement_index]; @@ -43,7 +43,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for MaybeStorageLive<'a, 'tcx> { } fn terminator_effect(&self, - _sets: &mut BlockSets, + _sets: &mut BlockSets<'_, Local>, _loc: Location) { // Terminators have no effect } diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index f09db970b7353..1853b60efd7e6 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -58,7 +58,7 @@ impl DebugFormatted { } impl fmt::Debug for DebugFormatted { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { write!(w, "{}", self.0) } } @@ -525,7 +525,7 @@ impl<'a, E:Idx> BlockSets<'a, E> { impl AllSets { pub fn bits_per_block(&self) -> usize { self.bits_per_block } - pub fn for_block(&mut self, block_idx: usize) -> BlockSets { + pub fn for_block(&mut self, block_idx: usize) -> BlockSets<'_, E> { BlockSets { on_entry: &mut self.on_entry_sets[block_idx], gen_set: &mut self.gen_sets[block_idx], @@ -616,7 +616,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// applied, in that order, before moving for the next /// statement. fn before_statement_effect(&self, - _sets: &mut BlockSets, + _sets: &mut BlockSets<'_, Self::Idx>, _location: Location) {} /// Mutates the block-sets (the flow sets for the given @@ -630,7 +630,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// `bb_data` is the sequence of statements identified by `bb` in /// the MIR. fn statement_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Self::Idx>, location: Location); /// Similar to `terminator_effect`, except it applies @@ -645,7 +645,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// applied, in that order, before moving for the next /// terminator. fn before_terminator_effect(&self, - _sets: &mut BlockSets, + _sets: &mut BlockSets<'_, Self::Idx>, _location: Location) {} /// Mutates the block-sets (the flow sets for the given @@ -659,7 +659,7 @@ pub trait BitDenotation<'tcx>: BitSetOperator { /// The effects applied here cannot depend on which branch the /// terminator took. fn terminator_effect(&self, - sets: &mut BlockSets, + sets: &mut BlockSets<'_, Self::Idx>, location: Location); /// Mutates the block-sets according to the (flow-dependent) diff --git a/src/librustc_mir/dataflow/move_paths/mod.rs b/src/librustc_mir/dataflow/move_paths/mod.rs index d77216220ac2b..efd979a7da4fb 100644 --- a/src/librustc_mir/dataflow/move_paths/mod.rs +++ b/src/librustc_mir/dataflow/move_paths/mod.rs @@ -37,7 +37,7 @@ pub(crate) mod indexes { } impl fmt::Debug for $Index { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{}{}", $debug_name, self.index()) } } @@ -62,7 +62,7 @@ pub use self::indexes::MoveOutIndex; pub use self::indexes::InitIndex; impl MoveOutIndex { - pub fn move_path_index(&self, move_data: &MoveData) -> MovePathIndex { + pub fn move_path_index(&self, move_data: &MoveData<'_>) -> MovePathIndex { move_data.moves[*self].path } } @@ -88,7 +88,10 @@ pub struct MovePath<'tcx> { } impl<'tcx> MovePath<'tcx> { - pub fn parents(&self, move_paths: &IndexVec) -> Vec { + pub fn parents( + &self, + move_paths: &IndexVec>, + ) -> Vec { let mut parents = Vec::new(); let mut curr_parent = self.parent; @@ -102,7 +105,7 @@ impl<'tcx> MovePath<'tcx> { } impl<'tcx> fmt::Debug for MovePath<'tcx> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { write!(w, "MovePath {{")?; if let Some(parent) = self.parent { write!(w, " parent: {:?},", parent)?; @@ -118,7 +121,7 @@ impl<'tcx> fmt::Debug for MovePath<'tcx> { } impl<'tcx> fmt::Display for MovePath<'tcx> { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { write!(w, "{:?}", self.place) } } @@ -166,7 +169,7 @@ impl IndexMut for LocationMap { } impl LocationMap where T: Default + Clone { - fn new(mir: &Mir) -> Self { + fn new(mir: &Mir<'_>) -> Self { LocationMap { map: mir.basic_blocks().iter().map(|block| { vec![T::default(); block.statements.len()+1] @@ -190,7 +193,7 @@ pub struct MoveOut { } impl fmt::Debug for MoveOut { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{:?}@{:?}", self.path, self.source) } } @@ -227,7 +230,7 @@ pub enum InitKind { } impl fmt::Debug for Init { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { write!(fmt, "{:?}@{:?} ({:?})", self.path, self.location, self.kind) } } diff --git a/src/librustc_mir/hair/cx/block.rs b/src/librustc_mir/hair/cx/block.rs index 518ae978ae17a..c24cf956504da 100644 --- a/src/librustc_mir/hair/cx/block.rs +++ b/src/librustc_mir/hair/cx/block.rs @@ -1,6 +1,6 @@ -use hair::*; -use hair::cx::Cx; -use hair::cx::to_ref::ToRef; +use crate::hair::*; +use crate::hair::cx::Cx; +use crate::hair::cx::to_ref::ToRef; use rustc::middle::region; use rustc::hir; use rustc::ty; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 8d64c9e9ada89..0759b95a78ff4 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -1,9 +1,9 @@ -use hair::*; +use crate::hair::*; +use crate::hair::cx::Cx; +use crate::hair::cx::block; +use crate::hair::cx::to_ref::ToRef; +use crate::hair::util::UserAnnotatedTyHelpers; use rustc_data_structures::indexed_vec::Idx; -use hair::cx::Cx; -use hair::cx::block; -use hair::cx::to_ref::ToRef; -use hair::util::UserAnnotatedTyHelpers; use rustc::hir::def::{Def, CtorKind}; use rustc::mir::interpret::{GlobalId, ErrorHandled}; use rustc::ty::{self, AdtKind, Ty}; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index f514cac6326be..6d61801fc7162 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -4,8 +4,8 @@ //! work. //! -use hair::*; -use hair::util::UserAnnotatedTyHelpers; +use crate::hair::*; +use crate::hair::util::UserAnnotatedTyHelpers; use rustc_data_structures::indexed_vec::Idx; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; @@ -21,7 +21,7 @@ use syntax::attr; use syntax::symbol::Symbol; use rustc::hir; use rustc_data_structures::sync::Lrc; -use hair::constant::{lit_to_const, LitToConstError}; +use crate::hair::constant::{lit_to_const, LitToConstError}; #[derive(Clone)] pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { @@ -239,7 +239,7 @@ impl UserAnnotatedTyHelpers<'gcx, 'tcx> for Cx<'_, 'gcx, 'tcx> { } } -fn lint_level_for_hir_id(tcx: TyCtxt, mut id: ast::NodeId) -> ast::NodeId { +fn lint_level_for_hir_id(tcx: TyCtxt<'_, '_, '_>, mut id: ast::NodeId) -> ast::NodeId { // Right now we insert a `with_ignore` node in the dep graph here to // ignore the fact that `lint_levels` below depends on the entire crate. // For now this'll prevent false positives of recompiling too much when diff --git a/src/librustc_mir/hair/cx/to_ref.rs b/src/librustc_mir/hair/cx/to_ref.rs index 1b87e4450c56e..a462c61c2acba 100644 --- a/src/librustc_mir/hair/cx/to_ref.rs +++ b/src/librustc_mir/hair/cx/to_ref.rs @@ -1,4 +1,4 @@ -use hair::*; +use crate::hair::*; use rustc::hir; use syntax::ptr::P; diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs index 7f5b1a761d261..5779a032acc4d 100644 --- a/src/librustc_mir/hair/pattern/_match.rs +++ b/src/librustc_mir/hair/pattern/_match.rs @@ -307,7 +307,7 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> { /// + _ + [_, _, ..tail] + /// ++++++++++++++++++++++++++ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "\n")?; let &Matrix(ref m) = self; @@ -442,7 +442,7 @@ impl<'tcx> Constructor<'tcx> { VariantIdx::new(0) } &ConstantValue(c) => { - ::const_eval::const_variant_index( + crate::const_eval::const_variant_index( cx.tcx, cx.param_env, c, @@ -1115,7 +1115,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, } else { debug!("is_useful - expanding wildcard"); - let used_ctors: Vec = rows.iter().flat_map(|row| { + let used_ctors: Vec> = rows.iter().flat_map(|row| { pat_constructors(cx, row[0], pcx).unwrap_or(vec![]) }).collect(); debug!("used_ctors = {:#?}", used_ctors); @@ -1302,7 +1302,7 @@ fn is_useful_specialized<'p, 'a: 'p, 'tcx: 'a>( /// Returns None in case of a catch-all, which can't be specialized. fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>, pat: &Pattern<'tcx>, - pcx: PatternContext) + pcx: PatternContext<'_>) -> Option>> { match *pat.kind { diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index a47d64319bdc5..978051aab591b 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -229,7 +229,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { return; } - let matrix: Matrix = inlined_arms + let matrix: Matrix<'_, '_> = inlined_arms .iter() .filter(|&&(_, guard)| guard.is_none()) .flat_map(|arm| &arm.0) @@ -248,7 +248,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { self.tables); let pattern = patcx.lower_pattern(pat); let pattern_ty = pattern.ty; - let pats: Matrix = vec![smallvec![ + let pats: Matrix<'_, '_> = vec![smallvec![ expand_pattern(cx, pattern) ]].into_iter().collect(); @@ -283,7 +283,7 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { } } -fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor, pat: &Pat) { +fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) { pat.walk(|p| { if let PatKind::Binding(_, _, _, ident, None) = p.node { if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) { @@ -462,7 +462,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>, } // Legality of move bindings checking -fn check_legality_of_move_bindings(cx: &MatchVisitor, +fn check_legality_of_move_bindings(cx: &MatchVisitor<'_, '_>, has_guard: bool, pats: &[P]) { let mut by_ref_span = None; @@ -541,7 +541,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor, /// assign. /// /// FIXME: this should be done by borrowck. -fn check_for_mutation_in_guard(cx: &MatchVisitor, guard: &hir::Guard) { +fn check_for_mutation_in_guard(cx: &MatchVisitor<'_, '_>, guard: &hir::Guard) { let mut checker = MutationChecker { cx, }; @@ -561,13 +561,13 @@ struct MutationChecker<'a, 'tcx: 'a> { } impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { - fn matched_pat(&mut self, _: &Pat, _: &cmt_, _: euv::MatchMode) {} - fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_, _: ConsumeMode) {} - fn consume_pat(&mut self, _: &Pat, _: &cmt_, _: ConsumeMode) {} + fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {} + fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {} + fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {} fn borrow(&mut self, _: ast::NodeId, span: Span, - _: &cmt_, + _: &cmt_<'_>, _: ty::Region<'tcx>, kind:ty:: BorrowKind, _: LoanCause) { @@ -588,7 +588,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { } } fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {} - fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_, mode: MutateMode) { + fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_<'_>, mode: MutateMode) { match mode { MutateMode::JustWrite | MutateMode::WriteAndRead => { struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard") @@ -603,7 +603,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> { /// Forbids bindings in `@` patterns. This is necessary for memory safety, /// because of the way rvalues are handled in the borrow check. (See issue /// #14587.) -fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor, pat: &Pat) { +fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat) { AtBindingPatternVisitor { cx: cx, bindings_allowed: true }.visit_pat(pat); } diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 6b7e14161186d..8d32becd439e0 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -6,10 +6,10 @@ mod check_match; pub use self::check_match::check_crate; pub(crate) use self::check_match::check_match; -use const_eval::{const_field, const_variant_index}; +use crate::const_eval::{const_field, const_variant_index}; -use hair::util::UserAnnotatedTyHelpers; -use hair::constant::*; +use crate::hair::util::UserAnnotatedTyHelpers; +use crate::hair::constant::*; use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability}; use rustc::mir::{UserTypeProjection}; @@ -176,7 +176,7 @@ pub struct PatternRange<'tcx> { } impl<'tcx> fmt::Display for Pattern<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self.kind { PatternKind::Wild => write!(f, "_"), PatternKind::AscribeUserType { ref subpattern, .. } => diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 1b976d822ebff..c87338fb0ce94 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -322,7 +322,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc ) -> EvalResult<'tcx, TyLayout<'tcx>> { match frame.locals[local].layout.get() { None => { - let layout = ::interpret::operand::from_known_layout(layout, || { + let layout = crate::interpret::operand::from_known_layout(layout, || { let local_ty = frame.mir.local_decls[local].ty; let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs); self.layout_of(local_ty) diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 5fae461bdc203..ee295116ba962 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -25,7 +25,7 @@ use syntax::source_map::Span; use super::eval_context::{LocalState, StackPopCleanup}; use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef, LocalValue}; -use const_eval::CompileTimeInterpreter; +use crate::const_eval::CompileTimeInterpreter; #[derive(Default)] pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir> { @@ -200,7 +200,7 @@ impl_snapshot_for!(enum ScalarMaybeUndef { Undef, }); -impl_stable_hash_for!(struct ::interpret::MemPlace { +impl_stable_hash_for!(struct crate::interpret::MemPlace { ptr, align, meta, @@ -211,7 +211,7 @@ impl_snapshot_for!(struct MemPlace { align -> *align, // just copy alignment verbatim }); -impl_stable_hash_for!(enum ::interpret::Place { +impl_stable_hash_for!(enum crate::interpret::Place { Ptr(mem_place), Local { frame, local }, }); @@ -232,7 +232,7 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for Place } } -impl_stable_hash_for!(enum ::interpret::Immediate { +impl_stable_hash_for!(enum crate::interpret::Immediate { Scalar(x), ScalarPair(x, y), }); @@ -241,7 +241,7 @@ impl_snapshot_for!(enum Immediate { ScalarPair(s, t), }); -impl_stable_hash_for!(enum ::interpret::Operand { +impl_stable_hash_for!(enum crate::interpret::Operand { Immediate(x), Indirect(x), }); @@ -250,7 +250,7 @@ impl_snapshot_for!(enum Operand { Indirect(m), }); -impl_stable_hash_for!(enum ::interpret::LocalValue { +impl_stable_hash_for!(enum crate::interpret::LocalValue { Dead, Live(x), }); @@ -298,7 +298,7 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for &'a Allocation } } -impl_stable_hash_for!(enum ::interpret::eval_context::StackPopCleanup { +impl_stable_hash_for!(enum crate::interpret::eval_context::StackPopCleanup { Goto(block), None { cleanup }, }); diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 7e823524c180c..be50daa17092f 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -112,7 +112,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> let ty = place.layout.ty; trace!("TerminatorKind::drop: {:?}, type {}", location, ty); - let instance = ::monomorphize::resolve_drop_in_place(*self.tcx, ty); + let instance = crate::monomorphize::resolve_drop_in_place(*self.tcx, ty); self.drop_in_place( place, instance, @@ -326,7 +326,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> // last incoming argument. These two iterators do not have the same type, // so to keep the code paths uniform we accept an allocation // (for RustCall ABI only). - let caller_args : Cow<[OpTy<'tcx, M::PointerTag>]> = + let caller_args : Cow<'_, [OpTy<'tcx, M::PointerTag>]> = if caller_abi == Abi::RustCall && !args.is_empty() { // Untuple let (&untuple_arg, args) = args.split_last().unwrap(); @@ -335,7 +335,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> .chain((0..untuple_arg.layout.fields.count()).into_iter() .map(|i| self.operand_field(untuple_arg, i as u64)) ) - .collect::>>>()?) + .collect::>>>()?) } else { // Plain arg passing Cow::from(args) diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index 642bbc114f562..63253bae9078b 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -52,7 +52,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> ).with_default_tag(); let tcx = &*self.tcx; - let drop = ::monomorphize::resolve_drop_in_place(*tcx, ty); + let drop = crate::monomorphize::resolve_drop_in_place(*tcx, ty); let drop = self.memory.create_fn_alloc(drop).with_default_tag(); // no need to do any alignment checks on the memory accesses below, because we know the // allocation is correctly aligned as we created it above. Also we're only offsetting by diff --git a/src/librustc_mir/interpret/visitor.rs b/src/librustc_mir/interpret/visitor.rs index 4773f5627d716..930bcb44374aa 100644 --- a/src/librustc_mir/interpret/visitor.rs +++ b/src/librustc_mir/interpret/visitor.rs @@ -26,7 +26,7 @@ pub trait Value<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>: Copy ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>>; /// Create this from an `MPlaceTy`. - fn from_mem_place(MPlaceTy<'tcx, M::PointerTag>) -> Self; + fn from_mem_place(mplace: MPlaceTy<'tcx, M::PointerTag>) -> Self; /// Project to the given enum variant. fn project_downcast( diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index ccfc15bac042c..72a13c791cec0 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -4,7 +4,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ -#![feature(nll)] #![feature(in_band_lifetimes)] #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] @@ -29,28 +28,19 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![recursion_limit="256"] -extern crate arena; +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] #[macro_use] extern crate bitflags; #[macro_use] extern crate log; -extern crate either; -extern crate graphviz as dot; -extern crate polonius_engine; #[macro_use] extern crate rustc; #[macro_use] extern crate rustc_data_structures; -extern crate serialize as rustc_serialize; -extern crate rustc_errors; +#[allow(unused_extern_crates)] +extern crate serialize as rustc_serialize; // used by deriving #[macro_use] extern crate syntax; -extern crate syntax_pos; -extern crate rustc_target; -extern crate log_settings; -extern crate rustc_apfloat; -extern crate byteorder; -extern crate core; -extern crate smallvec; // Once we can use edition 2018 in the compiler, // replace this with real try blocks. @@ -77,7 +67,7 @@ pub mod const_eval; pub use hair::pattern::check_crate as matchck_crate; use rustc::ty::query::Providers; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { borrow_check::provide(providers); shim::provide(providers); transform::provide(providers); diff --git a/src/librustc_mir/lints.rs b/src/librustc_mir/lints.rs index 8ded31d89daea..6b6e8fcdc82cf 100644 --- a/src/librustc_mir/lints.rs +++ b/src/librustc_mir/lints.rs @@ -18,7 +18,7 @@ pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>, } fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>, - fn_kind: FnKind, + fn_kind: FnKind<'_>, mir: &Mir<'tcx>, def_id: DefId) { if let FnKind::Closure(_) = fn_kind { diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index e713ab17c3af5..7f3c24daf606d 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -189,11 +189,11 @@ use rustc::mir::visit::Visitor as MirVisitor; use rustc::mir::mono::MonoItem; use rustc::mir::interpret::{Scalar, GlobalId, AllocKind, ErrorHandled}; -use monomorphize::{self, Instance}; +use crate::monomorphize::{self, Instance}; use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap}; use rustc::util::common::time; -use monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode}; +use crate::monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode}; use rustc_data_structures::bit_set::GrowableBitSet; use rustc_data_structures::sync::{MTRef, MTLock, ParallelIterator, par_iter}; diff --git a/src/librustc_mir/monomorphize/item.rs b/src/librustc_mir/monomorphize/item.rs index 431cc0d52b4c8..d3381f463f49e 100644 --- a/src/librustc_mir/monomorphize/item.rs +++ b/src/librustc_mir/monomorphize/item.rs @@ -1,4 +1,4 @@ -use monomorphize::Instance; +use crate::monomorphize::Instance; use rustc::hir; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::session::config::OptLevel; diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index 569e4c828f601..d4c7ebefe1753 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -111,9 +111,9 @@ use rustc::util::common::time; use rustc::util::nodemap::{DefIdSet, FxHashMap, FxHashSet}; use rustc::mir::mono::MonoItem; -use monomorphize::collector::InliningMap; -use monomorphize::collector::{self, MonoItemCollectionMode}; -use monomorphize::item::{MonoItemExt, InstantiationMode}; +use crate::monomorphize::collector::InliningMap; +use crate::monomorphize::collector::{self, MonoItemCollectionMode}; +use crate::monomorphize::item::{MonoItemExt, InstantiationMode}; pub use rustc::mir::mono::CodegenUnit; @@ -146,7 +146,7 @@ pub trait CodegenUnitExt<'tcx> { WorkProductId::from_cgu_name(&self.name().as_str()) } - fn work_product(&self, tcx: TyCtxt) -> WorkProduct { + fn work_product(&self, tcx: TyCtxt<'_, '_, '_>) -> WorkProduct { let work_product_id = self.work_product_id(); tcx.dep_graph .previous_work_product(&work_product_id) @@ -213,7 +213,7 @@ impl<'tcx> CodegenUnitExt<'tcx> for CodegenUnit<'tcx> { } // Anything we can't find a proper codegen unit for goes into this. -fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder) -> InternedString { +fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>) -> InternedString { name_builder.build_cgu_name(LOCAL_CRATE, &["fallback"], Some("cgu")) } @@ -536,7 +536,7 @@ fn mono_item_visibility( } } -fn default_visibility(tcx: TyCtxt, id: DefId, is_generic: bool) -> Visibility { +fn default_visibility(tcx: TyCtxt<'_, '_, '_>, id: DefId, is_generic: bool) -> Visibility { if !tcx.sess.target.target.options.default_hidden_visibility { return Visibility::Default } @@ -795,8 +795,8 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, type CguNameCache = FxHashMap<(DefId, bool), InternedString>; -fn compute_codegen_unit_name(tcx: TyCtxt, - name_builder: &mut CodegenUnitNameBuilder, +fn compute_codegen_unit_name(tcx: TyCtxt<'_, '_, '_>, + name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>, def_id: DefId, volatile: bool, cache: &mut CguNameCache) @@ -855,7 +855,7 @@ fn compute_codegen_unit_name(tcx: TyCtxt, }).clone() } -fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder, +fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>, index: usize) -> InternedString { name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(index)) @@ -929,7 +929,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( tcx.sess.abort_if_errors(); - ::monomorphize::assert_symbols_are_distinct(tcx, items.iter()); + crate::monomorphize::assert_symbols_are_distinct(tcx, items.iter()); let strategy = if tcx.sess.opts.incremental.is_some() { PartitioningStrategy::PerModule @@ -1013,7 +1013,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>( (Arc::new(mono_items), Arc::new(codegen_units)) } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.collect_and_partition_mono_items = collect_and_partition_mono_items; diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 751815eab287b..942e7a1f1bbbd 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -16,12 +16,12 @@ use syntax_pos::Span; use std::fmt; use std::iter; -use transform::{add_moves_for_packed_drops, add_call_guards}; -use transform::{remove_noop_landing_pads, no_landing_pads, simplify}; -use util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode}; -use util::patch::MirPatch; +use crate::transform::{add_moves_for_packed_drops, add_call_guards}; +use crate::transform::{remove_noop_landing_pads, no_landing_pads, simplify}; +use crate::util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode}; +use crate::util::patch::MirPatch; -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { providers.mir_shims = make_shim; } @@ -138,7 +138,7 @@ enum CallKind { Direct(DefId), } -fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl { +fn temp_decl(mutability: Mutability, ty: Ty<'_>, span: Span) -> LocalDecl<'_> { let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span }; LocalDecl { mutability, @@ -259,7 +259,7 @@ pub struct DropShimElaborator<'a, 'tcx: 'a> { } impl<'a, 'tcx> fmt::Debug for DropShimElaborator<'a, 'tcx> { - fn fmt(&self, _f: &mut fmt::Formatter) -> Result<(), fmt::Error> { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { Ok(()) } } diff --git a/src/librustc_mir/transform/add_call_guards.rs b/src/librustc_mir/transform/add_call_guards.rs index 3ea1c8e82ff2b..dab96faaa2a5e 100644 --- a/src/librustc_mir/transform/add_call_guards.rs +++ b/src/librustc_mir/transform/add_call_guards.rs @@ -1,7 +1,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; #[derive(PartialEq)] pub enum AddCallGuards { @@ -40,7 +40,7 @@ impl MirPass for AddCallGuards { } impl AddCallGuards { - pub fn add_call_guards(&self, mir: &mut Mir) { + pub fn add_call_guards(&self, mir: &mut Mir<'_>) { let pred_count: IndexVec<_, _> = mir.predecessors().iter().map(|ps| ps.len()).collect(); diff --git a/src/librustc_mir/transform/add_moves_for_packed_drops.rs b/src/librustc_mir/transform/add_moves_for_packed_drops.rs index 8ec6902cf15fd..1492f0c50a31a 100644 --- a/src/librustc_mir/transform/add_moves_for_packed_drops.rs +++ b/src/librustc_mir/transform/add_moves_for_packed_drops.rs @@ -2,9 +2,9 @@ use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; -use util; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; +use crate::util; // This pass moves values being dropped that are within a packed // struct to a separate local before dropping them, to ensure that diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index 3d5897bca9f52..7bfcd318afe2d 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -6,7 +6,7 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::*; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct AddRetag; diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index ab8da2f352c1c..b2e1afc519ec5 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -17,7 +17,7 @@ use syntax::symbol::Symbol; use std::ops::Bound; -use util; +use crate::util; pub struct UnsafetyChecker<'a, 'tcx: 'a> { mir: &'a Mir<'tcx>, @@ -458,7 +458,7 @@ impl<'a, 'tcx> UnsafetyChecker<'a, 'tcx> { } } -pub(crate) fn provide(providers: &mut Providers) { +pub(crate) fn provide(providers: &mut Providers<'_>) { *providers = Providers { unsafety_check_result, unsafe_derive_on_repr_packed, @@ -575,7 +575,7 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D } /// Return the NodeId for an enclosing scope that is also `unsafe` -fn is_enclosed(tcx: TyCtxt, +fn is_enclosed(tcx: TyCtxt<'_, '_, '_>, used_unsafe: &FxHashSet, id: ast::NodeId) -> Option<(String, ast::NodeId)> { let parent_id = tcx.hir().get_parent_node(id); @@ -598,7 +598,9 @@ fn is_enclosed(tcx: TyCtxt, } } -fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet, id: ast::NodeId) { +fn report_unused_unsafe(tcx: TyCtxt<'_, '_, '_>, + used_unsafe: &FxHashSet, + id: ast::NodeId) { let span = tcx.sess.source_map().def_span(tcx.hir().span(id)); let msg = "unnecessary `unsafe` block"; let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg); diff --git a/src/librustc_mir/transform/cleanup_post_borrowck.rs b/src/librustc_mir/transform/cleanup_post_borrowck.rs index e6df6b7fd2724..240ef7c8ba42a 100644 --- a/src/librustc_mir/transform/cleanup_post_borrowck.rs +++ b/src/librustc_mir/transform/cleanup_post_borrowck.rs @@ -26,7 +26,7 @@ use rustc::mir::{BasicBlock, FakeReadCause, Local, Location, Mir, Place}; use rustc::mir::{Statement, StatementKind}; use rustc::mir::visit::MutVisitor; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct CleanAscribeUserType; diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index dc556a15cd855..dd1f37a591888 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -18,12 +18,12 @@ use rustc::ty::layout::{ HasTyCtxt, TargetDataLayout, HasDataLayout, }; -use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; -use const_eval::{ +use crate::interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind}; +use crate::const_eval::{ CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_eval_cx, lazy_const_to_op, }; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct ConstProp; @@ -486,7 +486,7 @@ struct CanConstProp { impl CanConstProp { /// returns true if `local` can be propagated - fn check(mir: &Mir) -> IndexVec { + fn check(mir: &Mir<'_>) -> IndexVec { let mut cpv = CanConstProp { can_const_prop: IndexVec::from_elem(true, &mir.local_decls), found_assignment: IndexVec::from_elem(false, &mir.local_decls), diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs index 55e14077c3ed0..4789c35740eb3 100644 --- a/src/librustc_mir/transform/copy_prop.rs +++ b/src/librustc_mir/transform/copy_prop.rs @@ -22,8 +22,8 @@ use rustc::mir::{Constant, Local, LocalKind, Location, Place, Mir, Operand, Rvalue, StatementKind}; use rustc::mir::visit::MutVisitor; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; -use util::def_use::DefUseAnalysis; +use crate::transform::{MirPass, MirSource}; +use crate::util::def_use::DefUseAnalysis; pub struct CopyPropagation; @@ -173,7 +173,7 @@ enum Action<'tcx> { } impl<'tcx> Action<'tcx> { - fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'tcx>) + fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis<'_>, src_place: &Place<'tcx>) -> Option> { // The source must be a local. let src_local = if let Place::Local(local) = *src_place { diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs index a2fe9def8eeba..669384e31dac3 100644 --- a/src/librustc_mir/transform/deaggregator.rs +++ b/src/librustc_mir/transform/deaggregator.rs @@ -1,7 +1,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc_data_structures::indexed_vec::Idx; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct Deaggregator; diff --git a/src/librustc_mir/transform/dump_mir.rs b/src/librustc_mir/transform/dump_mir.rs index 8fabb2d11fc46..d7f697a320049 100644 --- a/src/librustc_mir/transform/dump_mir.rs +++ b/src/librustc_mir/transform/dump_mir.rs @@ -8,8 +8,8 @@ use std::io; use rustc::mir::Mir; use rustc::session::config::{OutputFilenames, OutputType}; use rustc::ty::TyCtxt; -use transform::{MirPass, MirSource}; -use util as mir_util; +use crate::transform::{MirPass, MirSource}; +use crate::util as mir_util; pub struct Marker(pub &'static str); @@ -31,7 +31,7 @@ pub struct Disambiguator { } impl fmt::Display for Disambiguator { - fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let title = if self.is_after { "after" } else { "before" }; write!(formatter, "{}", title) } diff --git a/src/librustc_mir/transform/elaborate_drops.rs b/src/librustc_mir/transform/elaborate_drops.rs index 06e16de8b43bc..4aaa0be7964a4 100644 --- a/src/librustc_mir/transform/elaborate_drops.rs +++ b/src/librustc_mir/transform/elaborate_drops.rs @@ -1,10 +1,14 @@ -use dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult}; -use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; -use dataflow::{DataflowResults}; -use dataflow::{on_all_children_bits, on_all_drop_children_bits}; -use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits}; -use dataflow::MoveDataParamEnv; -use dataflow::{self, do_dataflow, DebugFormatted}; +use crate::dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult}; +use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; +use crate::dataflow::{DataflowResults}; +use crate::dataflow::{on_all_children_bits, on_all_drop_children_bits}; +use crate::dataflow::{drop_flag_effects_for_location, on_lookup_result_bits}; +use crate::dataflow::MoveDataParamEnv; +use crate::dataflow::{self, do_dataflow, DebugFormatted}; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; +use crate::util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop}; +use crate::util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode}; use rustc::ty::{self, TyCtxt}; use rustc::ty::layout::VariantIdx; use rustc::mir::*; @@ -13,10 +17,6 @@ use rustc_data_structures::bit_set::BitSet; use std::fmt; use syntax::ast; use syntax_pos::Span; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; -use util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop}; -use util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode}; pub struct ElaborateDrops; @@ -174,7 +174,7 @@ struct Elaborator<'a, 'b: 'a, 'tcx: 'b> { } impl<'a, 'b, 'tcx> fmt::Debug for Elaborator<'a, 'b, 'tcx> { - fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { Ok(()) } } diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index b464b7d65e466..b555a2aa83ee3 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -8,7 +8,7 @@ use rustc::ty::subst::Substs; use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::*; use rustc::mir::visit::{MutVisitor, TyContext}; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; struct EraseRegionsVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index f5cc6a43e28b9..9897f9833ca62 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -56,19 +56,19 @@ use rustc::mir::visit::{PlaceContext, Visitor, MutVisitor}; use rustc::ty::{self, TyCtxt, AdtDef, Ty}; use rustc::ty::layout::VariantIdx; use rustc::ty::subst::Substs; -use util::dump_mir; -use util::liveness::{self, IdentityMap}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::bit_set::BitSet; use std::borrow::Cow; use std::iter::once; use std::mem; -use transform::{MirPass, MirSource}; -use transform::simplify; -use transform::no_landing_pads::no_landing_pads; -use dataflow::{do_dataflow, DebugFormatted, state_for_location}; -use dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals}; +use crate::transform::{MirPass, MirSource}; +use crate::transform::simplify; +use crate::transform::no_landing_pads::no_landing_pads; +use crate::dataflow::{do_dataflow, DebugFormatted, state_for_location}; +use crate::dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals}; +use crate::util::dump_mir; +use crate::util::liveness::{self, IdentityMap}; pub struct StateTransform; @@ -581,9 +581,9 @@ fn insert_switch<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, mir: &mut Mir<'tcx>) { - use util::elaborate_drops::{elaborate_drop, Unwind}; - use util::patch::MirPatch; - use shim::DropShimElaborator; + use crate::util::elaborate_drops::{elaborate_drop, Unwind}; + use crate::util::patch::MirPatch; + use crate::shim::DropShimElaborator; // Note that `elaborate_drops` only drops the upvars of a generator, and // this is ok because `open_drop` can only be reached within that own diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 9f0907adc9892..4fddf6f8e09c2 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -13,10 +13,10 @@ use rustc::ty::subst::{Subst,Substs}; use std::collections::VecDeque; use std::iter; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; use super::simplify::{remove_dead_blocks, CfgSimplifier}; -use syntax::{attr}; +use syntax::attr; use rustc_target::spec::abi::Abi; const DEFAULT_THRESHOLD: usize = 50; @@ -426,7 +426,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { // Place could result in two different locations if `f` // writes to `i`. To prevent this we need to create a temporary // borrow of the place and pass the destination as `*temp` instead. - fn dest_needs_borrow(place: &Place) -> bool { + fn dest_needs_borrow(place: &Place<'_>) -> bool { match *place { Place::Projection(ref p) => { match p.elem { diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs index 2b5e761d1d055..21772e1f1cd5b 100644 --- a/src/librustc_mir/transform/instcombine.rs +++ b/src/librustc_mir/transform/instcombine.rs @@ -6,7 +6,7 @@ use rustc::ty::{TyCtxt, TyKind}; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::Idx; use std::mem; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct InstCombine; diff --git a/src/librustc_mir/transform/lower_128bit.rs b/src/librustc_mir/transform/lower_128bit.rs index d14e0f078e6c6..aa248ba7c53df 100644 --- a/src/librustc_mir/transform/lower_128bit.rs +++ b/src/librustc_mir/transform/lower_128bit.rs @@ -5,8 +5,7 @@ use rustc::middle::lang_items::LangItem; use rustc::mir::*; use rustc::ty::{List, Ty, TyCtxt, TyKind}; use rustc_data_structures::indexed_vec::{Idx}; -use transform::{MirPass, MirSource}; -use syntax; +use crate::transform::{MirPass, MirSource}; pub struct Lower128Bit; @@ -182,7 +181,7 @@ impl RhsKind { } } -fn sign_of_128bit(ty: Ty) -> Option { +fn sign_of_128bit(ty: Ty<'_>) -> Option { match ty.sty { TyKind::Int(syntax::ast::IntTy::I128) => Some(true), TyKind::Uint(syntax::ast::UintTy::U128) => Some(false), diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs index a4f011b2e2ec9..cc37a8381f234 100644 --- a/src/librustc_mir/transform/mod.rs +++ b/src/librustc_mir/transform/mod.rs @@ -1,5 +1,5 @@ -use borrow_check::nll::type_check; -use build; +use crate::borrow_check::nll::type_check; +use crate::build; use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::mir::{Mir, MirPhase, Promoted}; use rustc::ty::TyCtxt; @@ -38,7 +38,7 @@ pub mod inline; pub mod lower_128bit; pub mod uniform_array_move_out; -pub(crate) fn provide(providers: &mut Providers) { +pub(crate) fn provide(providers: &mut Providers<'_>) { self::qualify_consts::provide(providers); self::check_unsafety::provide(providers); *providers = Providers { diff --git a/src/librustc_mir/transform/no_landing_pads.rs b/src/librustc_mir/transform/no_landing_pads.rs index 2d13b066270a2..15b59d36d363c 100644 --- a/src/librustc_mir/transform/no_landing_pads.rs +++ b/src/librustc_mir/transform/no_landing_pads.rs @@ -4,7 +4,7 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc::mir::visit::MutVisitor; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct NoLandingPads; diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 1602fc35a2c95..d1dc5cfec994d 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -130,7 +130,8 @@ impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> { } } -pub fn collect_temps(mir: &Mir, rpo: &mut ReversePostorder) -> IndexVec { +pub fn collect_temps(mir: &Mir<'_>, + rpo: &mut ReversePostorder<'_, '_>) -> IndexVec { let mut collector = TempCollector { temps: IndexVec::from_elem(TempState::Undefined, &mir.local_decls), span: mir.span, diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 7d1943e21b90d..c786e9438af12 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -27,7 +27,7 @@ use syntax_pos::{Span, DUMMY_SP}; use std::fmt; use std::usize; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; use super::promote_consts::{self, Candidate, TempState}; bitflags! { @@ -84,7 +84,7 @@ enum Mode { } impl fmt::Display for Mode { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Mode::Const => write!(f, "constant"), Mode::Static | Mode::StaticMut => write!(f, "static"), @@ -1128,7 +1128,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } } -pub fn provide(providers: &mut Providers) { +pub fn provide(providers: &mut Providers<'_>) { *providers = Providers { mir_const_qualif, ..*providers @@ -1317,7 +1317,7 @@ impl MirPass for QualifyAndPromoteConstants { } } -fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option> { +fn args_required_const(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option> { let attrs = tcx.get_attrs(def_id); let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?; let mut ret = FxHashSet::default(); diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index c8ef2decf2606..4fcb4c10f9e6d 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -1,8 +1,8 @@ use rustc::ty::TyCtxt; use rustc::mir::*; use rustc_data_structures::bit_set::BitSet; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; /// A pass that removes no-op landing pads and replaces jumps to them with /// `None`. This is important because otherwise LLVM generates terrible @@ -34,7 +34,7 @@ impl RemoveNoopLandingPads { fn is_nop_landing_pad( &self, bb: BasicBlock, - mir: &Mir, + mir: &Mir<'_>, nop_landing_pads: &BitSet, ) -> bool { for stmt in &mir[bb].statements { @@ -86,7 +86,7 @@ impl RemoveNoopLandingPads { } } - fn remove_nop_landing_pads(&self, mir: &mut Mir) { + fn remove_nop_landing_pads(&self, mir: &mut Mir<'_>) { // make sure there's a single resume block let resume_block = { let patch = MirPatch::new(mir); diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 36a6279e50320..806c1c1cca457 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -5,18 +5,20 @@ use syntax_pos::Span; use rustc::ty::{self, TyCtxt}; use rustc::mir::{self, Mir, Location}; use rustc_data_structures::bit_set::BitSet; -use transform::{MirPass, MirSource}; - -use dataflow::{do_dataflow, DebugFormatted}; -use dataflow::MoveDataParamEnv; -use dataflow::BitDenotation; -use dataflow::DataflowResults; -use dataflow::{DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces}; -use dataflow::move_paths::{MovePathIndex, LookupResult}; -use dataflow::move_paths::{HasMoveData, MoveData}; -use dataflow; - -use dataflow::has_rustc_mir_with; +use crate::transform::{MirPass, MirSource}; + +use crate::dataflow::{do_dataflow, DebugFormatted}; +use crate::dataflow::MoveDataParamEnv; +use crate::dataflow::BitDenotation; +use crate::dataflow::DataflowResults; +use crate::dataflow::{ + DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces +}; +use crate::dataflow::move_paths::{MovePathIndex, LookupResult}; +use crate::dataflow::move_paths::{HasMoveData, MoveData}; +use crate::dataflow; + +use crate::dataflow::has_rustc_mir_with; pub struct SanityCheck; diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index ed2da98dd5311..90486d1566413 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -34,7 +34,7 @@ use rustc::mir::*; use rustc::mir::visit::{MutVisitor, Visitor, PlaceContext}; use rustc::session::config::DebugInfo; use std::borrow::Cow; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; pub struct SimplifyCfg { label: String } @@ -44,7 +44,7 @@ impl SimplifyCfg { } } -pub fn simplify_cfg(mir: &mut Mir) { +pub fn simplify_cfg(mir: &mut Mir<'_>) { CfgSimplifier::new(mir).simplify(); remove_dead_blocks(mir); @@ -263,7 +263,7 @@ impl<'a, 'tcx: 'a> CfgSimplifier<'a, 'tcx> { } } -pub fn remove_dead_blocks(mir: &mut Mir) { +pub fn remove_dead_blocks(mir: &mut Mir<'_>) { let mut seen = BitSet::new_empty(mir.basic_blocks().len()); for (bb, _) in traversal::preorder(mir) { seen.insert(bb.index()); diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index abaea70946383..0dc89bfe14709 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -2,7 +2,7 @@ use rustc::ty::{TyCtxt, ParamEnv}; use rustc::mir::*; -use transform::{MirPass, MirSource}; +use crate::transform::{MirPass, MirSource}; use std::borrow::Cow; diff --git a/src/librustc_mir/transform/uniform_array_move_out.rs b/src/librustc_mir/transform/uniform_array_move_out.rs index 5ab9669baaca0..09918436817f3 100644 --- a/src/librustc_mir/transform/uniform_array_move_out.rs +++ b/src/librustc_mir/transform/uniform_array_move_out.rs @@ -30,9 +30,9 @@ use rustc::ty; use rustc::ty::TyCtxt; use rustc::mir::*; use rustc::mir::visit::{Visitor, PlaceContext, NonUseContext}; -use transform::{MirPass, MirSource}; -use util::patch::MirPatch; use rustc_data_structures::indexed_vec::{IndexVec}; +use crate::transform::{MirPass, MirSource}; +use crate::util::patch::MirPatch; pub struct UniformArrayMoveOut; diff --git a/src/librustc_mir/util/borrowck_errors.rs b/src/librustc_mir/util/borrowck_errors.rs index 7ad73aaa3f9a9..fd694ddbbd19f 100644 --- a/src/librustc_mir/util/borrowck_errors.rs +++ b/src/librustc_mir/util/borrowck_errors.rs @@ -12,7 +12,7 @@ pub enum Origin { } impl fmt::Display for Origin { - fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result { // If the user passed `-Z borrowck=compare`, then include // origin info as part of the error report, // otherwise @@ -437,7 +437,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { fn cannot_move_out_of_interior_noncopy( self, move_from_span: Span, - ty: ty::Ty, + ty: ty::Ty<'_>, is_index: Option, o: Origin, ) -> DiagnosticBuilder<'cx> { @@ -464,7 +464,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy { fn cannot_move_out_of_interior_of_drop( self, move_from_span: Span, - container_ty: ty::Ty, + container_ty: ty::Ty<'_>, o: Origin, ) -> DiagnosticBuilder<'cx> { let mut err = struct_span_err!( diff --git a/src/librustc_mir/util/def_use.rs b/src/librustc_mir/util/def_use.rs index 057a7c8be88c9..3b9d7c3612a57 100644 --- a/src/librustc_mir/util/def_use.rs +++ b/src/librustc_mir/util/def_use.rs @@ -107,7 +107,7 @@ impl<'tcx> Info<'tcx> { pub fn defs_not_including_drop( &self, - ) -> iter::Filter>, fn(&&Use<'tcx>) -> bool> { + ) -> iter::Filter>, fn(&&Use<'tcx>) -> bool> { self.defs_and_uses.iter().filter(|place_use| { place_use.context.is_mutating_use() && !place_use.context.is_drop() }) diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 8b55a4424ae29..23e92b3e933d3 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -8,7 +8,7 @@ use rustc::ty::layout::VariantIdx; use rustc::ty::subst::Substs; use rustc::ty::util::IntTypeExt; use rustc_data_structures::indexed_vec::Idx; -use util::patch::MirPatch; +use crate::util::patch::MirPatch; use std::u32; diff --git a/src/librustc_mir/util/graphviz.rs b/src/librustc_mir/util/graphviz.rs index b68898f713021..e93b96c12161c 100644 --- a/src/librustc_mir/util/graphviz.rs +++ b/src/librustc_mir/util/graphviz.rs @@ -1,4 +1,3 @@ -use dot; use rustc::hir::def_id::DefId; use rustc::mir::*; use rustc::ty::TyCtxt; @@ -24,7 +23,7 @@ pub fn write_mir_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, /// Write a graphviz DOT graph of the MIR. pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, def_id: DefId, - mir: &Mir, + mir: &Mir<'_>, w: &mut W) -> io::Result<()> where W: Write { @@ -58,7 +57,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>, /// `init` and `fini` are callbacks for emitting additional rows of /// data (using HTML enclosed with `` in the emitted text). pub fn write_node_label(block: BasicBlock, - mir: &Mir, + mir: &Mir<'_>, w: &mut W, num_cols: u32, init: INIT, @@ -100,7 +99,7 @@ pub fn write_node_label(block: BasicBlock, } /// Write a graphviz DOT node for the given basic block. -fn write_node(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> { +fn write_node(block: BasicBlock, mir: &Mir<'_>, w: &mut W) -> io::Result<()> { // Start a new node with the label to follow, in one of DOT's pseudo-HTML tables. write!(w, r#" {} [shape="none", label=<"#, node(block))?; write_node_label(block, mir, w, 1, |_| Ok(()), |_| Ok(()))?; @@ -109,7 +108,7 @@ fn write_node(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<( } /// Write graphviz DOT edges with labels between the given basic block and all of its successors. -fn write_edges(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> { +fn write_edges(source: BasicBlock, mir: &Mir<'_>, w: &mut W) -> io::Result<()> { let terminator = mir[source].terminator(); let labels = terminator.kind.fmt_successor_labels(); @@ -125,7 +124,7 @@ fn write_edges(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result /// all the variables and temporaries. fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId, - mir: &Mir, + mir: &Mir<'_>, w: &mut W) -> io::Result<()> { write!(w, " label= = BitSet; diff --git a/src/librustc_mir/util/patch.rs b/src/librustc_mir/util/patch.rs index 5a1f94677a1d4..366cd71f6d4e9 100644 --- a/src/librustc_mir/util/patch.rs +++ b/src/librustc_mir/util/patch.rs @@ -170,14 +170,14 @@ impl<'tcx> MirPatch<'tcx> { } } - pub fn source_info_for_index(data: &BasicBlockData, loc: Location) -> SourceInfo { + pub fn source_info_for_index(data: &BasicBlockData<'_>, loc: Location) -> SourceInfo { match data.statements.get(loc.statement_index) { Some(stmt) => stmt.source_info, None => data.terminator().source_info } } - pub fn source_info_for_location(&self, mir: &Mir, loc: Location) -> SourceInfo { + pub fn source_info_for_location(&self, mir: &Mir<'_>, loc: Location) -> SourceInfo { let data = match loc.block.index().checked_sub(mir.basic_blocks().len()) { Some(new) => &self.new_blocks[new], None => &mir[loc.block] diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 3a15356806a97..6e1ec31c9372f 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -12,7 +12,7 @@ use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use super::graphviz::write_mir_fn_graphviz; -use transform::MirSource; +use crate::transform::MirSource; const INDENT: &str = " "; /// Alignment for lining up comments following MIR statements @@ -446,7 +446,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for ExtraComments<'cx, 'gcx, 'tcx> { } } -fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String { +fn comment(tcx: TyCtxt<'_, '_, '_>, SourceInfo { span, scope }: SourceInfo) -> String { format!( "scope {} at {}", scope.index(), @@ -458,8 +458,8 @@ fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String { /// /// Returns the total number of variables printed. fn write_scope_tree( - tcx: TyCtxt, - mir: &Mir, + tcx: TyCtxt<'_, '_, '_>, + mir: &Mir<'_>, scope_tree: &FxHashMap>, w: &mut dyn Write, parent: SourceScope, @@ -529,7 +529,7 @@ fn write_scope_tree( pub fn write_mir_intro<'a, 'gcx, 'tcx>( tcx: TyCtxt<'a, 'gcx, 'tcx>, src: MirSource, - mir: &Mir, + mir: &Mir<'_>, w: &mut dyn Write, ) -> io::Result<()> { write_mir_sig(tcx, src, mir, w)?; @@ -568,7 +568,12 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>( Ok(()) } -fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn 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) { @@ -614,7 +619,7 @@ fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> i Ok(()) } -fn write_temp_decls(mir: &Mir, w: &mut dyn 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!( @@ -630,7 +635,7 @@ fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { Ok(()) } -fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { +fn write_user_type_annotations(mir: &Mir<'_>, w: &mut dyn Write) -> io::Result<()> { if !mir.user_type_annotations.is_empty() { writeln!(w, "| User Type Annotations")?; } @@ -643,7 +648,7 @@ fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> { Ok(()) } -pub fn dump_mir_def_ids(tcx: TyCtxt, single: Option) -> Vec { +pub fn dump_mir_def_ids(tcx: TyCtxt<'_, '_, '_>, single: Option) -> Vec { if let Some(i) = single { vec![i] } else { From 7815c9b1c80c96d80b2054a5bc182bc628473cfd Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 19:56:52 +0900 Subject: [PATCH 2/4] Revert removed #![feature(nll)] --- src/librustc_mir/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 72a13c791cec0..afd33a51a6a3b 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -4,6 +4,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ +#![feature(nll)] #![feature(in_band_lifetimes)] #![feature(slice_patterns)] #![feature(slice_sort_by_cached_key)] From d2514523db8d02fedc6f5d88545b96c55dd26a43 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:08:08 +0900 Subject: [PATCH 3/4] Use real try blocks --- src/librustc_mir/borrow_check/nll/mod.rs | 4 ++-- src/librustc_mir/lib.rs | 9 +-------- src/librustc_mir/util/pretty.rs | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index 128d54c9f49d7..1fca104cd3825 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -254,14 +254,14 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( ); // Also dump the inference graph constraints as a graphviz file. - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = pretty::create_dump_file(infcx.tcx, "regioncx.all.dot", None, "nll", &0, source)?; regioncx.dump_graphviz_raw_constraints(&mut file)?; }; // Also dump the inference graph constraints as a graphviz file. - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = pretty::create_dump_file(infcx.tcx, "regioncx.scc.dot", None, "nll", &0, source)?; regioncx.dump_graphviz_scc_constraints(&mut file)?; diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index afd33a51a6a3b..143104a0feec1 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -26,6 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![feature(slice_concat_ext)] #![feature(try_from)] #![feature(reverse_bits)] +#![feature(try_blocks)] #![recursion_limit="256"] @@ -43,14 +44,6 @@ extern crate serialize as rustc_serialize; // used by deriving #[macro_use] extern crate syntax; -// Once we can use edition 2018 in the compiler, -// replace this with real try blocks. -macro_rules! try_block { - ($($inside:tt)*) => ( - (||{ ::std::ops::Try::from_ok({ $($inside)* }) })() - ) -} - mod diagnostics; mod borrow_check; diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6e1ec31c9372f..2e1fc756833b8 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -131,7 +131,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>( ) where F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>, { - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = create_dump_file(tcx, "mir", pass_num, pass_name, disambiguator, source)?; writeln!(file, "// MIR for `{}`", node_path)?; writeln!(file, "// source = {:?}", source)?; @@ -148,7 +148,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>( }; if tcx.sess.opts.debugging_opts.dump_mir_graphviz { - let _: io::Result<()> = try_block! { + let _: io::Result<()> = try { let mut file = create_dump_file(tcx, "dot", pass_num, pass_name, disambiguator, source)?; write_mir_fn_graphviz(tcx, source.def_id, mir, &mut file)?; From c9bc85ecf100da1358ff2c2545fe5fa6caa506c2 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 8 Feb 2019 20:13:12 +0900 Subject: [PATCH 4/4] Remove #[macro_use] extern crate bitflags --- src/librustc_mir/lib.rs | 2 -- src/librustc_mir/transform/qualify_consts.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 143104a0feec1..909f96956695d 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -33,8 +33,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] -#[macro_use] -extern crate bitflags; #[macro_use] extern crate log; #[macro_use] extern crate rustc; diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index c786e9438af12..ab4e3ad23f69a 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -30,7 +30,7 @@ use std::usize; use crate::transform::{MirPass, MirSource}; use super::promote_consts::{self, Candidate, TempState}; -bitflags! { +bitflags::bitflags! { // Borrows of temporaries can be promoted only if // they have none of these qualifications, with // the exception of `STATIC_REF` (in statics only).