Skip to content

Commit 67ca37a

Browse files
committed
workaround a horribly obscure resolve bug
1 parent a559329 commit 67ca37a

File tree

6 files changed

+79
-76
lines changed

6 files changed

+79
-76
lines changed

src/rustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop,
16831683

16841684
fn root_value(bcx: block, val: ValueRef, ty: ty::t,
16851685
scope_id: ast::node_id) {
1686-
if !bcx.sess().opts.no_asm_comments {
1686+
if !bcx.sess().no_asm_comments() {
16871687
add_comment(bcx, #fmt["preserving until end of scope %d",
16881688
scope_id]);
16891689
}

src/rustc/middle/typeck/astconv.rs

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ an rptr (`&r.T`) use the region `r` that appears in the rptr.
4545
"];
4646

4747
import check::fn_ctxt;
48+
import rscope::*;
4849

4950
iface ast_conv {
5051
fn tcx() -> ty::ctxt;
@@ -55,74 +56,6 @@ iface ast_conv {
5556
fn ty_infer(span: span) -> ty::t;
5657
}
5758

58-
iface region_scope {
59-
fn anon_region() -> result<ty::region, str>;
60-
fn named_region(id: str) -> result<ty::region, str>;
61-
}
62-
63-
enum empty_rscope { empty_rscope }
64-
impl of region_scope for empty_rscope {
65-
fn anon_region() -> result<ty::region, str> {
66-
result::err("region types are not allowed here")
67-
}
68-
fn named_region(id: str) -> result<ty::region, str> {
69-
if id == "static" { result::ok(ty::re_static) }
70-
else { result::err("only the static region is allowed here") }
71-
}
72-
}
73-
74-
enum type_rscope = ast::region_param;
75-
impl of region_scope for type_rscope {
76-
fn anon_region() -> result<ty::region, str> {
77-
alt *self {
78-
ast::rp_self { result::ok(ty::re_bound(ty::br_self)) }
79-
ast::rp_none {
80-
result::err("to use region types here, the containing type \
81-
must be declared with a region bound")
82-
}
83-
}
84-
}
85-
fn named_region(id: str) -> result<ty::region, str> {
86-
empty_rscope.named_region(id).chain_err { |_e|
87-
if id == "self" { self.anon_region() }
88-
else {
89-
result::err("named regions other than `self` are not \
90-
allowed as part of a type declaration")
91-
}
92-
}
93-
}
94-
}
95-
96-
enum anon_rscope = {anon: ty::region, base: region_scope};
97-
fn in_anon_rscope<RS: region_scope copy>(self: RS, r: ty::region)
98-
-> @anon_rscope {
99-
@anon_rscope({anon: r, base: self as region_scope})
100-
}
101-
impl of region_scope for @anon_rscope {
102-
fn anon_region() -> result<ty::region, str> {
103-
result::ok(self.anon)
104-
}
105-
fn named_region(id: str) -> result<ty::region, str> {
106-
self.base.named_region(id)
107-
}
108-
}
109-
110-
enum binding_rscope = {base: region_scope};
111-
fn in_binding_rscope<RS: region_scope copy>(self: RS) -> @binding_rscope {
112-
let base = self as region_scope;
113-
@binding_rscope({base: base})
114-
}
115-
impl of region_scope for @binding_rscope {
116-
fn anon_region() -> result<ty::region, str> {
117-
result::ok(ty::re_bound(ty::br_anon))
118-
}
119-
fn named_region(id: str) -> result<ty::region, str> {
120-
self.base.named_region(id).chain_err {|_e|
121-
result::ok(ty::re_bound(ty::br_named(id)))
122-
}
123-
}
124-
}
125-
12659
fn get_region_reporting_err(tcx: ty::ctxt,
12760
span: span,
12861
res: result<ty::region, str>) -> ty::region {

src/rustc/middle/typeck/check.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ type parameter).
6666
6767
*/
6868

69-
import astconv::{ast_conv, region_scope, empty_rscope, ast_ty_to_ty,
70-
in_anon_rscope};
69+
import astconv::{ast_conv, ast_ty_to_ty};
7170
import collect::{methods}; // ccx.to_ty()
7271
import method::{methods}; // methods for method::lookup
7372
import regionmanip::{universally_quantify_regions_before_call,
7473
region_of, replace_bound_regions,
7574
collect_bound_regions_in_tys};
75+
import rscope::*;
7676

7777
type fn_ctxt =
7878
// var_bindings, locals and next_var_id are shared
@@ -335,7 +335,7 @@ fn class_types(ccx: @crate_ctxt, members: [@ast::class_member],
335335
rp: ast::region_param) -> class_map {
336336

337337
let rslt = int_hash::<ty::t>();
338-
let rs = astconv::type_rscope(rp);
338+
let rs = rscope::type_rscope(rp);
339339
for members.each { |m|
340340
alt m.node {
341341
ast::instance_var(_,t,_,id,_) {
@@ -375,7 +375,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
375375
check_bare_fn(ccx, decl, body, dtor_id, none);
376376
}
377377
ast::item_impl(tps, rp, _, ty, ms) {
378-
let self_ty = ccx.to_ty(astconv::type_rscope(rp), ty);
378+
let self_ty = ccx.to_ty(rscope::type_rscope(rp), ty);
379379
for ms.each {|m| check_method(ccx, m, self_ty);}
380380
}
381381
ast::item_class(tps, ifaces, members, ctor, m_dtor, rp) {
@@ -652,7 +652,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty {
652652
_}, _)) {
653653
{n_tps: ts.len(),
654654
rp: rp,
655-
raw_ty: fcx.ccx.to_ty(astconv::type_rscope(rp), st)}
655+
raw_ty: fcx.ccx.to_ty(rscope::type_rscope(rp), st)}
656656
}
657657
some(ast_map::node_item(@{node: ast::item_class(ts,
658658
_,_,_,_,rp), id: class_id, _},_)) {

src/rustc/middle/typeck/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ are represented as `ty_param()` instances.
2020
2121
*/
2222

23-
import astconv::{type_rscope, empty_rscope, in_binding_rscope, ast_conv,
24-
ty_of_fn_decl, ty_of_arg, region_scope, ast_ty_to_ty};
23+
import astconv::{ast_conv, ty_of_fn_decl, ty_of_arg, ast_ty_to_ty};
24+
import rscope::*;
2525

2626
fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
2727

src/rustc/middle/typeck/rscope.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import result::result;
2+
3+
iface region_scope {
4+
fn anon_region() -> result<ty::region, str>;
5+
fn named_region(id: str) -> result<ty::region, str>;
6+
}
7+
8+
enum empty_rscope { empty_rscope }
9+
impl of region_scope for empty_rscope {
10+
fn anon_region() -> result<ty::region, str> {
11+
result::err("region types are not allowed here")
12+
}
13+
fn named_region(id: str) -> result<ty::region, str> {
14+
if id == "static" { result::ok(ty::re_static) }
15+
else { result::err("only the static region is allowed here") }
16+
}
17+
}
18+
19+
enum type_rscope = ast::region_param;
20+
impl of region_scope for type_rscope {
21+
fn anon_region() -> result<ty::region, str> {
22+
alt *self {
23+
ast::rp_self { result::ok(ty::re_bound(ty::br_self)) }
24+
ast::rp_none {
25+
result::err("to use region types here, the containing type \
26+
must be declared with a region bound")
27+
}
28+
}
29+
}
30+
fn named_region(id: str) -> result<ty::region, str> {
31+
empty_rscope.named_region(id).chain_err { |_e|
32+
if id == "self" { self.anon_region() }
33+
else {
34+
result::err("named regions other than `self` are not \
35+
allowed as part of a type declaration")
36+
}
37+
}
38+
}
39+
}
40+
41+
enum anon_rscope = {anon: ty::region, base: region_scope};
42+
fn in_anon_rscope<RS: region_scope copy>(self: RS, r: ty::region)
43+
-> @anon_rscope {
44+
@anon_rscope({anon: r, base: self as region_scope})
45+
}
46+
impl of region_scope for @anon_rscope {
47+
fn anon_region() -> result<ty::region, str> {
48+
result::ok(self.anon)
49+
}
50+
fn named_region(id: str) -> result<ty::region, str> {
51+
self.base.named_region(id)
52+
}
53+
}
54+
55+
enum binding_rscope = {base: region_scope};
56+
fn in_binding_rscope<RS: region_scope copy>(self: RS) -> @binding_rscope {
57+
let base = self as region_scope;
58+
@binding_rscope({base: base})
59+
}
60+
impl of region_scope for @binding_rscope {
61+
fn anon_region() -> result<ty::region, str> {
62+
result::ok(ty::re_bound(ty::br_anon))
63+
}
64+
fn named_region(id: str) -> result<ty::region, str> {
65+
self.base.named_region(id).chain_err {|_e|
66+
result::ok(ty::re_bound(ty::br_named(id)))
67+
}
68+
}
69+
}

src/rustc/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ mod middle {
6161
mod demand;
6262
mod method;
6363
}
64+
mod rscope;
6465
mod astconv;
6566
mod infer;
6667
mod collect;

0 commit comments

Comments
 (0)