rustc: Make shape-based compare glue never called for comparison operators.
Only called for string patterns.
This commit is contained in:
parent
9a15c50f6c
commit
22b8757705
22 changed files with 322 additions and 82 deletions
|
|
@ -405,6 +405,13 @@ enum proto {
|
|||
proto_block, // fn&
|
||||
}
|
||||
|
||||
impl proto : cmp::Eq {
|
||||
pure fn eq(&&other: proto) -> bool {
|
||||
(self as uint) == (other as uint)
|
||||
}
|
||||
pure fn ne(&&other: proto) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
#[auto_serialize]
|
||||
enum vstore {
|
||||
// FIXME (#2112): Change uint to @expr (actually only constant exprs)
|
||||
|
|
@ -454,7 +461,49 @@ impl binop : cmp::Eq {
|
|||
enum unop {
|
||||
box(mutability),
|
||||
uniq(mutability),
|
||||
deref, not, neg
|
||||
deref,
|
||||
not,
|
||||
neg
|
||||
}
|
||||
|
||||
impl unop : cmp::Eq {
|
||||
pure fn eq(&&other: unop) -> bool {
|
||||
match self {
|
||||
box(e0a) => {
|
||||
match other {
|
||||
box(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
uniq(e0a) => {
|
||||
match other {
|
||||
uniq(e0b) => e0a == e0b,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
deref => {
|
||||
match other {
|
||||
deref => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
not => {
|
||||
match other {
|
||||
not => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
neg => {
|
||||
match other {
|
||||
neg => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pure fn ne(&&other: unop) -> bool {
|
||||
!self.eq(other)
|
||||
}
|
||||
}
|
||||
|
||||
// Generally, after typeck you can get the inferred value
|
||||
|
|
|
|||
|
|
@ -337,6 +337,13 @@ enum inline_attr {
|
|||
ia_never,
|
||||
}
|
||||
|
||||
impl inline_attr : cmp::Eq {
|
||||
pure fn eq(&&other: inline_attr) -> bool {
|
||||
(self as uint) == (other as uint)
|
||||
}
|
||||
pure fn ne(&&other: inline_attr) -> bool { !self.eq(other) }
|
||||
}
|
||||
|
||||
/// True if something like #[inline] is found in the list of attrs.
|
||||
fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr {
|
||||
// FIXME (#2809)---validate the usage of #[inline] and #[inline(always)]
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ struct protocol_ {
|
|||
fn get_state_by_id(id: uint) -> state { self.states[id] }
|
||||
|
||||
fn has_state(name: ~str) -> bool {
|
||||
self.states.find(|i| i.name == name) != None
|
||||
self.states.find(|i| i.name == name).is_some()
|
||||
}
|
||||
|
||||
fn filename() -> ~str {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) ->
|
|||
match elt.node {
|
||||
expr_mac(m) => match m.node {
|
||||
ast::mac_ellipsis => {
|
||||
if res != None {
|
||||
if res.is_some() {
|
||||
cx.span_fatal(m.span, ~"only one ellipsis allowed");
|
||||
}
|
||||
res =
|
||||
|
|
@ -449,7 +449,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) {
|
|||
}
|
||||
}
|
||||
{pre: pre, rep: None, post: post} => {
|
||||
if post != ~[] {
|
||||
if post.len() > 0 {
|
||||
cx.bug(~"elts_to_ell provided an invalid result");
|
||||
}
|
||||
p_t_s_r_length(cx, vec::len(pre), false, s, b);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,15 @@ enum cmnt_style {
|
|||
blank_line, // Just a manual blank line "\n\n", for layout
|
||||
}
|
||||
|
||||
impl cmnt_style : cmp::Eq {
|
||||
pure fn eq(&&other: cmnt_style) -> bool {
|
||||
(self as uint) == (other as uint)
|
||||
}
|
||||
pure fn ne(&&other: cmnt_style) -> bool {
|
||||
(self as uint) != (other as uint)
|
||||
}
|
||||
}
|
||||
|
||||
type cmnt = {style: cmnt_style, lines: ~[~str], pos: uint};
|
||||
|
||||
fn is_doc_comment(s: ~str) -> bool {
|
||||
|
|
|
|||
|
|
@ -1616,10 +1616,13 @@ fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl,
|
|||
pclose(s);
|
||||
|
||||
maybe_print_comment(s, decl.output.span.lo);
|
||||
if decl.output.node != ast::ty_nil {
|
||||
space_if_not_bol(s);
|
||||
word_space(s, ~"->");
|
||||
print_type(s, decl.output);
|
||||
match decl.output.node {
|
||||
ast::ty_nil => {}
|
||||
_ => {
|
||||
space_if_not_bol(s);
|
||||
word_space(s, ~"->");
|
||||
print_type(s, decl.output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1628,11 +1631,16 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl,
|
|||
word(s.s, ~"|");
|
||||
print_fn_args(s, decl, cap_items, None);
|
||||
word(s.s, ~"|");
|
||||
if decl.output.node != ast::ty_infer {
|
||||
space_if_not_bol(s);
|
||||
word_space(s, ~"->");
|
||||
print_type(s, decl.output);
|
||||
|
||||
match decl.output.node {
|
||||
ast::ty_infer => {}
|
||||
_ => {
|
||||
space_if_not_bol(s);
|
||||
word_space(s, ~"->");
|
||||
print_type(s, decl.output);
|
||||
}
|
||||
}
|
||||
|
||||
maybe_print_comment(s, decl.output.span.lo);
|
||||
}
|
||||
|
||||
|
|
@ -1829,14 +1837,19 @@ fn print_ty_fn(s: ps, opt_proto: Option<ast::proto>, purity: ast::purity,
|
|||
pclose(s);
|
||||
|
||||
maybe_print_comment(s, decl.output.span.lo);
|
||||
if decl.output.node != ast::ty_nil {
|
||||
space_if_not_bol(s);
|
||||
ibox(s, indent_unit);
|
||||
word_space(s, ~"->");
|
||||
if decl.cf == ast::noreturn { word_nbsp(s, ~"!"); }
|
||||
else { print_type(s, decl.output); }
|
||||
end(s);
|
||||
|
||||
match decl.output.node {
|
||||
ast::ty_nil => {}
|
||||
_ => {
|
||||
space_if_not_bol(s);
|
||||
ibox(s, indent_unit);
|
||||
word_space(s, ~"->");
|
||||
if decl.cf == ast::noreturn { word_nbsp(s, ~"!"); }
|
||||
else { print_type(s, decl.output); }
|
||||
end(s);
|
||||
}
|
||||
}
|
||||
|
||||
end(s);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue