Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
librustc: Remove @str from the language
  • Loading branch information
pcwalton authored and huonw committed Feb 1, 2014
1 parent 449a7a8 commit c594e67
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/lint.rs
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -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))
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/debuginfo.rs
Expand Up @@ -2094,8 +2094,7 @@ fn type_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)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/type_of.rs
Expand Up @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion src/librustc/middle/typeck/astconv.rs
Expand Up @@ -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.
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)) => {
Expand Down
7 changes: 5 additions & 2 deletions src/librustdoc/clean.rs
Expand Up @@ -874,11 +874,14 @@ impl Clean<PathSegment> for ast::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 {
Expand Down
1 change: 0 additions & 1 deletion src/libstd/str.rs
Expand Up @@ -3477,7 +3477,6 @@ mod tests {
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());
} }
);

Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/expand.rs
Expand Up @@ -1224,7 +1224,7 @@ mod test {
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:
Expand Down Expand Up @@ -1304,7 +1304,7 @@ foo_module!()
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 {
Expand Down
5 changes: 5 additions & 0 deletions src/libsyntax/parse/obsolete.rs
Expand Up @@ -44,6 +44,7 @@ pub enum ObsoleteSyntax {
ObsoleteMultipleImport,
ObsoleteExternModAttributesInParens,
ObsoleteManagedPattern,
ObsoleteManagedString,
}

impl to_bytes::IterBytes for ObsoleteSyntax {
Expand Down Expand Up @@ -149,6 +150,10 @@ impl ParserObsoleteMethods for Parser {
"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);
Expand Down
5 changes: 4 additions & 1 deletion src/libsyntax/parse/parser.rs
Expand Up @@ -2295,7 +2295,10 @@ impl Parser {
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)
};
}
Expand Down
9 changes: 5 additions & 4 deletions src/libsyntax/parse/token.rs
Expand Up @@ -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.
Expand Down Expand Up @@ -585,8 +585,9 @@ impl InternedString {

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())
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/util/interner.rs
Expand Up @@ -253,7 +253,7 @@ mod 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")
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/lint-heap-memory.rs
Expand Up @@ -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
Expand Down

0 comments on commit c594e67

Please sign in to comment.