Skip to content

Commit 725af30

Browse files
committed
librustc_mir => 2018
1 parent 626e74d commit 725af30

File tree

110 files changed

+514
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+514
-505
lines changed

src/librustc_mir/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = ["The Rust Project Developers"]
33
name = "rustc_mir"
44
version = "0.0.0"
5+
edition = "2018"
56

67
[lib]
78
name = "rustc_mir"
@@ -12,7 +13,7 @@ crate-type = ["dylib"]
1213
arena = { path = "../libarena" }
1314
bitflags = "1.0"
1415
either = "1.5.0"
15-
graphviz = { path = "../libgraphviz" }
16+
dot = { path = "../libgraphviz", package = "graphviz" }
1617
log = "0.4"
1718
log_settings = "0.1.1"
1819
polonius-engine = "0.6.2"

src/librustc_mir/borrow_check/borrow_set.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use borrow_check::place_ext::PlaceExt;
2-
use borrow_check::nll::ToRegionVid;
3-
use dataflow::indexes::BorrowIndex;
4-
use dataflow::move_paths::MoveData;
1+
use crate::borrow_check::place_ext::PlaceExt;
2+
use crate::borrow_check::nll::ToRegionVid;
3+
use crate::dataflow::indexes::BorrowIndex;
4+
use crate::dataflow::move_paths::MoveData;
55
use rustc::mir::traversal;
66
use rustc::mir::visit::{
77
PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext
@@ -72,7 +72,7 @@ crate struct BorrowData<'tcx> {
7272
}
7373

7474
impl<'tcx> fmt::Display for BorrowData<'tcx> {
75-
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
75+
fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
7676
let kind = match self.kind {
7777
mir::BorrowKind::Shared => "",
7878
mir::BorrowKind::Shallow => "shallow ",

src/librustc_mir/borrow_check/error_reporting.rs

+23-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use borrow_check::nll::explain_borrow::BorrowExplanation;
2-
use borrow_check::nll::region_infer::{RegionName, RegionNameSource};
3-
use borrow_check::prefixes::IsPrefixOf;
4-
use borrow_check::WriteKind;
1+
use crate::borrow_check::nll::explain_borrow::BorrowExplanation;
2+
use crate::borrow_check::nll::region_infer::{RegionName, RegionNameSource};
3+
use crate::borrow_check::prefixes::IsPrefixOf;
4+
use crate::borrow_check::WriteKind;
55
use rustc::hir;
66
use rustc::hir::def_id::DefId;
77
use rustc::middle::region::ScopeTree;
@@ -22,10 +22,10 @@ use syntax_pos::Span;
2222
use super::borrow_set::BorrowData;
2323
use super::{Context, MirBorrowckCtxt};
2424
use super::{InitializationRequiringAction, PrefixSet};
25-
use dataflow::drop_flag_effects;
26-
use dataflow::move_paths::indexes::MoveOutIndex;
27-
use dataflow::move_paths::MovePathIndex;
28-
use util::borrowck_errors::{BorrowckErrors, Origin};
25+
use crate::dataflow::drop_flag_effects;
26+
use crate::dataflow::move_paths::indexes::MoveOutIndex;
27+
use crate::dataflow::move_paths::MovePathIndex;
28+
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
2929

3030
#[derive(Debug)]
3131
struct MoveSite {
@@ -1726,7 +1726,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17261726
}
17271727

17281728
/// End-user visible description of the `field`nth field of `base`
1729-
fn describe_field(&self, base: &Place, field: Field) -> String {
1729+
fn describe_field(&self, base: &Place<'_>, field: Field) -> String {
17301730
match *base {
17311731
Place::Local(local) => {
17321732
let local = &self.mir.local_decls[local];
@@ -1751,7 +1751,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17511751
}
17521752

17531753
/// End-user visible description of the `field_index`nth field of `ty`
1754-
fn describe_field_from_ty(&self, ty: &ty::Ty, field: Field) -> String {
1754+
fn describe_field_from_ty(&self, ty: &ty::Ty<'_>, field: Field) -> String {
17551755
if ty.is_box() {
17561756
// If the type is a box, the field is described from the boxed type
17571757
self.describe_field_from_ty(&ty.boxed_ty(), field)
@@ -1860,7 +1860,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
18601860
fn annotate_argument_and_return_for_borrow(
18611861
&self,
18621862
borrow: &BorrowData<'tcx>,
1863-
) -> Option<AnnotatedBorrowFnSignature> {
1863+
) -> Option<AnnotatedBorrowFnSignature<'_>> {
18641864
// Define a fallback for when we can't match a closure.
18651865
let fallback = || {
18661866
let is_closure = self.infcx.tcx.is_closure(self.mir_def_id);
@@ -2081,7 +2081,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
20812081
&self,
20822082
did: DefId,
20832083
sig: ty::PolyFnSig<'tcx>,
2084-
) -> Option<AnnotatedBorrowFnSignature> {
2084+
) -> Option<AnnotatedBorrowFnSignature<'_>> {
20852085
debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
20862086
let is_closure = self.infcx.tcx.is_closure(did);
20872087
let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?;
@@ -2368,14 +2368,22 @@ impl UseSpans {
23682368
}
23692369

23702370
// Add a span label to the arguments of the closure, if it exists.
2371-
pub(super) fn args_span_label(self, err: &mut DiagnosticBuilder, message: impl Into<String>) {
2371+
pub(super) fn args_span_label(
2372+
self,
2373+
err: &mut DiagnosticBuilder<'_>,
2374+
message: impl Into<String>,
2375+
) {
23722376
if let UseSpans::ClosureUse { args_span, .. } = self {
23732377
err.span_label(args_span, message);
23742378
}
23752379
}
23762380

23772381
// Add a span label to the use of the captured variable, if it exists.
2378-
pub(super) fn var_span_label(self, err: &mut DiagnosticBuilder, message: impl Into<String>) {
2382+
pub(super) fn var_span_label(
2383+
self,
2384+
err: &mut DiagnosticBuilder<'_>,
2385+
message: impl Into<String>,
2386+
) {
23792387
if let UseSpans::ClosureUse { var_span, .. } = self {
23802388
err.span_label(var_span, message);
23812389
}
@@ -2563,7 +2571,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
25632571

25642572
/// Helper to retrieve span(s) of given borrow from the current MIR
25652573
/// representation
2566-
pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData) -> UseSpans {
2574+
pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData<'_>) -> UseSpans {
25672575
let span = self.mir.source_info(borrow.reserve_location).span;
25682576
self.borrow_spans(span, borrow.reserve_location)
25692577
}

src/librustc_mir/borrow_check/flows.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ use rustc::mir::{BasicBlock, Location};
77
use rustc::ty::RegionVid;
88
use rustc_data_structures::bit_set::BitIter;
99

10-
use borrow_check::location::LocationIndex;
10+
use crate::borrow_check::location::LocationIndex;
1111

1212
use polonius_engine::Output;
1313

14-
use dataflow::move_paths::indexes::BorrowIndex;
15-
use dataflow::move_paths::HasMoveData;
16-
use dataflow::Borrows;
17-
use dataflow::EverInitializedPlaces;
18-
use dataflow::{FlowAtLocation, FlowsAtLocation};
19-
use dataflow::MaybeUninitializedPlaces;
14+
use crate::dataflow::move_paths::indexes::BorrowIndex;
15+
use crate::dataflow::move_paths::HasMoveData;
16+
use crate::dataflow::Borrows;
17+
use crate::dataflow::EverInitializedPlaces;
18+
use crate::dataflow::{FlowAtLocation, FlowsAtLocation};
19+
use crate::dataflow::MaybeUninitializedPlaces;
2020
use either::Either;
2121
use std::fmt;
2222
use std::rc::Rc;
@@ -57,7 +57,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
5757
}
5858
}
5959

60-
crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<BorrowIndex>)) {
60+
crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<'_, BorrowIndex>)) {
6161
self.borrows.with_iter_outgoing(op)
6262
}
6363
}
@@ -93,7 +93,7 @@ impl<'b, 'gcx, 'tcx> FlowsAtLocation for Flows<'b, 'gcx, 'tcx> {
9393
}
9494

9595
impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
96-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
96+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
9797
let mut s = String::new();
9898

9999
s.push_str("borrows in effect: [");

src/librustc_mir/borrow_check/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This query borrow-checks the MIR to (further) ensure it is not broken.
22
3-
use borrow_check::nll::region_infer::RegionInferenceContext;
3+
use crate::borrow_check::nll::region_infer::RegionInferenceContext;
44
use rustc::hir;
55
use rustc::hir::Node;
66
use rustc::hir::def_id::DefId;
@@ -25,16 +25,16 @@ use std::collections::BTreeMap;
2525

2626
use syntax_pos::Span;
2727

28-
use dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
29-
use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError};
30-
use dataflow::Borrows;
31-
use dataflow::DataflowResultsConsumer;
32-
use dataflow::FlowAtLocation;
33-
use dataflow::MoveDataParamEnv;
34-
use dataflow::{do_dataflow, DebugFormatted};
35-
use dataflow::EverInitializedPlaces;
36-
use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
37-
use util::borrowck_errors::{BorrowckErrors, Origin};
28+
use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
29+
use crate::dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError};
30+
use crate::dataflow::Borrows;
31+
use crate::dataflow::DataflowResultsConsumer;
32+
use crate::dataflow::FlowAtLocation;
33+
use crate::dataflow::MoveDataParamEnv;
34+
use crate::dataflow::{do_dataflow, DebugFormatted};
35+
use crate::dataflow::EverInitializedPlaces;
36+
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
37+
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
3838

3939
use self::borrow_set::{BorrowData, BorrowSet};
4040
use self::flows::Flows;
@@ -59,7 +59,7 @@ mod used_muts;
5959

6060
pub(crate) mod nll;
6161

62-
pub fn provide(providers: &mut Providers) {
62+
pub fn provide(providers: &mut Providers<'_>) {
6363
*providers = Providers {
6464
mir_borrowck,
6565
..*providers
@@ -108,7 +108,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC
108108
}
109109

110110
let opt_closure_req = tcx.infer_ctxt().enter(|infcx| {
111-
let input_mir: &Mir = &input_mir.borrow();
111+
let input_mir: &Mir<'_> = &input_mir.borrow();
112112
do_mir_borrowck(&infcx, input_mir, def_id)
113113
});
114114
debug!("mir_borrowck done");

src/librustc_mir/borrow_check/move_errors.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use rustc::ty;
66
use rustc_errors::{DiagnosticBuilder,Applicability};
77
use syntax_pos::Span;
88

9-
use borrow_check::MirBorrowckCtxt;
10-
use borrow_check::prefixes::PrefixSet;
11-
use dataflow::move_paths::{
9+
use crate::borrow_check::MirBorrowckCtxt;
10+
use crate::borrow_check::prefixes::PrefixSet;
11+
use crate::dataflow::move_paths::{
1212
IllegalMoveOrigin, IllegalMoveOriginKind, InitLocation,
1313
LookupResult, MoveError, MovePathIndex,
1414
};
15-
use util::borrowck_errors::{BorrowckErrors, Origin};
15+
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
1616

1717
// Often when desugaring a pattern match we may have many individual moves in
1818
// MIR that are all part of one operation from the user's point-of-view. For
@@ -63,7 +63,7 @@ enum BorrowedContentSource {
6363
}
6464

6565
impl Display for BorrowedContentSource {
66-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
66+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6767
match *self {
6868
BorrowedContentSource::Arc => write!(f, "an `Arc`"),
6969
BorrowedContentSource::Rc => write!(f, "an `Rc`"),
@@ -240,7 +240,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
240240

241241
fn report(&mut self, error: GroupedMoveError<'tcx>) {
242242
let (mut err, err_span) = {
243-
let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind) =
243+
let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind<'_>) =
244244
match error {
245245
GroupedMoveError::MovesFromPlace {
246246
span,

src/librustc_mir/borrow_check/mutability_errors.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use rustc_data_structures::indexed_vec::Idx;
88
use syntax_pos::Span;
99
use syntax_pos::symbol::keywords;
1010

11-
use dataflow::move_paths::InitLocation;
12-
use borrow_check::MirBorrowckCtxt;
13-
use util::borrowck_errors::{BorrowckErrors, Origin};
14-
use util::collect_writes::FindAssignments;
15-
use util::suggest_ref_mut;
11+
use crate::dataflow::move_paths::InitLocation;
12+
use crate::borrow_check::MirBorrowckCtxt;
13+
use crate::util::borrowck_errors::{BorrowckErrors, Origin};
14+
use crate::util::collect_writes::FindAssignments;
15+
use crate::util::suggest_ref_mut;
1616
use rustc_errors::Applicability;
1717

1818
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -611,7 +611,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
611611
})
612612
}
613613

614-
fn is_closure_or_generator(ty: ty::Ty) -> bool {
614+
fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
615615
ty.is_closure() || ty.is_generator()
616616
}
617617

src/librustc_mir/borrow_check/nll/constraint_generation.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use borrow_check::borrow_set::BorrowSet;
2-
use borrow_check::location::LocationTable;
3-
use borrow_check::nll::ToRegionVid;
4-
use borrow_check::nll::facts::AllFacts;
5-
use borrow_check::nll::region_infer::values::LivenessValues;
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;
66
use rustc::infer::InferCtxt;
77
use rustc::mir::visit::TyContext;
88
use rustc::mir::visit::Visitor;

src/librustc_mir/borrow_check/nll/constraints/graph.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use borrow_check::nll::type_check::Locations;
2-
use borrow_check::nll::constraints::ConstraintIndex;
3-
use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
1+
use crate::borrow_check::nll::type_check::Locations;
2+
use crate::borrow_check::nll::constraints::ConstraintIndex;
3+
use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
44
use rustc::mir::ConstraintCategory;
55
use rustc::ty::RegionVid;
66
use rustc_data_structures::graph;

src/librustc_mir/borrow_check/nll/constraints/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rustc::mir::ConstraintCategory;
22
use rustc::ty::RegionVid;
33
use rustc_data_structures::graph::scc::Sccs;
44
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
5-
use borrow_check::nll::type_check::Locations;
5+
use crate::borrow_check::nll::type_check::Locations;
66

77
use std::fmt;
88
use std::ops::Deref;
@@ -84,7 +84,7 @@ pub struct OutlivesConstraint {
8484
}
8585

8686
impl fmt::Debug for OutlivesConstraint {
87-
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
87+
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
8888
write!(
8989
formatter,
9090
"({:?}: {:?}) due to {:?}",

src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs

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

4-
use borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
5-
use borrow_check::nll::ToRegionVid;
4+
use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
5+
use crate::borrow_check::nll::ToRegionVid;
6+
use crate::util::liveness::{self, DefUse};
67
use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor};
78
use rustc::mir::{Local, Location, Mir};
89
use rustc::ty::{RegionVid, TyCtxt};
910
use rustc_data_structures::fx::FxHashSet;
10-
use util::liveness::{self, DefUse};
1111

1212
crate fn find<'tcx>(
1313
mir: &Mir<'tcx>,

0 commit comments

Comments
 (0)