librustc: Remove @str
from the language
This commit is contained in:
parent
449a7a817f
commit
c594e675eb
13 changed files with 36 additions and 19 deletions
|
@ -887,7 +887,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
|
||||||
let mut n_uniq = 0;
|
let mut n_uniq = 0;
|
||||||
ty::fold_ty(cx.tcx, ty, |t| {
|
ty::fold_ty(cx.tcx, ty, |t| {
|
||||||
match ty::get(t).sty {
|
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_vec(_, ty::vstore_box) |
|
||||||
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
||||||
n_box += 1;
|
n_box += 1;
|
||||||
|
|
|
@ -179,8 +179,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
|
||||||
|
|
||||||
ty::ty_box(_) |
|
ty::ty_box(_) |
|
||||||
ty::ty_vec(_, ty::vstore_box) |
|
ty::ty_vec(_, ty::vstore_box) |
|
||||||
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) |
|
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
|
||||||
ty::ty_str(ty::vstore_box) => {
|
|
||||||
Some(deref_ptr(gc_ptr))
|
Some(deref_ptr(gc_ptr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2094,8 +2094,7 @@ fn type_metadata(cx: &CrateContext,
|
||||||
pointer_type_metadata(cx, t, vec_metadata)
|
pointer_type_metadata(cx, t, vec_metadata)
|
||||||
}
|
}
|
||||||
ty::vstore_box => {
|
ty::vstore_box => {
|
||||||
let boxed_vec_metadata = boxed_vec_metadata(cx, i8_t, usage_site_span);
|
fail!("unexpected managed string")
|
||||||
pointer_type_metadata(cx, t, boxed_vec_metadata)
|
|
||||||
}
|
}
|
||||||
ty::vstore_slice(_region) => {
|
ty::vstore_slice(_region) => {
|
||||||
vec_slice_metadata(cx, t, i8_t, usage_site_span)
|
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)
|
adt::incomplete_type_of(cx, repr, name)
|
||||||
}
|
}
|
||||||
ty::ty_str(ty::vstore_box) => {
|
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) => {
|
ty::ty_vec(ref mt, ty::vstore_box) => {
|
||||||
let e_ty = type_of(cx, mt.ty);
|
let e_ty = type_of(cx, mt.ty);
|
||||||
|
|
|
@ -413,8 +413,17 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
|
||||||
// will run after this as long as the path isn't a trait.
|
// will run after this as long as the path isn't a trait.
|
||||||
let def_map = tcx.def_map.borrow();
|
let def_map = tcx.def_map.borrow();
|
||||||
match def_map.get().find(&id) {
|
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);
|
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);
|
return ty::mk_str(tcx, vst);
|
||||||
}
|
}
|
||||||
Some(&ast::DefTrait(trait_def_id)) => {
|
Some(&ast::DefTrait(trait_def_id)) => {
|
||||||
|
|
|
@ -874,11 +874,14 @@ impl Clean<PathSegment> for ast::PathSegment {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_to_str(p: &ast::Path) -> ~str {
|
fn path_to_str(p: &ast::Path) -> ~str {
|
||||||
use syntax::parse::token::interner_get;
|
use syntax::parse::token;
|
||||||
|
|
||||||
let mut s = ~"";
|
let mut s = ~"";
|
||||||
let mut first = true;
|
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 {
|
if !first || p.global {
|
||||||
s.push_str("::");
|
s.push_str("::");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3477,7 +3477,6 @@ mod tests {
|
||||||
let e = $e;
|
let e = $e;
|
||||||
assert_eq!(s1 + s2, e.to_owned());
|
assert_eq!(s1 + s2, e.to_owned());
|
||||||
assert_eq!(s1.to_owned() + 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 @@ mod test {
|
||||||
fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
|
fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
|
||||||
let invalid_name = token::special_idents::invalid.name;
|
let invalid_name = token::special_idents::invalid.name;
|
||||||
let (teststr, bound_connections, bound_ident_check) = match *t {
|
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());
|
let cr = expand_crate_str(teststr.to_owned());
|
||||||
// find the bindings:
|
// find the bindings:
|
||||||
|
@ -1304,7 +1304,7 @@ foo_module!()
|
||||||
|
|
||||||
let cxbinds : ~[&ast::Ident] =
|
let cxbinds : ~[&ast::Ident] =
|
||||||
bindings.iter().filter(|b| {
|
bindings.iter().filter(|b| {
|
||||||
let string = token::get_ident(b);
|
let string = token::get_ident(b.name);
|
||||||
"xx" == string.get()
|
"xx" == string.get()
|
||||||
}).collect();
|
}).collect();
|
||||||
let cxbind = match cxbinds {
|
let cxbind = match cxbinds {
|
||||||
|
|
|
@ -44,6 +44,7 @@ pub enum ObsoleteSyntax {
|
||||||
ObsoleteMultipleImport,
|
ObsoleteMultipleImport,
|
||||||
ObsoleteExternModAttributesInParens,
|
ObsoleteExternModAttributesInParens,
|
||||||
ObsoleteManagedPattern,
|
ObsoleteManagedPattern,
|
||||||
|
ObsoleteManagedString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||||
|
@ -149,6 +150,10 @@ impl ParserObsoleteMethods for Parser {
|
||||||
"use a nested `match` expression instead of a managed box \
|
"use a nested `match` expression instead of a managed box \
|
||||||
pattern"
|
pattern"
|
||||||
),
|
),
|
||||||
|
ObsoleteManagedString => (
|
||||||
|
"managed string",
|
||||||
|
"use `Rc<~str>` instead of a managed string"
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc);
|
self.report(sp, kind, kind_str, desc);
|
||||||
|
|
|
@ -2295,7 +2295,10 @@ impl Parser {
|
||||||
ex = match e.node {
|
ex = match e.node {
|
||||||
ExprVec(..) |
|
ExprVec(..) |
|
||||||
ExprRepeat(..) => ExprVstore(e, ExprVstoreBox),
|
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)
|
_ => 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
|
/// 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.
|
/// immortal string, as long as it never crosses between tasks.
|
||||||
///
|
///
|
||||||
/// XXX(pcwalton): You must be careful about what you do in the destructors of
|
/// FIXME(pcwalton): You must be careful about what you do in the destructors
|
||||||
/// objects stored in TLS, because they may run after the interner is
|
/// of objects stored in TLS, because they may run after the interner is
|
||||||
/// destroyed. In particular, they must not access string contents. This can
|
/// destroyed. In particular, they must not access string contents. This can
|
||||||
/// be fixed in the future by just leaking all strings until task death
|
/// be fixed in the future by just leaking all strings until task death
|
||||||
/// somehow.
|
/// somehow.
|
||||||
|
@ -585,8 +585,9 @@ impl InternedString {
|
||||||
|
|
||||||
impl BytesContainer for InternedString {
|
impl BytesContainer for InternedString {
|
||||||
fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
|
fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
|
||||||
// XXX(pcwalton): This is a workaround for the incorrect signature of
|
// FIXME(pcwalton): This is a workaround for the incorrect signature
|
||||||
// `BytesContainer`, which is itself a workaround for the lack of DST.
|
// of `BytesContainer`, which is itself a workaround for the lack of
|
||||||
|
// DST.
|
||||||
unsafe {
|
unsafe {
|
||||||
let this = self.get();
|
let this = self.get();
|
||||||
cast::transmute(this.container_as_bytes())
|
cast::transmute(this.container_as_bytes())
|
||||||
|
|
|
@ -253,7 +253,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn i3 () {
|
fn i3 () {
|
||||||
let i : Interner<@~str> = Interner::prefill([
|
let i : Interner<RcStr> = Interner::prefill([
|
||||||
RcStr::new("Alan"),
|
RcStr::new("Alan"),
|
||||||
RcStr::new("Bob"),
|
RcStr::new("Bob"),
|
||||||
RcStr::new("Carol")
|
RcStr::new("Carol")
|
||||||
|
|
|
@ -25,7 +25,6 @@ fn main() {
|
||||||
@[1]; //~ ERROR type uses managed
|
@[1]; //~ ERROR type uses managed
|
||||||
//~^ ERROR type uses managed
|
//~^ ERROR type uses managed
|
||||||
fn f(_: @Clone) {} //~ ERROR type uses managed
|
fn f(_: @Clone) {} //~ ERROR type uses managed
|
||||||
//~^ ERROR type uses managed
|
|
||||||
|
|
||||||
~2; //~ ERROR type uses owned
|
~2; //~ ERROR type uses owned
|
||||||
~[1]; //~ ERROR type uses owned
|
~[1]; //~ ERROR type uses owned
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue