Skip to content

Commit f174772

Browse files
committed
---
yaml --- r: 13023 b: refs/heads/master c: d993df7 h: refs/heads/master i: 13021: 75c74c2 13019: c4ae3ca 13015: 41023ee 13007: fdf8e9d 12991: 030e55c v: v3
1 parent 9d92d07 commit f174772

File tree

13 files changed

+33
-7
lines changed

13 files changed

+33
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 30f8555544481e998f52d196c5a0f4d04cbcf334
2+
refs/heads/master: d993df74c39d7c0938194485d7c41ba94ed419ec
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/librustsyntax/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const crate_node_id: node_id = 0;
5959
enum ty_param_bound {
6060
bound_copy,
6161
bound_send,
62+
bound_const,
6263
bound_iface(@ty),
6364
}
6465

trunk/src/librustsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
137137

138138
fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound {
139139
alt tpb {
140-
bound_copy | bound_send { tpb }
140+
bound_copy | bound_send | bound_const { tpb }
141141
bound_iface(ty) { bound_iface(fld.fold_ty(ty)) }
142142
}
143143
}

trunk/src/librustsyntax/parse/parser.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,8 +1676,11 @@ class parser {
16761676
let ident = self.parse_ident();
16771677
if self.eat(token::COLON) {
16781678
while self.token != token::COMMA && self.token != token::GT {
1679-
if self.eat_keyword("send") { bounds += [bound_send]; }
1680-
else if self.eat_keyword("copy") { bounds += [bound_copy]; }
1679+
if self.eat_keyword(self, "send") { bounds += [bound_send]; }
1680+
else if self.eat_keyword(self, "copy")
1681+
{ bounds += [bound_copy]; }
1682+
else if self.eat_keyword(self, "const")
1683+
{ bounds += [bound_const]; }
16811684
else { bounds += [bound_iface(self.parse_ty(false))]; }
16821685
}
16831686
}

trunk/src/librustsyntax/print/pprust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,7 @@ fn print_bounds(s: ps, bounds: @[ast::ty_param_bound]) {
14001400
alt bound {
14011401
ast::bound_copy { word(s.s, "copy"); }
14021402
ast::bound_send { word(s.s, "send"); }
1403+
ast::bound_const { word(s.s, "const"); }
14031404
ast::bound_iface(t) { print_type(s, t); }
14041405
}
14051406
}

trunk/src/librustsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ fn visit_ty_params<E>(tps: [ty_param], e: E, v: vt<E>) {
261261
for vec::each(*tp.bounds) {|bound|
262262
alt bound {
263263
bound_iface(t) { v.visit_ty(t, e, v); }
264-
bound_copy | bound_send { }
264+
bound_copy | bound_send | bound_const { }
265265
}
266266
}
267267
}

trunk/src/rustc/metadata/tydecode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @[ty::param_bound] {
501501
bounds += [alt check next(st) {
502502
'S' { ty::bound_send }
503503
'C' { ty::bound_copy }
504+
'K' { ty::bound_const }
504505
'I' { ty::bound_iface(parse_ty(st, conv)) }
505506
'.' { break; }
506507
}];

trunk/src/rustc/metadata/tyencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ fn enc_bounds(w: io::writer, cx: @ctxt, bs: @[ty::param_bound]) {
392392
alt bound {
393393
ty::bound_send { w.write_char('S'); }
394394
ty::bound_copy { w.write_char('C'); }
395+
ty::bound_const { w.write_char('K'); }
395396
ty::bound_iface(tp) {
396397
w.write_char('I');
397398
enc_ty(w, cx, tp);

trunk/src/rustc/middle/ty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ enum type_err {
401401
enum param_bound {
402402
bound_copy,
403403
bound_send,
404+
bound_const,
404405
bound_iface(t),
405406
}
406407

trunk/src/rustc/middle/typeck/check/method.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ impl methods for lookup {
4747
let bounds = tcx.ty_param_bounds.get(did.node);
4848
for vec::each(*bounds) {|bound|
4949
let (iid, bound_substs) = alt bound {
50-
ty::bound_copy | ty::bound_send { cont; /* ok */ }
50+
ty::bound_copy | ty::bound_send | ty::bound_const {
51+
cont; /* ok */
52+
}
5153
ty::bound_iface(bound_t) {
5254
alt check ty::get(bound_t).struct {
5355
ty::ty_iface(i, substs) { (i, substs) }

trunk/src/rustc/middle/typeck/check/vtable.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span,
6767
let mut n_bound = 0u;
6868
for vec::each(*tcx.ty_param_bounds.get(did.node)) { |bound|
6969
alt bound {
70-
ty::bound_send | ty::bound_copy { /* ignore */ }
70+
ty::bound_send | ty::bound_copy | ty::bound_const {
71+
/* ignore */
72+
}
7173
ty::bound_iface(ity) {
7274
alt check ty::get(ity).struct {
7375
ty::ty_iface(idid, substs) {

trunk/src/rustc/middle/typeck/collect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ fn ty_param_bounds(ccx: @crate_ctxt,
657657
alt b {
658658
ast::bound_send { [ty::bound_send] }
659659
ast::bound_copy { [ty::bound_copy] }
660+
ast::bound_const { [ty::bound_const] }
660661
ast::bound_iface(t) {
661662
let ity = ast_ty_to_ty(ccx, empty_rscope, t);
662663
alt ty::get(ity).struct {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Make sure const bounds work on things, and test that a few types
2+
// are const.
3+
4+
5+
fn foo<T: copy const>(x: T) -> T { x }
6+
7+
fn main() {
8+
foo(1);
9+
foo("hi");
10+
foo([1, 2, 3]);
11+
foo({field: 42});
12+
foo((1, 2u));
13+
}

0 commit comments

Comments
 (0)