]> git.lizzy.rs Git - rust.git/commitdiff
librustc: Remove `@str` from the language
authorPatrick Walton <pcwalton@mimiga.net>
Sat, 1 Feb 2014 02:25:08 +0000 (18:25 -0800)
committerHuon Wilson <dbau.pp+github@gmail.com>
Sat, 1 Feb 2014 14:44:50 +0000 (01:44 +1100)
13 files changed:
src/librustc/middle/lint.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/type_of.rs
src/librustc/middle/typeck/astconv.rs
src/librustdoc/clean.rs
src/libstd/str.rs
src/libsyntax/ext/expand.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/util/interner.rs
src/test/compile-fail/lint-heap-memory.rs

index af83bc97adc46b28b120ae43df1ca04fd7be7247..33f97b3ba2ab1618c44c6b13a3e83ba08fa5f653 100644 (file)
@@ -887,7 +887,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
         let mut n_uniq = 0;
         ty::fold_ty(cx.tcx, ty, |t| {
             match ty::get(t).sty {
-                ty::ty_box(_) | ty::ty_str(ty::vstore_box) |
+                ty::ty_box(_) |
                 ty::ty_vec(_, ty::vstore_box) |
                 ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
                     n_box += 1;
index d98cf9795b22ce29a78d4ae1c2e5d342127f304a..9bab74dc56a67fbb8cc8b38d0404ecec58c4e0cd 100644 (file)
@@ -179,8 +179,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
 
         ty::ty_box(_) |
         ty::ty_vec(_, ty::vstore_box) |
-        ty::ty_trait(_, _, ty::BoxTraitStore, _, _) |
-        ty::ty_str(ty::vstore_box) => {
+        ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
             Some(deref_ptr(gc_ptr))
         }
 
index 2611076f15de95d2e79731a8f7621e61ae49cfa7..b89ec9d19dfbbcb2de2300789fc3f11633ba4131 100644 (file)
@@ -2094,8 +2094,7 @@ fn create_pointer_to_box_metadata(cx: &CrateContext,
                     pointer_type_metadata(cx, t, vec_metadata)
                 }
                 ty::vstore_box => {
-                    let boxed_vec_metadata = boxed_vec_metadata(cx, i8_t, usage_site_span);
-                    pointer_type_metadata(cx, t, boxed_vec_metadata)
+                    fail!("unexpected managed string")
                 }
                 ty::vstore_slice(_region) => {
                     vec_slice_metadata(cx, t, i8_t, usage_site_span)
index 86456187d1ad1bdfb78ff45a714c7d01f32a1d18..b440db66a12ff1dc8f6a103732ccee1f6051665b 100644 (file)
@@ -222,7 +222,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
         adt::incomplete_type_of(cx, repr, name)
       }
       ty::ty_str(ty::vstore_box) => {
-          Type::at_box(cx, Type::vec(cx.sess.targ_cfg.arch, &Type::i8())).ptr_to()
+          fail!("unexpected managed string")
       }
       ty::ty_vec(ref mt, ty::vstore_box) => {
           let e_ty = type_of(cx, mt.ty);
index 9f44aa1a0237e8d0ee8d4a2940075c4d43789553..9f8b9140417e3c103ea82cbc812db708ae177aad 100644 (file)
@@ -413,8 +413,17 @@ fn mk_pointer<AC:AstConv,
                 // will run after this as long as the path isn't a trait.
                 let def_map = tcx.def_map.borrow();
                 match def_map.get().find(&id) {
-                    Some(&ast::DefPrimTy(ast::TyStr)) if a_seq_ty.mutbl == ast::MutImmutable => {
+                    Some(&ast::DefPrimTy(ast::TyStr)) if
+                            a_seq_ty.mutbl == ast::MutImmutable => {
                         check_path_args(tcx, path, NO_TPS | NO_REGIONS);
+                        match vst {
+                            ty::vstore_box => {
+                                tcx.sess.span_err(path.span,
+                                                  "managed strings are not \
+                                                   supported")
+                            }
+                            _ => {}
+                        }
                         return ty::mk_str(tcx, vst);
                     }
                     Some(&ast::DefTrait(trait_def_id)) => {
index 53bae09f58c94e4d893394c552b11788c49c3d10..4f7e6df95e1cbc4fb23fb21d9df1c9a438d74adc 100644 (file)
@@ -874,11 +874,14 @@ fn clean(&self) -> PathSegment {
 }
 
 fn path_to_str(p: &ast::Path) -> ~str {
-    use syntax::parse::token::interner_get;
+    use syntax::parse::token;
 
     let mut s = ~"";
     let mut first = true;
-    for i in p.segments.iter().map(|x| interner_get(x.identifier.name)) {
+    for i in p.segments.iter().map(|x| {
+            let string = token::get_ident(x.identifier.name);
+            string.get().to_str()
+    }) {
         if !first || p.global {
             s.push_str("::");
         } else {
index 5d5beb3609e8508cac37c641783abf50b990cb82..0315e560bb783c98cd306f950685d55c6405c454 100644 (file)
@@ -3477,7 +3477,6 @@ macro_rules! t (
                 let e = $e;
                 assert_eq!(s1 + s2, e.to_owned());
                 assert_eq!(s1.to_owned() + s2, e.to_owned());
-                assert_eq!(s1.to_managed() + s2, e.to_owned());
             } }
         );
 
index f7419e77ff595a40fd25806714bfef7595b3a434..d8d98b2779316b5d1a15cf6a918f23fbd85230e8 100644 (file)
@@ -1224,7 +1224,7 @@ fn main() -> int {user!(z)}",
     fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
         let invalid_name = token::special_idents::invalid.name;
         let (teststr, bound_connections, bound_ident_check) = match *t {
-            (ref str,ref conns, bic) => (str.to_managed(), conns.clone(), bic)
+            (ref str,ref conns, bic) => (str.to_owned(), conns.clone(), bic)
         };
         let cr = expand_crate_str(teststr.to_owned());
         // find the bindings:
@@ -1304,7 +1304,7 @@ fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
 
         let cxbinds : ~[&ast::Ident] =
             bindings.iter().filter(|b| {
-                let string = token::get_ident(b);
+                let string = token::get_ident(b.name);
                 "xx" == string.get()
             }).collect();
         let cxbind = match cxbinds {
index 04c73ce71d0207777a34d044057c501a2a6b885d..46f1f33143e1fd88de70f4334dea947c5cf4084c 100644 (file)
@@ -44,6 +44,7 @@ pub enum ObsoleteSyntax {
     ObsoleteMultipleImport,
     ObsoleteExternModAttributesInParens,
     ObsoleteManagedPattern,
+    ObsoleteManagedString,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -149,6 +150,10 @@ fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
                 "use a nested `match` expression instead of a managed box \
                  pattern"
             ),
+            ObsoleteManagedString => (
+                "managed string",
+                "use `Rc<~str>` instead of a managed string"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
index dc16f32b872519dfbc42c3681ec58c5b02dced90..fb679fa0460d5df19a8382624618eae8b7a5b4a8 100644 (file)
@@ -2295,7 +2295,10 @@ pub fn parse_prefix_expr(&mut self) -> @Expr {
             ex = match e.node {
               ExprVec(..) |
               ExprRepeat(..) => ExprVstore(e, ExprVstoreBox),
-              ExprLit(lit) if lit_is_str(lit) => ExprVstore(e, ExprVstoreBox),
+              ExprLit(lit) if lit_is_str(lit) => {
+                  self.obsolete(self.last_span, ObsoleteManagedString);
+                  ExprVstore(e, ExprVstoreBox)
+              }
               _ => self.mk_unary(UnBox, e)
             };
           }
index eb2fa151f51eb76db5ca48159db718e02abdfc95..fa53f021cdbdb3a3856d6d4289ecec41ae4d81ca 100644 (file)
@@ -544,8 +544,8 @@ pub fn get_ident_interner() -> @IdentInterner {
 /// interner lives for the life of the task, this can be safely treated as an
 /// immortal string, as long as it never crosses between tasks.
 ///
-/// XXX(pcwalton): You must be careful about what you do in the destructors of
-/// objects stored in TLS, because they may run after the interner is
+/// FIXME(pcwalton): You must be careful about what you do in the destructors
+/// of objects stored in TLS, because they may run after the interner is
 /// destroyed. In particular, they must not access string contents. This can
 /// be fixed in the future by just leaking all strings until task death
 /// somehow.
@@ -585,8 +585,9 @@ pub fn get<'a>(&'a self) -> &'a str {
 
 impl BytesContainer for InternedString {
     fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
-        // XXX(pcwalton): This is a workaround for the incorrect signature of
-        // `BytesContainer`, which is itself a workaround for the lack of DST.
+        // FIXME(pcwalton): This is a workaround for the incorrect signature
+        // of `BytesContainer`, which is itself a workaround for the lack of
+        // DST.
         unsafe {
             let this = self.get();
             cast::transmute(this.container_as_bytes())
index e20efda9c6eccbdba410eb87ef056ee2ccaa49be..fc3e55dcde2565dfae472bb6d6aacf0ba783554a 100644 (file)
@@ -253,7 +253,7 @@ fn interner_tests () {
 
     #[test]
     fn i3 () {
-        let i : Interner<@~str> = Interner::prefill([
+        let i : Interner<RcStr> = Interner::prefill([
             RcStr::new("Alan"),
             RcStr::new("Bob"),
             RcStr::new("Carol")
index 0c19988bef4263ef57919c2c44f2ffeee7eb7622..5e8c83558fb9e4a481891d2431ef42bec5b9c74f 100644 (file)
@@ -25,7 +25,6 @@ fn main() {
     @[1]; //~ ERROR type uses managed
     //~^ ERROR type uses managed
     fn f(_: @Clone) {} //~ ERROR type uses managed
-    //~^ ERROR type uses managed
 
     ~2; //~ ERROR type uses owned
     ~[1]; //~ ERROR type uses owned