Skip to content

Commit 2e631b0

Browse files
committed
---
yaml --- r: 46364 b: refs/heads/auto c: df4273f h: refs/heads/master v: v3
1 parent 473141e commit 2e631b0

File tree

9 files changed

+198
-176
lines changed

9 files changed

+198
-176
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 99c4de73001e2f85a00c819fc208b31e93808480
17+
refs/heads/auto: df4273f8742b2305632916091c2af77128a6e4bf

branches/auto/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ This requirement most often affects name-designator pairs when they occur at the
549549

550550
* `log_syntax!` : print out the arguments at compile time
551551
* `trace_macros!` : supply `true` or `false` to enable or disable printing of the macro expansion process.
552-
* `stringify!` : turn the identifier argument into a string literal
552+
* `ident_to_str!` : turn the identifier argument into a string literal
553553
* `concat_idents!` : create a new identifier by concatenating the arguments
554554

555555

branches/auto/src/librustc/metadata/creader.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub fn read_crates(diag: span_handler,
5555
visit_view_item: |a| visit_view_item(e, a),
5656
visit_item: |a| visit_item(e, a),
5757
.. *visit::default_simple_visitor()});
58+
visit_crate(e, crate);
5859
visit::visit_crate(crate, (), v);
5960
dump_crates(e.crate_cache);
6061
warn_if_multiple_versions(e, diag, e.crate_cache);
@@ -125,6 +126,20 @@ struct Env {
125126
intr: @ident_interner
126127
}
127128

129+
fn visit_crate(e: @mut Env, c: ast::crate) {
130+
let cstore = e.cstore;
131+
let link_args = attr::find_attrs_by_name(c.node.attrs, "link_args");
132+
133+
for link_args.each |a| {
134+
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
135+
Some(ref linkarg) => {
136+
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
137+
}
138+
None => {/* fallthrough */ }
139+
}
140+
}
141+
}
142+
128143
fn visit_view_item(e: @mut Env, i: @ast::view_item) {
129144
match /*bad*/copy i.node {
130145
ast::view_item_use(ident, meta_items, id) => {
@@ -181,7 +196,7 @@ fn visit_item(e: @mut Env, i: @ast::item) {
181196
for link_args.each |a| {
182197
match attr::get_meta_item_value_str(attr::attr_meta(*a)) {
183198
Some(ref linkarg) => {
184-
cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg));
199+
cstore::add_used_link_args(cstore, *linkarg);
185200
}
186201
None => {/* fallthrough */ }
187202
}

branches/auto/src/librustc/metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub fn get_used_libraries(cstore: @mut CStore) -> ~[~str] {
119119
return /*bad*/copy cstore.used_libraries;
120120
}
121121

122-
pub fn add_used_link_args(cstore: @mut CStore, args: ~str) {
122+
pub fn add_used_link_args(cstore: @mut CStore, args: &str) {
123123
cstore.used_link_args.push_all(str::split_char(args, ' '));
124124
}
125125

branches/auto/src/libsyntax/ext/pipes/ast_builder.rs

Lines changed: 86 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -67,61 +67,68 @@ pub impl append_types for @ast::path {
6767
}
6868

6969
pub trait ext_ctxt_ast_builder {
70-
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
70+
fn ty_param(&self, id: ast::ident, +bounds: ~[ast::ty_param_bound])
7171
-> ast::ty_param;
72-
fn arg(name: ident, ty: @ast::Ty) -> ast::arg;
73-
fn expr_block(e: @ast::expr) -> ast::blk;
74-
fn fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl;
75-
fn item(name: ident, span: span, +node: ast::item_) -> @ast::item;
76-
fn item_fn_poly(name: ident,
72+
fn arg(&self, name: ident, ty: @ast::Ty) -> ast::arg;
73+
fn expr_block(&self, e: @ast::expr) -> ast::blk;
74+
fn fn_decl(&self, +inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl;
75+
fn item(&self, name: ident, span: span, +node: ast::item_) -> @ast::item;
76+
fn item_fn_poly(&self, name: ident,
7777
+inputs: ~[ast::arg],
7878
output: @ast::Ty,
7979
+ty_params: ~[ast::ty_param],
8080
+body: ast::blk) -> @ast::item;
81-
fn item_fn(name: ident,
81+
fn item_fn(&self, name: ident,
8282
+inputs: ~[ast::arg],
8383
output: @ast::Ty,
8484
+body: ast::blk) -> @ast::item;
85-
fn item_enum_poly(name: ident,
85+
fn item_enum_poly(&self, name: ident,
8686
span: span,
8787
+enum_definition: ast::enum_def,
8888
+ty_params: ~[ast::ty_param]) -> @ast::item;
89-
fn item_enum(name: ident, span: span,
89+
fn item_enum(&self, name: ident, span: span,
9090
+enum_definition: ast::enum_def) -> @ast::item;
91-
fn variant(name: ident, span: span, +tys: ~[@ast::Ty]) -> ast::variant;
92-
fn item_mod(name: ident, span: span, +items: ~[@ast::item]) -> @ast::item;
93-
fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty;
94-
fn item_ty_poly(name: ident,
91+
fn item_struct_poly(&self, name: ident, span: span,
92+
struct_def: ast::struct_def,
93+
ty_params: ~[ast::ty_param]) -> @ast::item;
94+
fn item_struct(&self, name: ident, span: span,
95+
struct_def: ast::struct_def) -> @ast::item;
96+
fn struct_expr(&self, path: @ast::path,
97+
fields: ~[ast::field]) -> @ast::expr;
98+
fn variant(&self, name: ident, span: span,
99+
+tys: ~[@ast::Ty]) -> ast::variant;
100+
fn item_mod(&self, name: ident, span: span,
101+
+items: ~[@ast::item]) -> @ast::item;
102+
fn ty_path_ast_builder(&self, path: @ast::path) -> @ast::Ty;
103+
fn item_ty_poly(&self, name: ident,
95104
span: span,
96105
ty: @ast::Ty,
97106
+params: ~[ast::ty_param]) -> @ast::item;
98-
fn item_ty(name: ident, span: span, ty: @ast::Ty) -> @ast::item;
99-
fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty];
100-
fn ty_vars_global(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty];
101-
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field;
102-
fn ty_rec(+v: ~[ast::ty_field]) -> @ast::Ty;
103-
fn field_imm(name: ident, e: @ast::expr) -> ast::field;
104-
fn rec(+v: ~[ast::field]) -> @ast::expr;
105-
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk;
106-
fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt;
107-
fn stmt_expr(e: @ast::expr) -> @ast::stmt;
108-
fn block_expr(b: ast::blk) -> @ast::expr;
109-
fn ty_option(ty: @ast::Ty) -> @ast::Ty;
110-
fn ty_infer() -> @ast::Ty;
111-
fn ty_nil_ast_builder() -> @ast::Ty;
112-
fn strip_bounds(bounds: &[ast::ty_param]) -> ~[ast::ty_param];
107+
fn item_ty(&self, name: ident, span: span, ty: @ast::Ty) -> @ast::item;
108+
fn ty_vars(&self, +ty_params: ~[ast::ty_param]) -> ~[@ast::Ty];
109+
fn ty_vars_global(&self, +ty_params: ~[ast::ty_param]) -> ~[@ast::Ty];
110+
fn ty_field_imm(&self, name: ident, ty: @ast::Ty) -> ast::ty_field;
111+
fn field_imm(&self, name: ident, e: @ast::expr) -> ast::field;
112+
fn block(&self, +stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk;
113+
fn stmt_let(&self, ident: ident, e: @ast::expr) -> @ast::stmt;
114+
fn stmt_expr(&self, e: @ast::expr) -> @ast::stmt;
115+
fn block_expr(&self, b: ast::blk) -> @ast::expr;
116+
fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty;
117+
fn ty_infer(&self) -> @ast::Ty;
118+
fn ty_nil_ast_builder(&self) -> @ast::Ty;
119+
fn strip_bounds(&self, bounds: &[ast::ty_param]) -> ~[ast::ty_param];
113120
}
114121

115122
pub impl ext_ctxt_ast_builder for ext_ctxt {
116-
fn ty_option(ty: @ast::Ty) -> @ast::Ty {
123+
fn ty_option(&self, ty: @ast::Ty) -> @ast::Ty {
117124
self.ty_path_ast_builder(path_global(~[
118125
self.ident_of(~"core"),
119126
self.ident_of(~"option"),
120127
self.ident_of(~"Option")
121128
], dummy_sp()).add_ty(ty))
122129
}
123130

124-
fn block_expr(b: ast::blk) -> @ast::expr {
131+
fn block_expr(&self, b: ast::blk) -> @ast::expr {
125132
@expr {
126133
id: self.next_id(),
127134
callee_id: self.next_id(),
@@ -130,33 +137,24 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
130137
}
131138
}
132139

133-
fn stmt_expr(e: @ast::expr) -> @ast::stmt {
140+
fn stmt_expr(&self, e: @ast::expr) -> @ast::stmt {
134141
@spanned { node: ast::stmt_expr(e, self.next_id()),
135142
span: dummy_sp()}
136143
}
137144

138-
fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt {
139-
let ext_cx = self;
145+
fn stmt_let(&self, ident: ident, e: @ast::expr) -> @ast::stmt {
146+
let ext_cx = *self;
140147
quote_stmt!( let $ident = $e; )
141148
}
142149

143-
fn field_imm(name: ident, e: @ast::expr) -> ast::field {
150+
fn field_imm(&self, name: ident, e: @ast::expr) -> ast::field {
144151
spanned {
145152
node: ast::field_ { mutbl: ast::m_imm, ident: name, expr: e },
146153
span: dummy_sp(),
147154
}
148155
}
149156

150-
fn rec(+fields: ~[ast::field]) -> @ast::expr {
151-
@expr {
152-
id: self.next_id(),
153-
callee_id: self.next_id(),
154-
node: ast::expr_rec(fields, None),
155-
span: dummy_sp(),
156-
}
157-
}
158-
159-
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field {
157+
fn ty_field_imm(&self, name: ident, ty: @ast::Ty) -> ast::ty_field {
160158
spanned {
161159
node: ast::ty_field_ {
162160
ident: name,
@@ -166,29 +164,21 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
166164
}
167165
}
168166

169-
fn ty_rec(+fields: ~[ast::ty_field]) -> @ast::Ty {
170-
@ast::Ty {
171-
id: self.next_id(),
172-
node: ast::ty_rec(fields),
173-
span: dummy_sp(),
174-
}
175-
}
176-
177-
fn ty_infer() -> @ast::Ty {
167+
fn ty_infer(&self) -> @ast::Ty {
178168
@ast::Ty {
179169
id: self.next_id(),
180170
node: ast::ty_infer,
181171
span: dummy_sp(),
182172
}
183173
}
184174

185-
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
175+
fn ty_param(&self, id: ast::ident, +bounds: ~[ast::ty_param_bound])
186176
-> ast::ty_param
187177
{
188178
ast::ty_param { ident: id, id: self.next_id(), bounds: @bounds }
189179
}
190180

191-
fn arg(name: ident, ty: @ast::Ty) -> ast::arg {
181+
fn arg(&self, name: ident, ty: @ast::Ty) -> ast::arg {
192182
ast::arg {
193183
mode: ast::infer(self.next_id()),
194184
is_mutbl: false,
@@ -205,7 +195,7 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
205195
}
206196
}
207197

208-
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
198+
fn block(&self, +stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
209199
let blk = ast::blk_ {
210200
view_items: ~[],
211201
stmts: stmts,
@@ -217,11 +207,11 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
217207
spanned { node: blk, span: dummy_sp() }
218208
}
219209

220-
fn expr_block(e: @ast::expr) -> ast::blk {
210+
fn expr_block(&self, e: @ast::expr) -> ast::blk {
221211
self.block(~[], e)
222212
}
223213

224-
fn fn_decl(+inputs: ~[ast::arg],
214+
fn fn_decl(&self, +inputs: ~[ast::arg],
225215
output: @ast::Ty) -> ast::fn_decl {
226216
ast::fn_decl {
227217
inputs: inputs,
@@ -230,8 +220,7 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
230220
}
231221
}
232222

233-
fn item(name: ident,
234-
span: span,
223+
fn item(&self, name: ident, span: span,
235224
+node: ast::item_) -> @ast::item {
236225

237226
// XXX: Would be nice if our generated code didn't violate
@@ -254,7 +243,7 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
254243
span: span }
255244
}
256245

257-
fn item_fn_poly(name: ident,
246+
fn item_fn_poly(&self, name: ident,
258247
+inputs: ~[ast::arg],
259248
output: @ast::Ty,
260249
+ty_params: ~[ast::ty_param],
@@ -267,27 +256,46 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
267256
body))
268257
}
269258

270-
fn item_fn(name: ident,
259+
fn item_fn(&self, name: ident,
271260
+inputs: ~[ast::arg],
272261
output: @ast::Ty,
273262
+body: ast::blk) -> @ast::item {
274263
self.item_fn_poly(name, inputs, output, ~[], body)
275264
}
276265

277-
fn item_enum_poly(name: ident,
278-
span: span,
266+
fn item_enum_poly(&self, name: ident, span: span,
279267
+enum_definition: ast::enum_def,
280268
+ty_params: ~[ast::ty_param]) -> @ast::item {
281269
self.item(name, span, ast::item_enum(enum_definition, ty_params))
282270
}
283271

284-
fn item_enum(name: ident, span: span,
272+
fn item_enum(&self, name: ident, span: span,
285273
+enum_definition: ast::enum_def) -> @ast::item {
286274
self.item_enum_poly(name, span, enum_definition, ~[])
287275
}
288276

289-
fn variant(name: ident,
290-
span: span,
277+
fn item_struct(&self, name: ident, span: span,
278+
struct_def: ast::struct_def) -> @ast::item {
279+
self.item_struct_poly(name, span, struct_def, ~[])
280+
}
281+
282+
fn item_struct_poly(&self, name: ident, span: span,
283+
struct_def: ast::struct_def,
284+
ty_params: ~[ast::ty_param]) -> @ast::item {
285+
self.item(name, span, ast::item_struct(@struct_def, ty_params))
286+
}
287+
288+
fn struct_expr(&self, path: @ast::path,
289+
fields: ~[ast::field]) -> @ast::expr {
290+
@ast::expr {
291+
id: self.next_id(),
292+
callee_id: self.next_id(),
293+
node: ast::expr_struct(path, fields, None),
294+
span: dummy_sp()
295+
}
296+
}
297+
298+
fn variant(&self, name: ident, span: span,
291299
+tys: ~[@ast::Ty]) -> ast::variant {
292300
let args = do tys.map |ty| {
293301
ast::variant_arg { ty: *ty, id: self.next_id() }
@@ -300,14 +308,15 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
300308
kind: ast::tuple_variant_kind(args),
301309
id: self.next_id(),
302310
disr_expr: None,
303-
vis: ast::public},
311+
vis: ast::public
312+
},
304313
span: span,
305314
}
306315
}
307316

308-
fn item_mod(name: ident,
309-
span: span,
317+
fn item_mod(&self, name: ident, span: span,
310318
+items: ~[@ast::item]) -> @ast::item {
319+
311320
// XXX: Total hack: import `core::kinds::Owned` to work around a
312321
// parser bug whereby `fn f<T: ::kinds::Owned>` doesn't parse.
313322
let vi = ast::view_item_import(~[
@@ -345,45 +354,43 @@ pub impl ext_ctxt_ast_builder for ext_ctxt {
345354
)
346355
}
347356

348-
fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty {
357+
fn ty_path_ast_builder(&self, path: @ast::path) -> @ast::Ty {
349358
@ast::Ty {
350359
id: self.next_id(),
351360
node: ast::ty_path(path, self.next_id()),
352361
span: path.span,
353362
}
354363
}
355364

356-
fn ty_nil_ast_builder() -> @ast::Ty {
365+
fn ty_nil_ast_builder(&self) -> @ast::Ty {
357366
@ast::Ty {
358367
id: self.next_id(),
359368
node: ast::ty_nil,
360369
span: dummy_sp(),
361370
}
362371
}
363372

364-
fn strip_bounds(bounds: &[ast::ty_param]) -> ~[ast::ty_param] {
373+
fn strip_bounds(&self, bounds: &[ast::ty_param]) -> ~[ast::ty_param] {
365374
do bounds.map |ty_param| {
366375
ast::ty_param { bounds: @~[], ..copy *ty_param }
367376
}
368377
}
369378

370-
fn item_ty_poly(name: ident,
371-
span: span,
372-
ty: @ast::Ty,
379+
fn item_ty_poly(&self, name: ident, span: span, ty: @ast::Ty,
373380
+params: ~[ast::ty_param]) -> @ast::item {
374381
self.item(name, span, ast::item_ty(ty, params))
375382
}
376383

377-
fn item_ty(name: ident, span: span, ty: @ast::Ty) -> @ast::item {
384+
fn item_ty(&self, name: ident, span: span, ty: @ast::Ty) -> @ast::item {
378385
self.item_ty_poly(name, span, ty, ~[])
379386
}
380387

381-
fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] {
388+
fn ty_vars(&self, +ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] {
382389
ty_params.map(|p| self.ty_path_ast_builder(
383390
path(~[p.ident], dummy_sp())))
384391
}
385392

386-
fn ty_vars_global(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] {
393+
fn ty_vars_global(&self, +ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] {
387394
ty_params.map(|p| self.ty_path_ast_builder(
388395
path(~[p.ident], dummy_sp())))
389396
}

0 commit comments

Comments
 (0)