Skip to content

Commit 8e98267

Browse files
committed
---
yaml --- r: 44990 b: refs/heads/master c: 7782aa8 h: refs/heads/master v: v3
1 parent 80ec474 commit 8e98267

File tree

11 files changed

+36
-66
lines changed

11 files changed

+36
-66
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: 704cd648ac1160c5f02291e505697a6cf7e20945
2+
refs/heads/master: 7782aa82d2238371f8d62ed8122d05c2cc225317
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/libcore/bool.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//! Boolean logic
1313
1414
use option::{None, Option, Some};
15+
use from_str::FromStr;
16+
1517
#[cfg(notest)] use cmp;
1618

1719
/// Negation / inverse
@@ -46,13 +48,15 @@ pub pure fn is_true(v: bool) -> bool { v }
4648
pub pure fn is_false(v: bool) -> bool { !v }
4749

4850
/// Parse logic value from `s`
49-
pub pure fn from_str(s: &str) -> Option<bool> {
50-
if s == "true" {
51-
Some(true)
52-
} else if s == "false" {
53-
Some(false)
54-
} else {
55-
None
51+
impl FromStr for bool {
52+
static pure fn from_str(s: &str) -> Option<bool> {
53+
if s == "true" {
54+
Some(true)
55+
} else if s == "false" {
56+
Some(false)
57+
} else {
58+
None
59+
}
5660
}
5761
}
5862

@@ -79,8 +83,10 @@ impl cmp::Eq for bool {
7983

8084
#[test]
8185
pub fn test_bool_from_str() {
86+
use from_str::FromStr;
87+
8288
do all_values |v| {
83-
assert Some(v) == from_str(to_str(v))
89+
assert Some(v) == FromStr::from_str(to_str(v))
8490
}
8591
}
8692

trunk/src/libcore/from_str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ use option::Option;
1515
pub trait FromStr {
1616
static pure fn from_str(s: &str) -> Option<Self>;
1717
}
18-

trunk/src/librustc/front/test.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,12 @@ fn is_test_fn(i: @ast::item) -> bool {
178178

179179
fn has_test_signature(i: @ast::item) -> bool {
180180
match &i.node {
181-
&ast::item_fn(ref decl, _, ref generics, _) => {
181+
&ast::item_fn(ref decl, _, ref tps, _) => {
182182
let no_output = match decl.output.node {
183183
ast::ty_nil => true,
184184
_ => false
185185
};
186-
decl.inputs.is_empty()
187-
&& no_output
188-
&& !generics.is_parameterized()
186+
decl.inputs.is_empty() && no_output && tps.is_empty()
189187
}
190188
_ => false
191189
}

trunk/src/librustc/metadata/encoder.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,14 @@ fn encode_type(ecx: @EncodeContext, ebml_w: writer::Encoder, typ: ty::t) {
228228

229229
fn encode_symbol(ecx: @EncodeContext, ebml_w: writer::Encoder, id: node_id) {
230230
ebml_w.start_tag(tag_items_data_item_symbol);
231-
match ecx.item_symbols.find(&id) {
232-
Some(ref x) => {
233-
debug!("encode_symbol(id=%?, str=%s)", id, *x);
234-
ebml_w.writer.write(str::to_bytes(*x));
235-
}
236-
None => {
237-
ecx.diag.handler().bug(
238-
fmt!("encode_symbol: id not found %d", id));
239-
}
240-
}
231+
let sym = match ecx.item_symbols.find(&id) {
232+
Some(ref x) => (/*bad*/copy *x),
233+
None => {
234+
ecx.diag.handler().bug(
235+
fmt!("encode_symbol: id not found %d", id));
236+
}
237+
};
238+
ebml_w.writer.write(str::to_bytes(sym));
241239
ebml_w.end_tag();
242240
}
243241

@@ -266,8 +264,6 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
266264
path: &[ast_map::path_elt],
267265
index: @mut ~[entry<int>],
268266
generics: &ast::Generics) {
269-
debug!("encode_enum_variant_info(id=%?)", id);
270-
271267
let mut disr_val = 0;
272268
let mut i = 0;
273269
let vi = ty::enum_variants(ecx.tcx,

trunk/src/librustc/middle/trans/base.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,15 +2079,15 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
20792079
_ => fail!(~"trans_item"),
20802080
};
20812081
match /*bad*/copy item.node {
2082-
ast::item_fn(ref decl, purity, ref generics, ref body) => {
2082+
ast::item_fn(ref decl, purity, ref tps, ref body) => {
20832083
if purity == ast::extern_fn {
20842084
let llfndecl = get_item_val(ccx, item.id);
20852085
foreign::trans_foreign_fn(ccx,
20862086
vec::append(
20872087
/*bad*/copy *path,
20882088
~[path_name(item.ident)]),
20892089
decl, body, llfndecl, item.id);
2090-
} else if !generics.is_type_parameterized() {
2090+
} else if tps.is_empty() {
20912091
let llfndecl = get_item_val(ccx, item.id);
20922092
trans_fn(ccx,
20932093
vec::append(/*bad*/copy *path, ~[path_name(item.ident)]),
@@ -2111,8 +2111,8 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
21112111
ast::item_mod(ref m) => {
21122112
trans_mod(ccx, m);
21132113
}
2114-
ast::item_enum(ref enum_definition, ref generics) => {
2115-
if !generics.is_type_parameterized() {
2114+
ast::item_enum(ref enum_definition, ref tps) => {
2115+
if tps.is_empty() {
21162116
let degen = (*enum_definition).variants.len() == 1u;
21172117
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
21182118
let mut i = 0;
@@ -2128,8 +2128,8 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
21282128
};
21292129
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
21302130
}
2131-
ast::item_struct(struct_def, generics) => {
2132-
if !generics.is_type_parameterized() {
2131+
ast::item_struct(struct_def, tps) => {
2132+
if tps.is_empty() {
21332133
trans_struct_def(ccx, struct_def, path, item.id);
21342134
}
21352135
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item)
861861
// like "foo<X>". This is because otherwise ty_to_str will
862862
// print the name as merely "foo", as it has no way to
863863
// reconstruct the value of X.
864-
if generics.is_parameterized() { t0 } else {
864+
if !generics.is_empty() { t0 } else {
865865
ty::mk_with_id(tcx, t0, def_id)
866866
}
867867
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
315315
Some(ast_map::node_item(it,_)) => {
316316
match it.node {
317317
ast::item_fn(_, _, ref ps, _)
318-
if ps.is_parameterized() => {
318+
if !ps.is_empty() => {
319319
tcx.sess.span_err(
320320
main_span,
321321
~"main function is not allowed \

trunk/src/libsyntax/ast.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,8 @@ pub struct Generics {
161161
}
162162
163163
pub impl Generics {
164-
fn is_parameterized(&self) -> bool {
165-
self.lifetimes.len() + self.ty_params.len() > 0
166-
}
167-
fn is_lt_parameterized(&self) -> bool {
168-
self.lifetimes.len() > 0
169-
}
170-
fn is_type_parameterized(&self) -> bool {
171-
self.ty_params.len() > 0
164+
fn is_empty(&self) -> bool {
165+
self.lifetimes.len() + self.ty_params.len() == 0
172166
}
173167
}
174168

trunk/src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ pub fn print_item(s: @ps, &&item: @ast::item) {
567567
568568
ast::item_impl(ref generics, opt_trait, ty, ref methods) => {
569569
head(s, visibility_qualified(item.vis, ~"impl"));
570-
if generics.is_parameterized() {
570+
if !generics.is_empty() {
571571
print_generics(s, generics);
572572
space(s.s);
573573
}

trunk/src/test/run-pass/issue-5243.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)