librustc: Remove @str
from the language
This commit is contained in:
parent
449a7a817f
commit
c594e675eb
@ -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;
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)) => {
|
||||
|
@ -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 {
|
||||
|
@ -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());
|
||||
} }
|
||||
);
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
};
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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")
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user