Skip to content

Commit e9469a6

Browse files
committed
Auto merge of rust-lang#66886 - mark-i-m:simplify-borrow_check-2, r=matthewjasper
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 rust-lang#66815
2 parents 3eebe05 + bc9582a commit e9469a6

30 files changed

+182
-148
lines changed

Diff for: src/librustc_mir/borrow_check/nll/constraint_generation.rs renamed to src/librustc_mir/borrow_check/constraint_generation.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
use crate::borrow_check::borrow_set::BorrowSet;
2-
use crate::borrow_check::location::LocationTable;
3-
use crate::borrow_check::nll::ToRegionVid;
4-
use crate::borrow_check::nll::facts::AllFacts;
5-
use crate::borrow_check::nll::region_infer::values::LivenessValues;
6-
use crate::borrow_check::places_conflict;
71
use rustc::infer::InferCtxt;
82
use rustc::mir::visit::TyContext;
93
use rustc::mir::visit::Visitor;
@@ -15,6 +9,15 @@ use rustc::ty::fold::TypeFoldable;
159
use rustc::ty::{self, RegionVid, Ty};
1610
use rustc::ty::subst::SubstsRef;
1711

12+
use crate::borrow_check::{
13+
borrow_set::BorrowSet,
14+
location::LocationTable,
15+
nll::ToRegionVid,
16+
facts::AllFacts,
17+
region_infer::values::LivenessValues,
18+
places_conflict,
19+
};
20+
1821
pub(super) fn generate_constraints<'cx, 'tcx>(
1922
infcx: &InferCtxt<'cx, 'tcx>,
2023
param_env: ty::ParamEnv<'tcx>,

Diff for: src/librustc_mir/borrow_check/nll/constraints/graph.rs renamed to src/librustc_mir/borrow_check/constraints/graph.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
use crate::borrow_check::nll::type_check::Locations;
2-
use crate::borrow_check::nll::constraints::OutlivesConstraintIndex;
3-
use crate::borrow_check::nll::constraints::{OutlivesConstraintSet, OutlivesConstraint};
41
use rustc::mir::ConstraintCategory;
52
use rustc::ty::RegionVid;
63
use rustc_data_structures::graph;
74
use rustc_index::vec::IndexVec;
85
use syntax_pos::DUMMY_SP;
96

7+
use crate::borrow_check::{
8+
type_check::Locations,
9+
constraints::OutlivesConstraintIndex,
10+
constraints::{OutlivesConstraintSet, OutlivesConstraint},
11+
};
12+
1013
/// The construct graph organizes the constraints by their end-points.
1114
/// It can be used to view a `R1: R2` constraint as either an edge `R1
1215
/// -> R2` or `R2 -> R1` depending on the direction type `D`.

Diff for: src/librustc_mir/borrow_check/nll/constraints/mod.rs renamed to src/librustc_mir/borrow_check/constraints/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
use crate::borrow_check::nll::type_check::Locations;
21
use rustc::mir::ConstraintCategory;
32
use rustc::ty::RegionVid;
43
use rustc_data_structures::graph::scc::Sccs;
54
use rustc_index::vec::{Idx, IndexVec};
65
use std::fmt;
76
use std::ops::Index;
87

8+
use crate::borrow_check::type_check::Locations;
9+
910
crate mod graph;
1011

1112
/// A set of NLL region constraints. These include "outlives"

Diff for: src/librustc_mir/borrow_check/diagnostics/explain_borrow.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1+
//! Print diagnostics to explain why values are borrowed.
2+
13
use std::collections::VecDeque;
24

3-
use crate::borrow_check::borrow_set::BorrowData;
4-
use crate::borrow_check::nll::region_infer::Cause;
5-
use crate::borrow_check::nll::ConstraintDescription;
6-
use crate::borrow_check::{MirBorrowckCtxt, WriteKind};
75
use rustc::mir::{
86
CastKind, ConstraintCategory, FakeReadCause, Local, Location, Body, Operand, Place, Rvalue,
97
Statement, StatementKind, TerminatorKind,
@@ -16,6 +14,13 @@ use rustc_errors::DiagnosticBuilder;
1614
use syntax_pos::Span;
1715
use syntax_pos::symbol::Symbol;
1816

17+
use crate::borrow_check::{
18+
borrow_set::BorrowData,
19+
region_infer::Cause,
20+
nll::ConstraintDescription,
21+
MirBorrowckCtxt, WriteKind,
22+
};
23+
1924
use super::{UseSpans, find_use, RegionName};
2025

2126
#[derive(Debug)]

Diff for: src/librustc_mir/borrow_check/diagnostics/find_use.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use std::collections::VecDeque;
22
use std::rc::Rc;
33

4-
use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
5-
use crate::borrow_check::nll::ToRegionVid;
4+
use crate::borrow_check::{nll::ToRegionVid, region_infer::{Cause, RegionInferenceContext}};
65
use crate::util::liveness::{self, DefUse};
76
use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor};
87
use rustc::mir::{Local, Location, Body};

Diff for: src/librustc_mir/borrow_check/diagnostics/outlives_suggestion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use syntax_pos::symbol::Symbol;
1313

1414
use smallvec::SmallVec;
1515

16-
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
16+
use crate::borrow_check::region_infer::RegionInferenceContext;
1717

1818
use super::{
1919
RegionName, RegionNameSource, ErrorConstraintInfo, ErrorReportingCtx, RegionErrorNamingCtx,

Diff for: src/librustc_mir/borrow_check/diagnostics/region_errors.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
use crate::borrow_check::nll::constraints::OutlivesConstraint;
2-
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
3-
use crate::borrow_check::nll::type_check::Locations;
4-
use crate::borrow_check::nll::universal_regions::DefiningTy;
5-
use crate::borrow_check::nll::ConstraintDescription;
6-
use crate::borrow_check::Upvar;
7-
use crate::util::borrowck_errors;
1+
//! Error reporting machinery for lifetime errors.
2+
83
use rustc::hir::def_id::DefId;
94
use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
105
use rustc::infer::InferCtxt;
@@ -19,6 +14,17 @@ use syntax::symbol::kw;
1914
use syntax_pos::Span;
2015
use syntax_pos::symbol::Symbol;
2116

17+
use crate::util::borrowck_errors;
18+
19+
use crate::borrow_check::{
20+
constraints::OutlivesConstraint,
21+
region_infer::RegionInferenceContext,
22+
type_check::Locations,
23+
universal_regions::DefiningTy,
24+
nll::ConstraintDescription,
25+
Upvar,
26+
};
27+
2228
use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource, RegionErrorNamingCtx};
2329

2430
impl ConstraintDescription for ConstraintCategory {

Diff for: src/librustc_mir/borrow_check/diagnostics/region_name.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ use rustc_data_structures::fx::FxHashMap;
1515
use syntax_pos::{Span, symbol::Symbol, DUMMY_SP};
1616

1717
use crate::borrow_check::{
18-
nll::region_infer::RegionInferenceContext,
19-
nll::universal_regions::DefiningTy,
18+
diagnostics::region_errors::ErrorReportingCtx,
19+
region_infer::RegionInferenceContext,
20+
universal_regions::DefiningTy,
2021
nll::ToRegionVid,
2122
Upvar,
2223
};
2324

24-
use super::region_errors::ErrorReportingCtx;
25-
2625
/// A name for a particular region used in emitting diagnostics. This name could be a generated
2726
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
2827
#[derive(Debug, Clone)]

Diff for: src/librustc_mir/borrow_check/diagnostics/var_name.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
2-
use crate::borrow_check::nll::ToRegionVid;
1+
use crate::borrow_check::{nll::ToRegionVid, region_infer::RegionInferenceContext};
32
use crate::borrow_check::Upvar;
43
use rustc::mir::{Local, Body};
54
use rustc::ty::{RegionVid, TyCtxt};
File renamed without changes.

Diff for: src/librustc_mir/borrow_check/nll/invalidation.rs renamed to src/librustc_mir/borrow_check/invalidation.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
use crate::borrow_check::borrow_set::BorrowSet;
2-
use crate::borrow_check::location::LocationTable;
3-
use crate::borrow_check::{JustWrite, WriteAndRead};
4-
use crate::borrow_check::{AccessDepth, Deep, Shallow};
5-
use crate::borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write};
6-
use crate::borrow_check::{LocalMutationIsAllowed, MutateMode};
7-
use crate::borrow_check::ArtificialField;
8-
use crate::borrow_check::{ReadKind, WriteKind};
9-
use crate::borrow_check::nll::facts::AllFacts;
10-
use crate::borrow_check::path_utils::*;
11-
use crate::dataflow::indexes::BorrowIndex;
121
use rustc::ty::{self, TyCtxt};
132
use rustc::mir::visit::Visitor;
143
use rustc::mir::{BasicBlock, Location, Body, Place, ReadOnlyBodyAndCache, Rvalue};
@@ -17,6 +6,17 @@ use rustc::mir::TerminatorKind;
176
use rustc::mir::{Operand, BorrowKind};
187
use rustc_data_structures::graph::dominators::Dominators;
198

9+
use crate::dataflow::indexes::BorrowIndex;
10+
11+
use crate::borrow_check::{
12+
borrow_set::BorrowSet,
13+
location::LocationTable,
14+
facts::AllFacts,
15+
path_utils::*,
16+
JustWrite, WriteAndRead, AccessDepth, Deep, Shallow, ReadOrWrite, Activation, Read,
17+
Reservation, Write, LocalMutationIsAllowed, MutateMode, ArtificialField, ReadKind, WriteKind,
18+
};
19+
2020
pub(super) fn generate_invalidates<'tcx>(
2121
tcx: TyCtxt<'tcx>,
2222
param_env: ty::ParamEnv<'tcx>,

Diff for: src/librustc_mir/borrow_check/mod.rs

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! This query borrow-checks the MIR to (further) ensure it is not broken.
22
3-
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
43
use rustc::hir::{self, HirId};
54
use rustc::hir::Node;
65
use rustc::hir::def_id::DefId;
@@ -41,7 +40,6 @@ use crate::dataflow::{do_dataflow, DebugFormatted};
4140
use crate::dataflow::EverInitializedPlaces;
4241
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
4342

44-
use self::borrow_set::{BorrowData, BorrowSet};
4543
use self::flows::Flows;
4644
use self::location::LocationTable;
4745
use self::prefixes::PrefixSet;
@@ -50,17 +48,31 @@ use self::diagnostics::AccessKind;
5048

5149
use self::path_utils::*;
5250

53-
crate mod borrow_set;
5451
mod diagnostics;
5552
mod flows;
5653
mod location;
5754
mod path_utils;
58-
crate mod place_ext;
59-
crate mod places_conflict;
6055
mod prefixes;
6156
mod used_muts;
62-
63-
pub(crate) mod nll;
57+
mod constraint_generation;
58+
mod facts;
59+
mod invalidation;
60+
mod renumber;
61+
mod member_constraints;
62+
mod constraints;
63+
mod universal_regions;
64+
mod type_check;
65+
mod region_infer;
66+
mod borrow_set;
67+
mod place_ext;
68+
mod places_conflict;
69+
mod nll;
70+
71+
crate use region_infer::RegionInferenceContext;
72+
crate use borrow_set::{BorrowSet, BorrowData};
73+
crate use places_conflict::{places_conflict, PlaceConflictBias};
74+
crate use place_ext::PlaceExt;
75+
crate use nll::ToRegionVid;
6476

6577
// FIXME(eddyb) perhaps move this somewhere more centrally.
6678
#[derive(Debug)]

Diff for: src/librustc_mir/borrow_check/nll/mod.rs renamed to src/librustc_mir/borrow_check/nll.rs

+16-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
use crate::borrow_check::borrow_set::BorrowSet;
2-
use crate::borrow_check::location::LocationTable;
3-
use crate::borrow_check::nll::facts::AllFactsExt;
4-
use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints};
5-
use crate::borrow_check::nll::region_infer::values::RegionValueElements;
6-
use crate::dataflow::move_paths::{InitLocation, MoveData, InitKind};
7-
use crate::dataflow::FlowAtLocation;
8-
use crate::dataflow::MaybeInitializedPlaces;
9-
use crate::transform::MirSource;
10-
use crate::borrow_check::Upvar;
1+
//! The entry point of the NLL borrow checker.
2+
113
use rustc::hir::def_id::DefId;
124
use rustc::infer::InferCtxt;
135
use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements,
@@ -27,24 +19,23 @@ use syntax::symbol::sym;
2719

2820
use self::mir_util::PassWhere;
2921
use polonius_engine::{Algorithm, Output};
22+
3023
use crate::util as mir_util;
3124
use crate::util::pretty;
25+
use crate::dataflow::move_paths::{InitLocation, MoveData, InitKind};
26+
use crate::dataflow::FlowAtLocation;
27+
use crate::dataflow::MaybeInitializedPlaces;
28+
use crate::transform::MirSource;
3229

33-
mod constraint_generation;
34-
mod facts;
35-
mod invalidation;
36-
mod renumber;
37-
38-
mod member_constraints;
39-
40-
crate mod constraints;
41-
crate mod universal_regions;
42-
crate mod type_check;
43-
crate mod region_infer;
44-
45-
use self::facts::{AllFacts, RustcFacts};
46-
use self::region_infer::RegionInferenceContext;
47-
use self::universal_regions::UniversalRegions;
30+
use crate::borrow_check::{
31+
borrow_set::BorrowSet,
32+
location::LocationTable,
33+
facts::{AllFacts, AllFactsExt, RustcFacts},
34+
region_infer::{RegionInferenceContext, values::RegionValueElements},
35+
universal_regions::UniversalRegions,
36+
type_check::{self, MirTypeckResults, MirTypeckRegionConstraints},
37+
Upvar, renumber, constraint_generation, invalidation,
38+
};
4839

4940
crate type PoloniusOutput = Output<RustcFacts>;
5041

Diff for: src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs renamed to src/librustc_mir/borrow_check/region_infer/graphviz.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
//! libgraphviz traits, specialized to attaching borrowck analysis
33
//! data to rendered labels.
44
5-
use super::*;
6-
use crate::borrow_check::nll::constraints::OutlivesConstraint;
75
use std::borrow::Cow;
86
use std::io::{self, Write};
97

8+
use super::*;
9+
use crate::borrow_check::constraints::OutlivesConstraint;
10+
1011
impl<'tcx> RegionInferenceContext<'tcx> {
1112
/// Write out the region constraint graph.
1213
crate fn dump_graphviz_raw_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> {

Diff for: src/librustc_mir/borrow_check/nll/region_infer/mod.rs renamed to src/librustc_mir/borrow_check/region_infer/mod.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,26 @@ use syntax_pos::Span;
2323
use syntax_pos::symbol::Symbol;
2424

2525
use crate::borrow_check::{
26-
nll::{
27-
constraints::{
28-
graph::NormalConstraintGraph,
29-
ConstraintSccIndex,
30-
OutlivesConstraint,
31-
OutlivesConstraintSet,
32-
},
33-
member_constraints::{MemberConstraintSet, NllMemberConstraintIndex},
34-
region_infer::values::{
35-
PlaceholderIndices, RegionElement, ToElementIndex
36-
},
37-
type_check::{free_region_relations::UniversalRegionRelations, Locations},
26+
constraints::{
27+
graph::NormalConstraintGraph,
28+
ConstraintSccIndex,
29+
OutlivesConstraint,
30+
OutlivesConstraintSet,
3831
},
32+
member_constraints::{MemberConstraintSet, NllMemberConstraintIndex},
33+
region_infer::values::{
34+
PlaceholderIndices, RegionElement, ToElementIndex, LivenessValues, RegionValueElements,
35+
RegionValues,
36+
},
37+
type_check::{free_region_relations::UniversalRegionRelations, Locations},
3938
diagnostics::{
4039
OutlivesSuggestionBuilder, RegionErrorNamingCtx,
4140
},
41+
nll::{ToRegionVid, PoloniusOutput},
42+
universal_regions::UniversalRegions,
4243
Upvar,
4344
};
4445

45-
use self::values::{LivenessValues, RegionValueElements, RegionValues};
46-
use super::universal_regions::UniversalRegions;
47-
use super::{PoloniusOutput, ToRegionVid};
48-
4946
mod dump_mir;
5047
mod graphviz;
5148

Diff for: src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs renamed to src/librustc_mir/borrow_check/type_check/constraint_conversion.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
use crate::borrow_check::nll::constraints::OutlivesConstraint;
2-
use crate::borrow_check::nll::region_infer::TypeTest;
3-
use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
4-
use crate::borrow_check::nll::universal_regions::UniversalRegions;
5-
use crate::borrow_check::nll::ToRegionVid;
61
use rustc::infer::canonical::QueryRegionConstraints;
72
use rustc::infer::canonical::QueryOutlivesConstraint;
83
use rustc::infer::outlives::env::RegionBoundPairs;
@@ -14,6 +9,14 @@ use rustc::ty::subst::GenericArgKind;
149
use rustc::ty::{self, TyCtxt};
1510
use syntax_pos::DUMMY_SP;
1611

12+
use crate::borrow_check::{
13+
constraints::OutlivesConstraint,
14+
region_infer::TypeTest,
15+
type_check::{Locations, MirTypeckRegionConstraints},
16+
universal_regions::UniversalRegions,
17+
nll::ToRegionVid,
18+
};
19+
1720
crate struct ConstraintConversion<'a, 'tcx> {
1821
infcx: &'a InferCtxt<'a, 'tcx>,
1922
tcx: TyCtxt<'tcx>,

0 commit comments

Comments
 (0)