Skip to content

Commit 62c83bb

Browse files
author
James Miller
committed
De-manage Lifetime
1 parent cd1b6c8 commit 62c83bb

File tree

9 files changed

+61
-62
lines changed

9 files changed

+61
-62
lines changed

src/librustc/middle/region.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -651,18 +651,18 @@ impl DetermineRpCtxt {
651651
// with &self type, &self is also bound. We detect those last two
652652
// cases via flags (anon_implies_rp and self_implies_rp) that are
653653
// true when the anon or self region implies RP.
654-
pub fn region_is_relevant(&self, r: Option<@ast::Lifetime>) -> bool {
654+
pub fn region_is_relevant(&self, r: &Option<ast::Lifetime>) -> bool {
655655
match r {
656-
None => {
656+
&None => {
657657
self.anon_implies_rp
658658
}
659-
Some(ref l) if l.ident == special_idents::statik => {
659+
&Some(ref l) if l.ident == special_idents::statik => {
660660
false
661661
}
662-
Some(ref l) if l.ident == special_idents::self_ => {
662+
&Some(ref l) if l.ident == special_idents::self_ => {
663663
true
664664
}
665-
Some(_) => {
665+
&Some(_) => {
666666
false
667667
}
668668
}
@@ -747,7 +747,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
747747
// locations)
748748
let sess = cx.sess;
749749
match ty.node {
750-
ast::ty_rptr(r, _) => {
750+
ast::ty_rptr(ref r, _) => {
751751
debug!("referenced rptr type %s",
752752
pprust::ty_to_str(ty, sess.intr()));
753753

@@ -762,7 +762,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
762762
pprust::ty_to_str(ty, sess.intr()));
763763
match f.region {
764764
Some(_) => {
765-
if cx.region_is_relevant(f.region) {
765+
if cx.region_is_relevant(&f.region) {
766766
let rv = cx.add_variance(rv_contravariant);
767767
cx.add_rp(cx.item_id, rv)
768768
}
@@ -790,7 +790,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
790790
Some(&ast::def_trait(did)) |
791791
Some(&ast::def_struct(did)) => {
792792
if did.crate == ast::local_crate {
793-
if cx.region_is_relevant(path.rp) {
793+
if cx.region_is_relevant(&path.rp) {
794794
cx.add_dep(did.node);
795795
}
796796
} else {
@@ -800,7 +800,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
800800
Some(variance) => {
801801
debug!("reference to external, rp'd type %s",
802802
pprust::ty_to_str(ty, sess.intr()));
803-
if cx.region_is_relevant(path.rp) {
803+
if cx.region_is_relevant(&path.rp) {
804804
let rv = cx.add_variance(variance);
805805
cx.add_rp(cx.item_id, rv)
806806
}

src/librustc/middle/typeck/astconv.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ pub trait AstConv {
8585
pub fn get_region_reporting_err(
8686
tcx: ty::ctxt,
8787
span: span,
88-
a_r: Option<@ast::Lifetime>,
88+
a_r: &Option<ast::Lifetime>,
8989
res: Result<ty::Region, RegionError>) -> ty::Region
9090
{
9191
match res {
9292
result::Ok(r) => r,
9393
result::Err(ref e) => {
9494
let descr = match a_r {
95-
None => ~"anonymous lifetime",
96-
Some(a) => fmt!("lifetime %s",
95+
&None => ~"anonymous lifetime",
96+
&Some(ref a) => fmt!("lifetime %s",
9797
lifetime_to_str(a, tcx.sess.intr()))
9898
};
9999
tcx.sess.span_err(
@@ -109,19 +109,19 @@ pub fn ast_region_to_region<AC:AstConv,RS:region_scope + Copy + 'static>(
109109
this: &AC,
110110
rscope: &RS,
111111
default_span: span,
112-
opt_lifetime: Option<@ast::Lifetime>) -> ty::Region
112+
opt_lifetime: &Option<ast::Lifetime>) -> ty::Region
113113
{
114114
let (span, res) = match opt_lifetime {
115-
None => {
115+
&None => {
116116
(default_span, rscope.anon_region(default_span))
117117
}
118-
Some(ref lifetime) if lifetime.ident == special_idents::statik => {
118+
&Some(ref lifetime) if lifetime.ident == special_idents::statik => {
119119
(lifetime.span, Ok(ty::re_static))
120120
}
121-
Some(ref lifetime) if lifetime.ident == special_idents::self_ => {
121+
&Some(ref lifetime) if lifetime.ident == special_idents::self_ => {
122122
(lifetime.span, rscope.self_region(lifetime.span))
123123
}
124-
Some(ref lifetime) => {
124+
&Some(ref lifetime) => {
125125
(lifetime.span, rscope.named_region(lifetime.span,
126126
lifetime.ident))
127127
}
@@ -164,11 +164,11 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Copy + 'static>(
164164
}
165165
(&Some(_), &None) => {
166166
let res = rscope.anon_region(path.span);
167-
let r = get_region_reporting_err(this.tcx(), path.span, None, res);
167+
let r = get_region_reporting_err(this.tcx(), path.span, &None, res);
168168
Some(r)
169169
}
170170
(&Some(_), &Some(_)) => {
171-
Some(ast_region_to_region(this, rscope, path.span, path.rp))
171+
Some(ast_region_to_region(this, rscope, path.span, &path.rp))
172172
}
173173
};
174174

@@ -371,7 +371,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
371371
ast::ty_ptr(ref mt) => {
372372
ty::mk_ptr(tcx, ast_mt_to_mt(this, rscope, mt))
373373
}
374-
ast::ty_rptr(region, ref mt) => {
374+
ast::ty_rptr(ref region, ref mt) => {
375375
let r = ast_region_to_region(this, rscope, ast_ty.span, region);
376376
mk_pointer(this, rscope, mt, ty::vstore_slice(r),
377377
|tmt| ty::mk_rptr(tcx, r, tmt))
@@ -398,7 +398,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
398398
f.purity,
399399
f.onceness,
400400
bounds,
401-
f.region,
401+
&f.region,
402402
&f.decl,
403403
None,
404404
&f.lifetimes,
@@ -647,7 +647,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
647647
ast::sty_value => {
648648
Some(self_info.untransformed_self_ty)
649649
}
650-
ast::sty_region(lifetime, mutability) => {
650+
ast::sty_region(ref lifetime, mutability) => {
651651
let region =
652652
ast_region_to_region(this, rscope,
653653
self_info.explicit_self.span,
@@ -677,7 +677,7 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + 'static>(
677677
purity: ast::purity,
678678
onceness: ast::Onceness,
679679
bounds: ty::BuiltinBounds,
680-
opt_lifetime: Option<@ast::Lifetime>,
680+
opt_lifetime: &Option<ast::Lifetime>,
681681
decl: &ast::fn_decl,
682682
expected_sig: Option<ty::FnSig>,
683683
lifetimes: &OptVec<ast::Lifetime>,
@@ -695,10 +695,10 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + 'static>(
695695
// resolve the function bound region in the original region
696696
// scope `rscope`, not the scope of the function parameters
697697
let bound_region = match opt_lifetime {
698-
Some(_) => {
698+
&Some(_) => {
699699
ast_region_to_region(this, rscope, span, opt_lifetime)
700700
}
701-
None => {
701+
&None => {
702702
match sigil {
703703
ast::OwnedSigil | ast::ManagedSigil => {
704704
// @fn(), ~fn() default to static as the bound

src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
17381738
purity,
17391739
expected_onceness,
17401740
expected_bounds,
1741-
None,
1741+
&None,
17421742
decl,
17431743
expected_sig,
17441744
&opt_vec::Empty,
@@ -3310,7 +3310,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
33103310
None
33113311
}
33123312
Some(_) => { // ...and the type is lifetime parameterized, ok.
3313-
Some(ast_region_to_region(fcx, fcx, span, pth.rp))
3313+
Some(ast_region_to_region(fcx, fcx, span, &pth.rp))
33143314
}
33153315
}
33163316
}

src/libsyntax/ast.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub struct Path {
109109
span: span,
110110
global: bool,
111111
idents: ~[ident],
112-
rp: Option<@Lifetime>,
112+
rp: Option<Lifetime>,
113113
types: ~[@Ty],
114114
}
115115

@@ -296,7 +296,7 @@ pub enum vstore {
296296
vstore_fixed(Option<uint>), // [1,2,3,4]
297297
vstore_uniq, // ~[1,2,3,4]
298298
vstore_box, // @[1,2,3,4]
299-
vstore_slice(Option<@Lifetime>) // &'foo? [1,2,3,4]
299+
vstore_slice(Option<Lifetime>) // &'foo? [1,2,3,4]
300300
}
301301

302302
#[deriving(Eq, Encodable, Decodable,IterBytes)]
@@ -701,7 +701,7 @@ impl ToStr for Onceness {
701701
#[deriving(Eq, Encodable, Decodable,IterBytes)]
702702
pub struct TyClosure {
703703
sigil: Sigil,
704-
region: Option<@Lifetime>,
704+
region: Option<Lifetime>,
705705
lifetimes: OptVec<Lifetime>,
706706
purity: purity,
707707
onceness: Onceness,
@@ -730,7 +730,7 @@ pub enum ty_ {
730730
ty_vec(mt),
731731
ty_fixed_length_vec(mt, @expr),
732732
ty_ptr(mt),
733-
ty_rptr(Option<@Lifetime>, mt),
733+
ty_rptr(Option<Lifetime>, mt),
734734
ty_closure(@TyClosure),
735735
ty_bare_fn(@TyBareFn),
736736
ty_tup(~[@Ty]),
@@ -803,7 +803,7 @@ pub enum ret_style {
803803
pub enum explicit_self_ {
804804
sty_static, // no self
805805
sty_value, // `self`
806-
sty_region(Option<@Lifetime>, mutability), // `&'lt self`
806+
sty_region(Option<Lifetime>, mutability), // `&'lt self`
807807
sty_box(mutability), // `@self`
808808
sty_uniq // `~self`
809809
}

src/libsyntax/ext/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub trait AstBuilder {
3838
fn path_all(&self, sp: span,
3939
global: bool,
4040
idents: ~[ast::ident],
41-
rp: Option<@ast::Lifetime>,
41+
rp: Option<ast::Lifetime>,
4242
types: ~[@ast::Ty])
4343
-> ast::Path;
4444

@@ -51,7 +51,7 @@ pub trait AstBuilder {
5151

5252
fn ty_rptr(&self, span: span,
5353
ty: @ast::Ty,
54-
lifetime: Option<@ast::Lifetime>,
54+
lifetime: Option<ast::Lifetime>,
5555
mutbl: ast::mutability)
5656
-> @ast::Ty;
5757
fn ty_uniq(&self, span: span, ty: @ast::Ty) -> @ast::Ty;
@@ -238,7 +238,7 @@ impl AstBuilder for @ExtCtxt {
238238
fn path_all(&self, sp: span,
239239
global: bool,
240240
idents: ~[ast::ident],
241-
rp: Option<@ast::Lifetime>,
241+
rp: Option<ast::Lifetime>,
242242
types: ~[@ast::Ty])
243243
-> ast::Path {
244244
ast::Path {
@@ -281,7 +281,7 @@ impl AstBuilder for @ExtCtxt {
281281
fn ty_rptr(&self,
282282
span: span,
283283
ty: @ast::Ty,
284-
lifetime: Option<@ast::Lifetime>,
284+
lifetime: Option<ast::Lifetime>,
285285
mutbl: ast::mutability)
286286
-> @ast::Ty {
287287
self.ty(span,

src/libsyntax/ext/deriving/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<'self> TraitDef<'self> {
351351
let self_lifetime = if generics.lifetimes.is_empty() {
352352
None
353353
} else {
354-
Some(@*generics.lifetimes.get(0))
354+
Some(*generics.lifetimes.get(0))
355355
};
356356

357357
// Create the type of `self`.

src/libsyntax/ext/deriving/ty.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ pub fn nil_ty() -> Ty<'static> {
110110
Tuple(~[])
111111
}
112112

113-
fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<@ast::Lifetime> {
113+
fn mk_lifetime(cx: @ExtCtxt, span: span, lt: &Option<&str>) -> Option<ast::Lifetime> {
114114
match *lt {
115-
Some(ref s) => Some(@cx.lifetime(span, cx.ident_of(*s))),
115+
Some(ref s) => Some(cx.lifetime(span, cx.ident_of(*s))),
116116
None => None
117117
}
118118
}
@@ -171,7 +171,7 @@ impl<'self> Ty<'self> {
171171
let lifetime = if self_generics.lifetimes.is_empty() {
172172
None
173173
} else {
174-
Some(@*self_generics.lifetimes.get(0))
174+
Some(*self_generics.lifetimes.get(0))
175175
};
176176

177177
cx.path_all(span, false, ~[self_ty], lifetime,
@@ -251,8 +251,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
251251
Send => ast::sty_uniq,
252252
Managed(mutbl) => ast::sty_box(mutbl),
253253
Borrowed(ref lt, mutbl) => {
254-
let lt = lt.map(|s| @cx.lifetime(span,
255-
cx.ident_of(*s)));
254+
let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(*s)));
256255
ast::sty_region(lt, mutbl)
257256
}
258257
});

src/libsyntax/parse/parser.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ impl Parser {
646646
// parse a ty_closure type
647647
pub fn parse_ty_closure(&self,
648648
sigil: ast::Sigil,
649-
region: Option<@ast::Lifetime>)
649+
region: Option<ast::Lifetime>)
650650
-> ty_ {
651651
/*
652652
@@ -985,7 +985,7 @@ impl Parser {
985985
// @'foo fn() or @foo/fn() or @fn() are parsed directly as fn types:
986986
match *self.token {
987987
token::LIFETIME(*) => {
988-
let lifetime = @self.parse_lifetime();
988+
let lifetime = self.parse_lifetime();
989989
self.bump();
990990
return self.parse_ty_closure(sigil, Some(lifetime));
991991
}
@@ -994,7 +994,7 @@ impl Parser {
994994
if self.look_ahead(1u) == token::BINOP(token::SLASH) &&
995995
self.token_is_closure_keyword(&self.look_ahead(2u))
996996
{
997-
let lifetime = @self.parse_lifetime();
997+
let lifetime = self.parse_lifetime();
998998
self.obsolete(*self.last_span, ObsoleteLifetimeNotation);
999999
return self.parse_ty_closure(sigil, Some(lifetime));
10001000
} else if self.token_is_closure_keyword(&copy *self.token) {
@@ -1263,7 +1263,7 @@ impl Parser {
12631263
token::IDENT(sid, _) => {
12641264
let span = copy self.span;
12651265
self.bump();
1266-
Some(@ast::Lifetime {
1266+
Some(ast::Lifetime {
12671267
id: self.get_id(),
12681268
span: *span,
12691269
ident: sid
@@ -1288,7 +1288,7 @@ impl Parser {
12881288
if v.len() == 0 {
12891289
None
12901290
} else if v.len() == 1 {
1291-
Some(@*v.get(0))
1291+
Some(*v.get(0))
12921292
} else {
12931293
self.fatal(fmt!("Expected at most one \
12941294
lifetime name (for now)"));
@@ -1322,17 +1322,17 @@ impl Parser {
13221322
}
13231323

13241324
/// parses 0 or 1 lifetime
1325-
pub fn parse_opt_lifetime(&self) -> Option<@ast::Lifetime> {
1325+
pub fn parse_opt_lifetime(&self) -> Option<ast::Lifetime> {
13261326
match *self.token {
13271327
token::LIFETIME(*) => {
1328-
Some(@self.parse_lifetime())
1328+
Some(self.parse_lifetime())
13291329
}
13301330

13311331
// Also accept the (obsolete) syntax `foo/`
13321332
token::IDENT(*) => {
13331333
if self.look_ahead(1u) == token::BINOP(token::SLASH) {
13341334
self.obsolete(*self.last_span, ObsoleteLifetimeNotation);
1335-
Some(@self.parse_lifetime())
1335+
Some(self.parse_lifetime())
13361336
} else {
13371337
None
13381338
}
@@ -3343,14 +3343,14 @@ impl Parser {
33433343
} else if (this.token_is_lifetime(&this.look_ahead(1)) &&
33443344
token::is_keyword(keywords::Self, &this.look_ahead(2))) {
33453345
this.bump();
3346-
let lifetime = @this.parse_lifetime();
3346+
let lifetime = this.parse_lifetime();
33473347
this.expect_self_ident();
33483348
sty_region(Some(lifetime), m_imm)
33493349
} else if (this.token_is_lifetime(&this.look_ahead(1)) &&
33503350
this.token_is_mutability(&this.look_ahead(2)) &&
33513351
token::is_keyword(keywords::Self, &this.look_ahead(3))) {
33523352
this.bump();
3353-
let lifetime = @this.parse_lifetime();
3353+
let lifetime = this.parse_lifetime();
33543354
let mutability = this.parse_mutability();
33553355
this.expect_self_ident();
33563356
sty_region(Some(lifetime), mutability)

0 commit comments

Comments
 (0)