Skip to content

Commit b363c78

Browse files
committed
---
yaml --- r: 181829 b: refs/heads/master c: e84a719 h: refs/heads/master i: 181827: b93d38f v: v3
1 parent d2ef2b9 commit b363c78

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 48c70d68637536cc2922c1a7c2a612877705a2ed
2+
refs/heads/master: e84a719e375ac48c6792d0495fb3302879bf7916
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3cf3483ffd586b3042fda31c66d5afad7415e715
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77

trunk/src/librustc_typeck/check/regionck.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ use syntax::codemap::Span;
102102
use syntax::visit;
103103
use syntax::visit::Visitor;
104104

105-
use self::RepeatingScope::Repeating;
106105
use self::SubjectNode::Subject;
107106

108107
// a variation on try that just returns unit
@@ -114,7 +113,7 @@ macro_rules! ignore_err {
114113
// PUBLIC ENTRY POINTS
115114

116115
pub fn regionck_expr(fcx: &FnCtxt, e: &ast::Expr) {
117-
let mut rcx = Rcx::new(fcx, Repeating(e.id), Subject(e.id));
116+
let mut rcx = Rcx::new(fcx, RepeatingScope(e.id), e.id, Subject(e.id));
118117
if fcx.err_count_since_creation() == 0 {
119118
// regionck assumes typeck succeeded
120119
rcx.visit_expr(e);
@@ -124,16 +123,17 @@ pub fn regionck_expr(fcx: &FnCtxt, e: &ast::Expr) {
124123
}
125124

126125
pub fn regionck_item(fcx: &FnCtxt, item: &ast::Item) {
127-
let mut rcx = Rcx::new(fcx, Repeating(item.id), Subject(item.id));
126+
let mut rcx = Rcx::new(fcx, RepeatingScope(item.id), item.id, Subject(item.id));
128127
rcx.visit_region_obligations(item.id);
129128
rcx.resolve_regions_and_report_errors();
130129
}
131130

132131
pub fn regionck_fn(fcx: &FnCtxt, id: ast::NodeId, decl: &ast::FnDecl, blk: &ast::Block) {
133-
let mut rcx = Rcx::new(fcx, Repeating(blk.id), Subject(id));
132+
debug!("regionck_fn(id={})", id);
133+
let mut rcx = Rcx::new(fcx, RepeatingScope(blk.id), blk.id, Subject(id));
134134
if fcx.err_count_since_creation() == 0 {
135135
// regionck assumes typeck succeeded
136-
rcx.visit_fn_body(id, decl, blk);
136+
rcx.visit_fn_body(id, decl, blk, blk.span); // TODO suboptimal span
137137
}
138138

139139
// Region checking a fn can introduce new trait obligations,
@@ -148,7 +148,7 @@ pub fn regionck_fn(fcx: &FnCtxt, id: ast::NodeId, decl: &ast::FnDecl, blk: &ast:
148148
pub fn regionck_ensure_component_tys_wf<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
149149
span: Span,
150150
component_tys: &[Ty<'tcx>]) {
151-
let mut rcx = Rcx::new(fcx, Repeating(0), SubjectNode::None);
151+
let mut rcx = Rcx::new(fcx, RepeatingScope(0), 0, SubjectNode::None);
152152
for &component_ty in component_tys {
153153
// Check that each type outlives the empty region. Since the
154154
// empty region is a subregion of all others, this can't fail
@@ -189,14 +189,14 @@ fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region {
189189
}
190190
}
191191

192-
pub enum RepeatingScope { Repeating(ast::NodeId) }
192+
struct RepeatingScope(ast::NodeId);
193193
pub enum SubjectNode { Subject(ast::NodeId), None }
194194

195195
impl<'a, 'tcx> Rcx<'a, 'tcx> {
196196
pub fn new(fcx: &'a FnCtxt<'a, 'tcx>,
197197
initial_repeating_scope: RepeatingScope,
198198
subject: SubjectNode) -> Rcx<'a, 'tcx> {
199-
let Repeating(initial_repeating_scope) = initial_repeating_scope;
199+
let RepeatingScope(initial_repeating_scope) = initial_repeating_scope;
200200
Rcx { fcx: fcx,
201201
repeating_scope: initial_repeating_scope,
202202
subject: subject,
@@ -208,10 +208,8 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
208208
self.fcx.ccx.tcx
209209
}
210210

211-
pub fn set_repeating_scope(&mut self, scope: ast::NodeId) -> ast::NodeId {
212-
let old_scope = self.repeating_scope;
213-
self.repeating_scope = scope;
214-
old_scope
211+
fn set_repeating_scope(&mut self, scope: ast::NodeId) -> ast::NodeId {
212+
mem::replace(&mut self.repeating_scope, scope)
215213
}
216214

217215
/// Try to resolve the type for the given node, returning t_err if an error results. Note that

0 commit comments

Comments
 (0)