Skip to content

Commit c7e3946

Browse files
committed
---
yaml --- r: 23127 b: refs/heads/master c: 68bdc09 h: refs/heads/master i: 23125: 90ff64c 23123: ac531e6 23119: 4e512e6 v: v3
1 parent c36c1fc commit c7e3946

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
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: 2082a979e72a79508f9b5f035002cf070be04301
2+
refs/heads/master: 68bdc09650ad897cbc5477b94c0c476b1b3313c1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
161161
}
162162

163163
// Handle @, ~, and & being able to mean estrs and evecs.
164-
// If a_seq_ty is a str or a vec, make it an estr/evec
164+
// If a_seq_ty is a str or a vec, make it an estr/evec.
165+
// Also handle function sigils.
165166
fn mk_maybe_vstore<AC: ast_conv, RS: region_scope copy owned>(
166167
self: AC, rscope: RS, a_seq_ty: ast::mt, vst: ty::vstore,
167-
constr: fn(ty::mt) -> ty::t) -> ty::t {
168+
span: span, constr: fn(ty::mt) -> ty::t) -> ty::t {
168169

169170
let tcx = self.tcx();
170171

@@ -183,6 +184,25 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
183184
_ => ()
184185
}
185186
}
187+
ast::ty_fn(ast::proto_block, ast_bounds, ast_fn_decl) => {
188+
let new_proto;
189+
match vst {
190+
ty::vstore_fixed(_) => {
191+
tcx.sess.span_err(span, ~"fixed-length functions are not \
192+
allowed");
193+
new_proto = ast::proto_block;
194+
}
195+
ty::vstore_uniq => new_proto = ast::proto_uniq,
196+
ty::vstore_box => new_proto = ast::proto_box,
197+
ty::vstore_slice(_) => new_proto = ast::proto_block
198+
}
199+
200+
// Run through the normal function type conversion process.
201+
let bounds = collect::compute_bounds(self.ccx(), ast_bounds);
202+
let fn_decl = ty_of_fn_decl(self, rscope, new_proto, bounds,
203+
ast_fn_decl, none);
204+
return ty::mk_fn(tcx, fn_decl);
205+
}
186206
_ => ()
187207
}
188208

@@ -227,11 +247,11 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
227247
ast::ty_nil => ty::mk_nil(tcx),
228248
ast::ty_bot => ty::mk_bot(tcx),
229249
ast::ty_box(mt) => {
230-
mk_maybe_vstore(self, rscope, mt, ty::vstore_box,
250+
mk_maybe_vstore(self, rscope, mt, ty::vstore_box, ast_ty.span,
231251
|tmt| ty::mk_box(tcx, tmt))
232252
}
233253
ast::ty_uniq(mt) => {
234-
mk_maybe_vstore(self, rscope, mt, ty::vstore_uniq,
254+
mk_maybe_vstore(self, rscope, mt, ty::vstore_uniq, ast_ty.span,
235255
|tmt| ty::mk_uniq(tcx, tmt))
236256
}
237257
ast::ty_vec(mt) => {
@@ -246,8 +266,11 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
246266
}
247267
ast::ty_rptr(region, mt) => {
248268
let r = ast_region_to_region(self, rscope, ast_ty.span, region);
249-
mk_maybe_vstore(self, in_anon_rscope(rscope, r), mt,
269+
mk_maybe_vstore(self,
270+
in_anon_rscope(rscope, r),
271+
mt,
250272
ty::vstore_slice(r),
273+
ast_ty.span,
251274
|tmt| ty::mk_rptr(tcx, r, tmt))
252275
}
253276
ast::ty_tup(fields) => {
@@ -322,6 +345,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
322345
ast::ty_fixed_length(a_t, some(u)) => {
323346
mk_maybe_vstore(self, rscope, {ty: a_t, mutbl: ast::m_imm},
324347
ty::vstore_fixed(u),
348+
ast_ty.span,
325349
|ty| {
326350
tcx.sess.span_err(
327351
a_t.span,

0 commit comments

Comments
 (0)