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;
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))
}
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)
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);
// 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)) => {
}
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 {
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());
} }
);
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:
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 {
ObsoleteMultipleImport,
ObsoleteExternModAttributesInParens,
ObsoleteManagedPattern,
+ ObsoleteManagedString,
}
impl to_bytes::IterBytes for 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);
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)
};
}
/// 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.
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())
#[test]
fn i3 () {
- let i : Interner<@~str> = Interner::prefill([
+ let i : Interner<RcStr> = Interner::prefill([
RcStr::new("Alan"),
RcStr::new("Bob"),
RcStr::new("Carol")
@[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