Skip to content

Commit 29ae7aa

Browse files
committed
---
yaml --- r: 30031 b: refs/heads/incoming c: 5eea7d6 h: refs/heads/master i: 30029: 28b3705 30027: fa97fed 30023: 9c8cd4f 30015: cbf6e98 v: v3
1 parent 7e49f13 commit 29ae7aa

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 89222646f446e608f151c08f6623c695d7b8c673
9+
refs/heads/incoming: 5eea7d6e618ff1f4a26ab79b2fb53208b0ce7912
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/rustc/middle/region.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,21 @@ impl determine_rp_ctxt {
518518
}
519519
}
520520

521+
// For named types like Foo, if there is no explicit region
522+
// parameter, then we will add the anonymous region, so there is
523+
// a dependency if the anonymous region implies rp.
524+
//
525+
// If the region is explicitly specified, then we follows the
526+
// normal rules.
527+
fn opt_region_is_relevant(opt_r: option<@ast::region>) -> bool {
528+
debug!("opt_region_is_relevant: %? (anon_implies_rp=%b)",
529+
opt_r, self.anon_implies_rp);
530+
match opt_r {
531+
none => self.anon_implies_rp,
532+
some(r) => self.region_is_relevant(r)
533+
}
534+
}
535+
521536
fn with(item_id: ast::node_id,
522537
anon_implies_rp: bool,
523538
f: fn()) {
@@ -613,19 +628,23 @@ fn determine_rp_in_ty(ty: @ast::ty,
613628
// then check whether it is region-parameterized and consider
614629
// that as a direct dependency.
615630
match ty.node {
616-
ast::ty_path(_, id) => {
631+
ast::ty_path(path, id) => {
617632
match cx.def_map.get(id) {
618633
ast::def_ty(did) | ast::def_class(did, _) => {
619634
if did.crate == ast::local_crate {
620-
cx.add_dep(did.node);
635+
if cx.opt_region_is_relevant(path.rp) {
636+
cx.add_dep(did.node);
637+
}
621638
} else {
622639
let cstore = cx.sess.cstore;
623640
match csearch::get_region_param(cstore, did) {
624641
none => {}
625642
some(variance) => {
626643
debug!("reference to external, rp'd type %s",
627644
pprust::ty_to_str(ty, cx.sess.intr()));
628-
cx.add_rp(cx.item_id, cx.add_variance(variance))
645+
if cx.opt_region_is_relevant(path.rp) {
646+
cx.add_rp(cx.item_id, cx.add_variance(variance))
647+
}
629648
}
630649
}
631650
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
struct direct {
2+
f: &int;
3+
}
4+
5+
struct indirect1 {
6+
g: fn@(direct);
7+
}
8+
9+
struct indirect2 {
10+
g: fn@(direct/&);
11+
}
12+
13+
struct indirect3 {
14+
g: fn@(direct/&self);
15+
}
16+
17+
fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types
18+
fn take_indirect1(p: indirect1) -> indirect1 { p }
19+
fn take_indirect2(p: indirect2) -> indirect2 { p }
20+
fn take_indirect3(p: indirect3) -> indirect3 { p } //~ ERROR mismatched types
21+
fn main() {}

0 commit comments

Comments
 (0)