Skip to content

Commit b6f9aa1

Browse files
committed
auto merge of #5483 : pcwalton/rust/static-syntax, r=graydon
r? @nikomatsakis
2 parents f011f92 + 94327d0 commit b6f9aa1

14 files changed

+60
-57
lines changed

src/librustc/middle/kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ pub fn check_bounds(cx: Context,
376376

377377
ty::bound_durable => {
378378
if !kind.is_durable(cx.tcx) {
379-
missing.push("&static");
379+
missing.push("'static");
380380
}
381381
}
382382

@@ -467,7 +467,7 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
467467
match ty::get(ty).sty {
468468
ty::ty_param(*) => {
469469
tcx.sess.span_err(sp, ~"value may contain borrowed \
470-
pointers; use `&static` bound");
470+
pointers; use `'static` bound");
471471
}
472472
_ => {
473473
tcx.sess.span_err(sp, ~"value may contain borrowed \

src/librustc/middle/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ pub fn substs_to_str(cx: ctxt, substs: &substs) -> ~str {
14041404
pub fn param_bound_to_str(cx: ctxt, pb: &param_bound) -> ~str {
14051405
match *pb {
14061406
bound_copy => ~"copy",
1407-
bound_durable => ~"&static",
1407+
bound_durable => ~"'static",
14081408
bound_owned => ~"owned",
14091409
bound_const => ~"const",
14101410
bound_trait(t) => ::util::ppaux::ty_to_str(cx, t)

src/libsyntax/parse/parser.rs

+40-37
Original file line numberDiff line numberDiff line change
@@ -2704,49 +2704,52 @@ pub impl Parser {
27042704

27052705
let mut result = opt_vec::Empty;
27062706
loop {
2707-
if self.eat(&token::BINOP(token::AND)) {
2708-
if self.eat_keyword(&~"static") {
2709-
result.push(RegionTyParamBound);
2710-
} else {
2711-
self.span_err(*self.span,
2712-
~"`&static` is the only permissible \
2713-
region bound here");
2707+
match *self.token {
2708+
token::LIFETIME(lifetime) => {
2709+
if str::eq_slice(*self.id_to_str(lifetime), "static") {
2710+
result.push(RegionTyParamBound);
2711+
} else {
2712+
self.span_err(*self.span,
2713+
~"`'static` is the only permissible \
2714+
region bound here");
2715+
}
2716+
self.bump();
27142717
}
2715-
} else if is_ident(&*self.token) {
2716-
let maybe_bound = match *self.token {
2717-
token::IDENT(copy sid, _) => {
2718-
match *self.id_to_str(sid) {
2719-
~"send" |
2720-
~"copy" |
2721-
~"const" |
2722-
~"owned" => {
2723-
self.obsolete(
2724-
*self.span,
2725-
ObsoleteLowerCaseKindBounds);
2726-
2727-
// Bogus value, but doesn't matter, since
2728-
// is an error
2729-
Some(TraitTyParamBound(
2730-
self.mk_ty_path(sid)))
2718+
token::IDENT(*) => {
2719+
let maybe_bound = match *self.token {
2720+
token::IDENT(copy sid, _) => {
2721+
match *self.id_to_str(sid) {
2722+
~"send" |
2723+
~"copy" |
2724+
~"const" |
2725+
~"owned" => {
2726+
self.obsolete(
2727+
*self.span,
2728+
ObsoleteLowerCaseKindBounds);
2729+
2730+
// Bogus value, but doesn't matter, since
2731+
// is an error
2732+
Some(TraitTyParamBound(
2733+
self.mk_ty_path(sid)))
2734+
}
2735+
_ => None
27312736
}
2732-
_ => None
27332737
}
2734-
}
2735-
_ => fail!()
2736-
};
2738+
_ => fail!()
2739+
};
27372740

2738-
match maybe_bound {
2739-
Some(bound) => {
2740-
self.bump();
2741-
result.push(bound);
2742-
}
2743-
None => {
2744-
let ty = self.parse_ty(false);
2745-
result.push(TraitTyParamBound(ty));
2741+
match maybe_bound {
2742+
Some(bound) => {
2743+
self.bump();
2744+
result.push(bound);
2745+
}
2746+
None => {
2747+
let ty = self.parse_ty(false);
2748+
result.push(TraitTyParamBound(ty));
2749+
}
27462750
}
27472751
}
2748-
} else {
2749-
break;
2752+
_ => break,
27502753
}
27512754

27522755
if self.eat(&token::BINOP(token::PLUS)) {

src/libsyntax/print/pprust.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ pub fn print_bounds(s: @ps, bounds: @OptVec<ast::TyParamBound>) {
17551755
17561756
match *bound {
17571757
TraitTyParamBound(ty) => print_type(s, ty),
1758-
RegionTyParamBound => word(s.s, ~"&static"),
1758+
RegionTyParamBound => word(s.s, ~"'static"),
17591759
}
17601760
}
17611761
}

src/test/compile-fail/kindck-owned-trait-scoped.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ fn to_foo_2<T:Copy>(t: T) -> @foo {
3737
// Not OK---T may contain borrowed ptrs and it is going to escape
3838
// as part of the returned foo value
3939
struct F<T> { f: T }
40-
@F {f:t} as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound
40+
@F {f:t} as @foo //~ ERROR value may contain borrowed pointers; use `'static` bound
4141
}
4242

43-
fn to_foo_3<T:Copy + &static>(t: T) -> @foo {
43+
fn to_foo_3<T:Copy + 'static>(t: T) -> @foo {
4444
// OK---T may escape as part of the returned foo value, but it is
4545
// owned and hence does not contain borrowed ptrs
4646
struct F<T> { f: T }

src/test/compile-fail/kindck-owned-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
trait foo { fn foo(&self); }
1212

1313
fn to_foo<T:Copy + foo>(t: T) -> @foo {
14-
@t as @foo //~ ERROR value may contain borrowed pointers; use `&static` bound
14+
@t as @foo //~ ERROR value may contain borrowed pointers; use `'static` bound
1515
}
1616

17-
fn to_foo2<T:Copy + foo + &static>(t: T) -> @foo {
17+
fn to_foo2<T:Copy + foo + 'static>(t: T) -> @foo {
1818
@t as @foo
1919
}
2020

src/test/compile-fail/kindck-owned.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ fn copy1<T:Copy>(t: T) -> @fn() -> T {
1313
result
1414
}
1515

16-
fn copy2<T:Copy + &static>(t: T) -> @fn() -> T {
16+
fn copy2<T:Copy + 'static>(t: T) -> @fn() -> T {
1717
let result: @fn() -> T = || t;
1818
result
1919
}
2020

2121
fn main() {
2222
let x = &3;
23-
copy2(&x); //~ ERROR does not fulfill `&static`
23+
copy2(&x); //~ ERROR does not fulfill `'static`
2424

2525
copy2(@3);
26-
copy2(@&x); //~ ERROR does not fulfill `&static`
26+
copy2(@&x); //~ ERROR does not fulfill `'static`
2727

2828
let boxed: @fn() = || {};
2929
copy2(boxed);
3030
let owned: ~fn() = || {};
3131
copy2(owned); //~ ERROR does not fulfill `Copy`
3232
let borrowed: &fn() = || {};
33-
copy2(borrowed); //~ ERROR does not fulfill `&static`
33+
copy2(borrowed); //~ ERROR does not fulfill `'static`
3434
}

src/test/compile-fail/static-region-bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fn f<T:&static>(_: T) {}
1+
fn f<T:'static>(_: T) {}
22

33
fn main() {
44
let x = @3;

src/test/run-pass/alignment-gep-tup-like-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct pair<A,B> {
1212
a: A, b: B
1313
}
1414

15-
fn f<A:Copy + &static>(a: A, b: u16) -> @fn() -> (A, u16) {
15+
fn f<A:Copy + 'static>(a: A, b: u16) -> @fn() -> (A, u16) {
1616
let result: @fn() -> (A, u16) = || (a, b);
1717
result
1818
}

src/test/run-pass/close-over-big-then-small-data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct Pair<A,B> {
1616
a: A, b: B
1717
}
1818

19-
fn f<A:Copy + &static>(a: A, b: u16) -> @fn() -> (A, u16) {
19+
fn f<A:Copy + 'static>(a: A, b: u16) -> @fn() -> (A, u16) {
2020
let result: @fn() -> (A, u16) = || (a, b);
2121
result
2222
}

src/test/run-pass/fixed-point-bind-unique.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
// xfail-fast
1212

13-
fn fix_help<A:&static,B:Owned>(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B {
13+
fn fix_help<A:'static,B:Owned>(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B {
1414
return f(|a| fix_help(f, a), x);
1515
}
1616

17-
fn fix<A:&static,B:Owned>(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B {
17+
fn fix<A:'static,B:Owned>(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B {
1818
return |a| fix_help(f, a);
1919
}
2020

src/test/run-pass/issue-2734.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
trait hax { }
1212
impl<A> hax for A { }
1313

14-
fn perform_hax<T:&static>(x: @T) -> @hax {
14+
fn perform_hax<T:'static>(x: @T) -> @hax {
1515
@x as @hax
1616
}
1717

src/test/run-pass/issue-2735.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
trait hax { }
1212
impl<A> hax for A { }
1313

14-
fn perform_hax<T:&static>(x: @T) -> @hax {
14+
fn perform_hax<T:'static>(x: @T) -> @hax {
1515
@x as @hax
1616
}
1717

src/test/run-pass/issue-2904.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn square_from_char(c: char) -> square {
5959
}
6060
}
6161

62-
fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] {
62+
fn read_board_grid<rdr:'static + io::Reader>(+in: rdr) -> ~[~[square]] {
6363
let in = @in as @io::Reader;
6464
let mut grid = ~[];
6565
for in.each_line |line| {

0 commit comments

Comments
 (0)