Skip to content

Commit e84a719

Browse files
committed
Misc. cleanup in regionck: Remove a one-variant enum for some reason.
1 parent 48c70d6 commit e84a719

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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)