]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #9136 : thestinger/rust/ptr, r=alexcrichton
authorbors <bors@rust-lang.org>
Thu, 12 Sep 2013 20:10:55 +0000 (13:10 -0700)
committerbors <bors@rust-lang.org>
Thu, 12 Sep 2013 20:10:55 +0000 (13:10 -0700)
This is mostly for consistency, as you can now compare raw pointers in
constant expressions or without the standard library.

It also reduces the number of `ptrtoint` instructions in the IR, making
tracking down culprits of what's usually an anti-pattern easier.

1  2 
src/librustc/middle/ty.rs

index 33870ed6acb06597e41ff094aa949db0b8816ab2,f5bb5dab41e18a5543999e34016792feeca9dbf3..e4b459bc34b344fa213564d356394da77cc0fa1a
@@@ -156,7 -156,7 +156,7 @@@ pub enum SelfMode 
  }
  
  pub struct field_ty {
 -    ident: Ident,
 +    name: Name,
      id: DefId,
      vis: ast::visibility,
  }
@@@ -1757,7 -1757,7 +1757,7 @@@ fn type_is_newtype_immediate(cx: ctxt, 
          ty_struct(def_id, ref substs) => {
              let fields = struct_fields(cx, def_id, substs);
              fields.len() == 1 &&
 -                fields[0].ident == token::special_idents::unnamed_field &&
 +                fields[0].ident.name == token::special_idents::unnamed_field.name &&
                  type_is_immediate(cx, fields[0].mt.ty)
          }
          _ => false
@@@ -4227,15 -4227,15 +4227,15 @@@ fn struct_field_tys(fields: &[@struct_f
          match field.node.kind {
              named_field(ident, visibility) => {
                  field_ty {
 -                    ident: ident,
 +                    name: ident.name,
                      id: ast_util::local_def(field.node.id),
                      vis: visibility,
                  }
              }
              unnamed_field => {
                  field_ty {
 -                    ident:
 -                        syntax::parse::token::special_idents::unnamed_field,
 +                    name:
 +                        syntax::parse::token::special_idents::unnamed_field.name,
                      id: ast_util::local_def(field.node.id),
                      vis: ast::public,
                  }
@@@ -4250,8 -4250,7 +4250,8 @@@ pub fn struct_fields(cx: ctxt, did: ast
                       -> ~[field] {
      do lookup_struct_fields(cx, did).map |f| {
         field {
 -            ident: f.ident,
 +            // FIXME #6993: change type of field to Name and get rid of new()
 +            ident: ast::Ident::new(f.name),
              mt: mt {
                  ty: lookup_field_type(cx, did, f.id, substs),
                  mutbl: MutImmutable
@@@ -4267,6 -4266,7 +4267,7 @@@ pub fn is_binopable(cx: ctxt, ty: t, op
      static tycat_int: int = 3;
      static tycat_float: int = 4;
      static tycat_bot: int = 5;
+     static tycat_raw_ptr: int = 6;
  
      static opcat_add: int = 0;
      static opcat_sub: int = 1;
            ty_int(_) | ty_uint(_) | ty_infer(IntVar(_)) => tycat_int,
            ty_float(_) | ty_infer(FloatVar(_)) => tycat_float,
            ty_bot => tycat_bot,
+           ty_ptr(_) => tycat_raw_ptr,
            _ => tycat_other
          }
      }
      /*char*/    [f, f, f, f,     t,   t,  f,   f],
      /*int*/     [t, t, t, t,     t,   t,  t,   f],
      /*float*/   [t, t, t, f,     t,   t,  f,   f],
-     /*bot*/     [t, t, t, t,     f,   f,  t,   t]];
+     /*bot*/     [t, t, t, t,     f,   f,  t,   t],
+     /*raw ptr*/ [f, f, f, f,     t,   t,  f,   f]];
  
      return tbl[tycat(cx, ty)][opcat(op)];
  }