Skip to content

Commit c3d365f

Browse files
authored
Rollup merge of rust-lang#58260 - taiki-e:librustc_borrowck-2018, r=Centril
librustc_borrowck => 2018 Transitions `librustc_borrowck` to Rust 2018; cc rust-lang#58099 r? @Centril
2 parents d7a4dd1 + a2c4a36 commit c3d365f

13 files changed

+71
-69
lines changed

src/librustc_borrowck/Cargo.toml

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

67
[lib]
78
name = "rustc_borrowck"
@@ -13,8 +14,10 @@ test = false
1314
log = "0.4"
1415
syntax = { path = "../libsyntax" }
1516
syntax_pos = { path = "../libsyntax_pos" }
16-
graphviz = { path = "../libgraphviz" }
17+
# for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
18+
# refers to the borrowck-specific graphviz adapter traits.
19+
dot = { path = "../libgraphviz", package = "graphviz" }
1720
rustc = { path = "../librustc" }
1821
rustc_mir = { path = "../librustc_mir" }
19-
rustc_errors = { path = "../librustc_errors" }
20-
rustc_data_structures = { path = "../librustc_data_structures" }
22+
errors = { path = "../librustc_errors", package = "rustc_errors" }
23+
rustc_data_structures = { path = "../librustc_data_structures" }

src/librustc_borrowck/borrowck/check_loans.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// 3. assignments do not affect things loaned out as immutable
88
// 4. moves do not affect things loaned out in any way
99

10-
use self::UseError::*;
10+
use UseError::*;
1111

12-
use borrowck::*;
13-
use borrowck::InteriorKind::{InteriorElement, InteriorField};
12+
use crate::borrowck::*;
13+
use crate::borrowck::InteriorKind::{InteriorElement, InteriorField};
1414
use rustc::middle::expr_use_visitor as euv;
1515
use rustc::middle::expr_use_visitor::MutateMode;
1616
use rustc::middle::mem_categorization as mc;
@@ -22,6 +22,7 @@ use syntax_pos::Span;
2222
use rustc::hir;
2323
use rustc::hir::Node;
2424
use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
25+
use log::debug;
2526

2627
use std::rc::Rc;
2728

@@ -101,7 +102,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> {
101102

102103
fn matched_pat(&mut self,
103104
_matched_pat: &hir::Pat,
104-
_cmt: &mc::cmt_,
105+
_cmt: &mc::cmt_<'_>,
105106
_mode: euv::MatchMode) { }
106107

107108
fn consume_pat(&mut self,
@@ -910,7 +911,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
910911
pub fn report_illegal_mutation(&self,
911912
span: Span,
912913
loan_path: &LoanPath<'tcx>,
913-
loan: &Loan) {
914+
loan: &Loan<'_>) {
914915
self.bccx.cannot_assign_to_borrowed(
915916
span, loan.span, &self.bccx.loan_path_to_string(loan_path), Origin::Ast)
916917
.emit();

src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Computes moves.
22
3-
use borrowck::*;
4-
use borrowck::gather_loans::move_error::MovePlace;
5-
use borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
6-
use borrowck::move_data::*;
3+
use crate::borrowck::*;
4+
use crate::borrowck::gather_loans::move_error::MovePlace;
5+
use crate::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
6+
use crate::borrowck::move_data::*;
77
use rustc::middle::expr_use_visitor as euv;
88
use rustc::middle::mem_categorization as mc;
99
use rustc::middle::mem_categorization::Categorization;
@@ -15,6 +15,7 @@ use syntax::ast;
1515
use syntax_pos::Span;
1616
use rustc::hir::*;
1717
use rustc::hir::Node;
18+
use log::debug;
1819

1920
struct GatherMoveInfo<'c, 'tcx: 'c> {
2021
id: hir::ItemLocalId,

src/librustc_borrowck/borrowck/gather_loans/lifetime.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module implements the check that the lifetime of a borrow
22
//! does not exceed the lifetime of the value being borrowed.
33
4-
use borrowck::*;
4+
use crate::borrowck::*;
55
use rustc::middle::expr_use_visitor as euv;
66
use rustc::middle::mem_categorization as mc;
77
use rustc::middle::mem_categorization::Categorization;
@@ -10,6 +10,7 @@ use rustc::ty;
1010

1111
use syntax::ast;
1212
use syntax_pos::Span;
13+
use log::debug;
1314

1415
type R = Result<(),()>;
1516

src/librustc_borrowck/borrowck/gather_loans/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// their associated scopes. In phase two, checking loans, we will then make
77
// sure that all of these loans are honored.
88

9-
use borrowck::*;
10-
use borrowck::move_data::MoveData;
9+
use crate::borrowck::*;
10+
use crate::borrowck::move_data::MoveData;
1111
use rustc::middle::expr_use_visitor as euv;
1212
use rustc::middle::mem_categorization as mc;
1313
use rustc::middle::mem_categorization::Categorization;
@@ -17,8 +17,9 @@ use rustc::ty::{self, TyCtxt};
1717
use syntax::ast;
1818
use syntax_pos::Span;
1919
use rustc::hir;
20+
use log::debug;
2021

21-
use self::restrictions::RestrictionResult;
22+
use restrictions::RestrictionResult;
2223

2324
mod lifetime;
2425
mod restrictions;
@@ -427,7 +428,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> {
427428
// }
428429
}
429430

430-
pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath) {
431+
pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath<'_>) {
431432
//! For mutable loans of content whose mutability derives
432433
//! from a local variable, mark the mutability decl as necessary.
433434

src/librustc_borrowck/borrowck/gather_loans/move_error.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use borrowck::BorrowckCtxt;
1+
use crate::borrowck::BorrowckCtxt;
22
use rustc::middle::mem_categorization as mc;
33
use rustc::middle::mem_categorization::Categorization;
44
use rustc::middle::mem_categorization::NoteClosureEnv;
@@ -8,7 +8,8 @@ use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
88
use syntax::ast;
99
use syntax_pos;
1010
use errors::{DiagnosticBuilder, Applicability};
11-
use borrowck::gather_loans::gather_moves::PatternSource;
11+
use crate::borrowck::gather_loans::gather_moves::PatternSource;
12+
use log::debug;
1213

1314
pub struct MoveErrorCollector<'tcx> {
1415
errors: Vec<MoveError<'tcx>>
@@ -167,10 +168,10 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &'a BorrowckCtxt<'a, 'tcx>,
167168
}
168169
}
169170

170-
fn note_move_destination(mut err: DiagnosticBuilder,
171+
fn note_move_destination(mut err: DiagnosticBuilder<'_>,
171172
move_to_span: syntax_pos::Span,
172173
pat_name: ast::Name,
173-
is_first_note: bool) -> DiagnosticBuilder {
174+
is_first_note: bool) -> DiagnosticBuilder<'_> {
174175
if is_first_note {
175176
err.span_label(
176177
move_to_span,

src/librustc_borrowck/borrowck/gather_loans/restrictions.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
//! Computes the restrictions that result from a borrow.
22
3-
use borrowck::*;
3+
use crate::borrowck::*;
44
use rustc::middle::expr_use_visitor as euv;
55
use rustc::middle::mem_categorization as mc;
66
use rustc::middle::mem_categorization::Categorization;
77
use rustc::ty;
88
use syntax_pos::Span;
9+
use log::debug;
910

10-
use borrowck::ToInteriorKind;
11+
use crate::borrowck::ToInteriorKind;
1112

1213
use std::rc::Rc;
1314

src/librustc_borrowck/borrowck/mod.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
33
#![allow(non_camel_case_types)]
44

5-
pub use self::LoanPathKind::*;
6-
pub use self::LoanPathElem::*;
7-
pub use self::bckerr_code::*;
8-
pub use self::AliasableViolationKind::*;
9-
pub use self::MovedValueUseKind::*;
5+
pub use LoanPathKind::*;
6+
pub use LoanPathElem::*;
7+
pub use bckerr_code::*;
8+
pub use AliasableViolationKind::*;
9+
pub use MovedValueUseKind::*;
1010

11-
use self::InteriorKind::*;
11+
use InteriorKind::*;
1212

1313
use rustc::hir::HirId;
1414
use rustc::hir::Node;
@@ -37,10 +37,11 @@ use std::hash::{Hash, Hasher};
3737
use syntax::ast;
3838
use syntax_pos::{MultiSpan, Span};
3939
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
40+
use log::debug;
4041

4142
use rustc::hir;
4243

43-
use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
44+
use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
4445

4546
pub mod check_loans;
4647

@@ -61,7 +62,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6162
});
6263
}
6364

64-
pub fn provide(providers: &mut Providers) {
65+
pub fn provide(providers: &mut Providers<'_>) {
6566
*providers = Providers {
6667
borrowck,
6768
..*providers
@@ -398,7 +399,7 @@ pub enum LoanPathElem<'tcx> {
398399
}
399400

400401
fn closure_to_block(closure_id: LocalDefId,
401-
tcx: TyCtxt) -> ast::NodeId {
402+
tcx: TyCtxt<'_, '_, '_>) -> ast::NodeId {
402403
let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
403404
match tcx.hir().get(closure_id) {
404405
Node::Expr(expr) => match expr.node {
@@ -1214,8 +1215,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
12141215
}
12151216

12161217
fn note_immutability_blame(&self,
1217-
db: &mut DiagnosticBuilder,
1218-
blame: Option<ImmutabilityBlame>,
1218+
db: &mut DiagnosticBuilder<'_>,
1219+
blame: Option<ImmutabilityBlame<'_>>,
12191220
error_node_id: ast::NodeId) {
12201221
match blame {
12211222
None => {}
@@ -1271,7 +1272,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
12711272
// binding: either to make the binding mutable (if its type is
12721273
// not a mutable reference) or to avoid borrowing altogether
12731274
fn note_immutable_local(&self,
1274-
db: &mut DiagnosticBuilder,
1275+
db: &mut DiagnosticBuilder<'_>,
12751276
borrowed_node_id: ast::NodeId,
12761277
binding_node_id: ast::NodeId) {
12771278
let let_span = self.tcx.hir().span(binding_node_id);
@@ -1349,7 +1350,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
13491350
}
13501351
}
13511352

1352-
fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder, err: &BckError<'a, 'tcx>,
1353+
fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder<'_>, err: &BckError<'a, 'tcx>,
13531354
error_span: &Span) {
13541355
match err.cmt.note {
13551356
mc::NoteClosureEnv(upvar_id) | mc::NoteUpvarRef(upvar_id) => {
@@ -1487,7 +1488,7 @@ impl DataFlowOperator for LoanDataFlowOperator {
14871488
}
14881489

14891490
impl<'tcx> fmt::Debug for InteriorKind {
1490-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1491+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14911492
match *self {
14921493
InteriorField(mc::FieldIndex(_, info)) => write!(f, "{}", info),
14931494
InteriorElement => write!(f, "[]"),
@@ -1496,7 +1497,7 @@ impl<'tcx> fmt::Debug for InteriorKind {
14961497
}
14971498

14981499
impl<'tcx> fmt::Debug for Loan<'tcx> {
1499-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1500+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15001501
write!(f, "Loan_{}({:?}, {:?}, {:?}-{:?}, {:?})",
15011502
self.index,
15021503
self.loan_path,
@@ -1508,7 +1509,7 @@ impl<'tcx> fmt::Debug for Loan<'tcx> {
15081509
}
15091510

15101511
impl<'tcx> fmt::Debug for LoanPath<'tcx> {
1511-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1512+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15121513
match self.kind {
15131514
LpVar(id) => {
15141515
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
@@ -1543,7 +1544,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> {
15431544
}
15441545

15451546
impl<'tcx> fmt::Display for LoanPath<'tcx> {
1546-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1547+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15471548
match self.kind {
15481549
LpVar(id) => {
15491550
write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id)))

src/librustc_borrowck/borrowck/move_data.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Data structures used for tracking moves. Please see the extensive
22
//! comments in the section "Moves and initialization" in `README.md`.
33
4-
pub use self::MoveKind::*;
4+
pub use MoveKind::*;
55

6-
use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
6+
use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
77

8-
use borrowck::*;
8+
use crate::borrowck::*;
99
use rustc::cfg;
1010
use rustc::ty::{self, TyCtxt};
1111
use rustc::util::nodemap::FxHashMap;
@@ -15,6 +15,7 @@ use std::rc::Rc;
1515
use std::usize;
1616
use syntax_pos::Span;
1717
use rustc::hir;
18+
use log::debug;
1819

1920
#[derive(Default)]
2021
pub struct MoveData<'tcx> {
@@ -145,7 +146,7 @@ pub struct AssignDataFlowOperator;
145146

146147
pub type AssignDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, AssignDataFlowOperator>;
147148

148-
fn loan_path_is_precise(loan_path: &LoanPath) -> bool {
149+
fn loan_path_is_precise(loan_path: &LoanPath<'_>) -> bool {
149150
match loan_path.kind {
150151
LpVar(_) | LpUpvar(_) => {
151152
true
@@ -428,8 +429,8 @@ impl<'a, 'tcx> MoveData<'tcx> {
428429
/// killed by scoping. See `README.md` for more details.
429430
fn add_gen_kills(&self,
430431
bccx: &BorrowckCtxt<'a, 'tcx>,
431-
dfcx_moves: &mut MoveDataFlow,
432-
dfcx_assign: &mut AssignDataFlow) {
432+
dfcx_moves: &mut MoveDataFlow<'_, '_>,
433+
dfcx_assign: &mut AssignDataFlow<'_, '_>) {
433434
for (i, the_move) in self.moves.borrow().iter().enumerate() {
434435
dfcx_moves.add_gen(the_move.id, i);
435436
}
@@ -537,7 +538,7 @@ impl<'a, 'tcx> MoveData<'tcx> {
537538
path: MovePathIndex,
538539
kill_id: hir::ItemLocalId,
539540
kill_kind: KillFrom,
540-
dfcx_moves: &mut MoveDataFlow) {
541+
dfcx_moves: &mut MoveDataFlow<'_, '_>) {
541542
// We can only perform kills for paths that refer to a unique location,
542543
// since otherwise we may kill a move from one location with an
543544
// assignment referring to another location.

src/librustc_borrowck/borrowck/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use errors::Applicability;
77
use std::slice;
88
use syntax::ptr::P;
99

10-
use borrowck::BorrowckCtxt;
10+
use crate::borrowck::BorrowckCtxt;
1111

1212
pub fn check<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &'tcx hir::Body) {
1313
let mut used_mut = bccx.used_mut_nodes.borrow().clone();

src/librustc_borrowck/dataflow.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::io;
1010
use std::mem;
1111
use std::usize;
1212
use syntax::print::pprust::PrintState;
13+
use log::debug;
1314

1415
use rustc_data_structures::graph::implementation::OUTGOING;
1516

@@ -80,7 +81,7 @@ pub trait DataFlowOperator : BitwiseOperator {
8081
fn initial_value(&self) -> bool;
8182
}
8283

83-
struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O: 'a> {
84+
struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O> {
8485
dfcx: &'a mut DataFlowContext<'b, 'tcx, O>,
8586
changed: bool
8687
}
@@ -99,12 +100,12 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
99100
}
100101

101102
impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> {
102-
fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> {
103+
fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> {
103104
pprust::PpAnn::nested(self.tcx.hir(), state, nested)
104105
}
105106
fn pre(&self,
106-
ps: &mut pprust::State,
107-
node: pprust::AnnNode) -> io::Result<()> {
107+
ps: &mut pprust::State<'_>,
108+
node: pprust::AnnNode<'_>) -> io::Result<()> {
108109
let id = match node {
109110
pprust::AnnNode::Name(_) => return Ok(()),
110111
pprust::AnnNode::Expr(expr) => expr.hir_id.local_id,

0 commit comments

Comments
 (0)