Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librustc_mir => 2018 #58265

Merged
merged 4 commits into from
Feb 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/librustc_mir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "rustc_mir"
version = "0.0.0"
edition = "2018"

[lib]
name = "rustc_mir"
Expand All @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/borrow_check/borrow_set.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 ",
Expand Down
38 changes: 23 additions & 15 deletions src/librustc_mir/borrow_check/error_reporting.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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];
Expand All @@ -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)
Expand Down Expand Up @@ -1860,7 +1860,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
fn annotate_argument_and_return_for_borrow(
&self,
borrow: &BorrowData<'tcx>,
) -> Option<AnnotatedBorrowFnSignature> {
) -> Option<AnnotatedBorrowFnSignature<'_>> {
// 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);
Expand Down Expand Up @@ -2081,7 +2081,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
&self,
did: DefId,
sig: ty::PolyFnSig<'tcx>,
) -> Option<AnnotatedBorrowFnSignature> {
) -> Option<AnnotatedBorrowFnSignature<'_>> {
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)?;
Expand Down Expand Up @@ -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<String>) {
pub(super) fn args_span_label(
self,
err: &mut DiagnosticBuilder<'_>,
message: impl Into<String>,
) {
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<String>) {
pub(super) fn var_span_label(
self,
err: &mut DiagnosticBuilder<'_>,
message: impl Into<String>,
) {
if let UseSpans::ClosureUse { var_span, .. } = self {
err.span_label(var_span, message);
}
Expand Down Expand Up @@ -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)
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_mir/borrow_check/flows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -57,7 +57,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
}
}

crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<BorrowIndex>)) {
crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<'_, BorrowIndex>)) {
self.borrows.with_iter_outgoing(op)
}
}
Expand Down Expand Up @@ -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: [");
Expand Down
26 changes: 13 additions & 13 deletions src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_mir/borrow_check/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`"),
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/librustc_mir/borrow_check/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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()
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/borrow_check/nll/constraint_generation.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/borrow_check/nll/constraints/graph.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/nll/constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {:?}",
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs
Original file line number Diff line number Diff line change
@@ -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>,
Expand Down
Loading