Skip to content

Commit

Permalink
Auto merge of #66886 - mark-i-m:simplify-borrow_check-2, r=matthewjasper
Browse files Browse the repository at this point in the history
Remove the borrow check::nll submodule

NLL is the only borrow checker now, so no need to have a separate submodule.

@rustbot modify labels: +S-blocked

Waiting on #66815
  • Loading branch information
bors committed Dec 12, 2019
2 parents 3eebe05 + bc9582a commit e9469a6
Show file tree
Hide file tree
Showing 30 changed files with 182 additions and 148 deletions.
@@ -1,9 +1,3 @@
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 crate::borrow_check::places_conflict;
use rustc::infer::InferCtxt;
use rustc::mir::visit::TyContext;
use rustc::mir::visit::Visitor;
Expand All @@ -15,6 +9,15 @@ use rustc::ty::fold::TypeFoldable;
use rustc::ty::{self, RegionVid, Ty};
use rustc::ty::subst::SubstsRef;

use crate::borrow_check::{
borrow_set::BorrowSet,
location::LocationTable,
nll::ToRegionVid,
facts::AllFacts,
region_infer::values::LivenessValues,
places_conflict,
};

pub(super) fn generate_constraints<'cx, 'tcx>(
infcx: &InferCtxt<'cx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
Expand Down
@@ -1,12 +1,15 @@
use crate::borrow_check::nll::type_check::Locations;
use crate::borrow_check::nll::constraints::OutlivesConstraintIndex;
use crate::borrow_check::nll::constraints::{OutlivesConstraintSet, OutlivesConstraint};
use rustc::mir::ConstraintCategory;
use rustc::ty::RegionVid;
use rustc_data_structures::graph;
use rustc_index::vec::IndexVec;
use syntax_pos::DUMMY_SP;

use crate::borrow_check::{
type_check::Locations,
constraints::OutlivesConstraintIndex,
constraints::{OutlivesConstraintSet, OutlivesConstraint},
};

/// The construct graph organizes the constraints by their end-points.
/// It can be used to view a `R1: R2` constraint as either an edge `R1
/// -> R2` or `R2 -> R1` depending on the direction type `D`.
Expand Down
@@ -1,11 +1,12 @@
use crate::borrow_check::nll::type_check::Locations;
use rustc::mir::ConstraintCategory;
use rustc::ty::RegionVid;
use rustc_data_structures::graph::scc::Sccs;
use rustc_index::vec::{Idx, IndexVec};
use std::fmt;
use std::ops::Index;

use crate::borrow_check::type_check::Locations;

crate mod graph;

/// A set of NLL region constraints. These include "outlives"
Expand Down
13 changes: 9 additions & 4 deletions src/librustc_mir/borrow_check/diagnostics/explain_borrow.rs
@@ -1,9 +1,7 @@
//! Print diagnostics to explain why values are borrowed.

use std::collections::VecDeque;

use crate::borrow_check::borrow_set::BorrowData;
use crate::borrow_check::nll::region_infer::Cause;
use crate::borrow_check::nll::ConstraintDescription;
use crate::borrow_check::{MirBorrowckCtxt, WriteKind};
use rustc::mir::{
CastKind, ConstraintCategory, FakeReadCause, Local, Location, Body, Operand, Place, Rvalue,
Statement, StatementKind, TerminatorKind,
Expand All @@ -16,6 +14,13 @@ use rustc_errors::DiagnosticBuilder;
use syntax_pos::Span;
use syntax_pos::symbol::Symbol;

use crate::borrow_check::{
borrow_set::BorrowData,
region_infer::Cause,
nll::ConstraintDescription,
MirBorrowckCtxt, WriteKind,
};

use super::{UseSpans, find_use, RegionName};

#[derive(Debug)]
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/borrow_check/diagnostics/find_use.rs
@@ -1,8 +1,7 @@
use std::collections::VecDeque;
use std::rc::Rc;

use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
use crate::borrow_check::nll::ToRegionVid;
use crate::borrow_check::{nll::ToRegionVid, region_infer::{Cause, RegionInferenceContext}};
use crate::util::liveness::{self, DefUse};
use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor};
use rustc::mir::{Local, Location, Body};
Expand Down
Expand Up @@ -13,7 +13,7 @@ use syntax_pos::symbol::Symbol;

use smallvec::SmallVec;

use crate::borrow_check::nll::region_infer::RegionInferenceContext;
use crate::borrow_check::region_infer::RegionInferenceContext;

use super::{
RegionName, RegionNameSource, ErrorConstraintInfo, ErrorReportingCtx, RegionErrorNamingCtx,
Expand Down
20 changes: 13 additions & 7 deletions src/librustc_mir/borrow_check/diagnostics/region_errors.rs
@@ -1,10 +1,5 @@
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::borrow_check::Upvar;
use crate::util::borrowck_errors;
//! Error reporting machinery for lifetime errors.

use rustc::hir::def_id::DefId;
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
use rustc::infer::InferCtxt;
Expand All @@ -19,6 +14,17 @@ use syntax::symbol::kw;
use syntax_pos::Span;
use syntax_pos::symbol::Symbol;

use crate::util::borrowck_errors;

use crate::borrow_check::{
constraints::OutlivesConstraint,
region_infer::RegionInferenceContext,
type_check::Locations,
universal_regions::DefiningTy,
nll::ConstraintDescription,
Upvar,
};

use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource, RegionErrorNamingCtx};

impl ConstraintDescription for ConstraintCategory {
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_mir/borrow_check/diagnostics/region_name.rs
Expand Up @@ -15,14 +15,13 @@ use rustc_data_structures::fx::FxHashMap;
use syntax_pos::{Span, symbol::Symbol, DUMMY_SP};

use crate::borrow_check::{
nll::region_infer::RegionInferenceContext,
nll::universal_regions::DefiningTy,
diagnostics::region_errors::ErrorReportingCtx,
region_infer::RegionInferenceContext,
universal_regions::DefiningTy,
nll::ToRegionVid,
Upvar,
};

use super::region_errors::ErrorReportingCtx;

/// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
#[derive(Debug, Clone)]
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_mir/borrow_check/diagnostics/var_name.rs
@@ -1,5 +1,4 @@
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
use crate::borrow_check::nll::ToRegionVid;
use crate::borrow_check::{nll::ToRegionVid, region_infer::RegionInferenceContext};
use crate::borrow_check::Upvar;
use rustc::mir::{Local, Body};
use rustc::ty::{RegionVid, TyCtxt};
Expand Down
File renamed without changes.
@@ -1,14 +1,3 @@
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::{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::indexes::BorrowIndex;
use rustc::ty::{self, TyCtxt};
use rustc::mir::visit::Visitor;
use rustc::mir::{BasicBlock, Location, Body, Place, ReadOnlyBodyAndCache, Rvalue};
Expand All @@ -17,6 +6,17 @@ use rustc::mir::TerminatorKind;
use rustc::mir::{Operand, BorrowKind};
use rustc_data_structures::graph::dominators::Dominators;

use crate::dataflow::indexes::BorrowIndex;

use crate::borrow_check::{
borrow_set::BorrowSet,
location::LocationTable,
facts::AllFacts,
path_utils::*,
JustWrite, WriteAndRead, AccessDepth, Deep, Shallow, ReadOrWrite, Activation, Read,
Reservation, Write, LocalMutationIsAllowed, MutateMode, ArtificialField, ReadKind, WriteKind,
};

pub(super) fn generate_invalidates<'tcx>(
tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
Expand Down
26 changes: 19 additions & 7 deletions src/librustc_mir/borrow_check/mod.rs
@@ -1,6 +1,5 @@
//! This query borrow-checks the MIR to (further) ensure it is not broken.

use crate::borrow_check::nll::region_infer::RegionInferenceContext;
use rustc::hir::{self, HirId};
use rustc::hir::Node;
use rustc::hir::def_id::DefId;
Expand Down Expand Up @@ -41,7 +40,6 @@ use crate::dataflow::{do_dataflow, DebugFormatted};
use crate::dataflow::EverInitializedPlaces;
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};

use self::borrow_set::{BorrowData, BorrowSet};
use self::flows::Flows;
use self::location::LocationTable;
use self::prefixes::PrefixSet;
Expand All @@ -50,17 +48,31 @@ use self::diagnostics::AccessKind;

use self::path_utils::*;

crate mod borrow_set;
mod diagnostics;
mod flows;
mod location;
mod path_utils;
crate mod place_ext;
crate mod places_conflict;
mod prefixes;
mod used_muts;

pub(crate) mod nll;
mod constraint_generation;
mod facts;
mod invalidation;
mod renumber;
mod member_constraints;
mod constraints;
mod universal_regions;
mod type_check;
mod region_infer;
mod borrow_set;
mod place_ext;
mod places_conflict;
mod nll;

crate use region_infer::RegionInferenceContext;
crate use borrow_set::{BorrowSet, BorrowData};
crate use places_conflict::{places_conflict, PlaceConflictBias};
crate use place_ext::PlaceExt;
crate use nll::ToRegionVid;

// FIXME(eddyb) perhaps move this somewhere more centrally.
#[derive(Debug)]
Expand Down
@@ -1,13 +1,5 @@
use crate::borrow_check::borrow_set::BorrowSet;
use crate::borrow_check::location::LocationTable;
use crate::borrow_check::nll::facts::AllFactsExt;
use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints};
use crate::borrow_check::nll::region_infer::values::RegionValueElements;
use crate::dataflow::move_paths::{InitLocation, MoveData, InitKind};
use crate::dataflow::FlowAtLocation;
use crate::dataflow::MaybeInitializedPlaces;
use crate::transform::MirSource;
use crate::borrow_check::Upvar;
//! The entry point of the NLL borrow checker.

use rustc::hir::def_id::DefId;
use rustc::infer::InferCtxt;
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements,
Expand All @@ -27,24 +19,23 @@ use syntax::symbol::sym;

use self::mir_util::PassWhere;
use polonius_engine::{Algorithm, Output};

use crate::util as mir_util;
use crate::util::pretty;
use crate::dataflow::move_paths::{InitLocation, MoveData, InitKind};
use crate::dataflow::FlowAtLocation;
use crate::dataflow::MaybeInitializedPlaces;
use crate::transform::MirSource;

mod constraint_generation;
mod facts;
mod invalidation;
mod renumber;

mod member_constraints;

crate mod constraints;
crate mod universal_regions;
crate mod type_check;
crate mod region_infer;

use self::facts::{AllFacts, RustcFacts};
use self::region_infer::RegionInferenceContext;
use self::universal_regions::UniversalRegions;
use crate::borrow_check::{
borrow_set::BorrowSet,
location::LocationTable,
facts::{AllFacts, AllFactsExt, RustcFacts},
region_infer::{RegionInferenceContext, values::RegionValueElements},
universal_regions::UniversalRegions,
type_check::{self, MirTypeckResults, MirTypeckRegionConstraints},
Upvar, renumber, constraint_generation, invalidation,
};

crate type PoloniusOutput = Output<RustcFacts>;

Expand Down
Expand Up @@ -2,11 +2,12 @@
//! libgraphviz traits, specialized to attaching borrowck analysis
//! data to rendered labels.

use super::*;
use crate::borrow_check::nll::constraints::OutlivesConstraint;
use std::borrow::Cow;
use std::io::{self, Write};

use super::*;
use crate::borrow_check::constraints::OutlivesConstraint;

impl<'tcx> RegionInferenceContext<'tcx> {
/// Write out the region constraint graph.
crate fn dump_graphviz_raw_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> {
Expand Down
Expand Up @@ -23,29 +23,26 @@ use syntax_pos::Span;
use syntax_pos::symbol::Symbol;

use crate::borrow_check::{
nll::{
constraints::{
graph::NormalConstraintGraph,
ConstraintSccIndex,
OutlivesConstraint,
OutlivesConstraintSet,
},
member_constraints::{MemberConstraintSet, NllMemberConstraintIndex},
region_infer::values::{
PlaceholderIndices, RegionElement, ToElementIndex
},
type_check::{free_region_relations::UniversalRegionRelations, Locations},
constraints::{
graph::NormalConstraintGraph,
ConstraintSccIndex,
OutlivesConstraint,
OutlivesConstraintSet,
},
member_constraints::{MemberConstraintSet, NllMemberConstraintIndex},
region_infer::values::{
PlaceholderIndices, RegionElement, ToElementIndex, LivenessValues, RegionValueElements,
RegionValues,
},
type_check::{free_region_relations::UniversalRegionRelations, Locations},
diagnostics::{
OutlivesSuggestionBuilder, RegionErrorNamingCtx,
},
nll::{ToRegionVid, PoloniusOutput},
universal_regions::UniversalRegions,
Upvar,
};

use self::values::{LivenessValues, RegionValueElements, RegionValues};
use super::universal_regions::UniversalRegions;
use super::{PoloniusOutput, ToRegionVid};

mod dump_mir;
mod graphviz;

Expand Down
File renamed without changes.
@@ -1,8 +1,3 @@
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::QueryRegionConstraints;
use rustc::infer::canonical::QueryOutlivesConstraint;
use rustc::infer::outlives::env::RegionBoundPairs;
Expand All @@ -14,6 +9,14 @@ use rustc::ty::subst::GenericArgKind;
use rustc::ty::{self, TyCtxt};
use syntax_pos::DUMMY_SP;

use crate::borrow_check::{
constraints::OutlivesConstraint,
region_infer::TypeTest,
type_check::{Locations, MirTypeckRegionConstraints},
universal_regions::UniversalRegions,
nll::ToRegionVid,
};

crate struct ConstraintConversion<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
tcx: TyCtxt<'tcx>,
Expand Down

0 comments on commit e9469a6

Please sign in to comment.