Skip to content

Commit 8544cb2

Browse files
committed
librustc: Remove @str from the language
1 parent 086849b commit 8544cb2

File tree

13 files changed

+36
-19
lines changed

13 files changed

+36
-19
lines changed

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ fn check_heap_type(cx: &Context, span: Span, ty: ty::t) {
887887
let mut n_uniq = 0;
888888
ty::fold_ty(cx.tcx, ty, |t| {
889889
match ty::get(t).sty {
890-
ty::ty_box(_) | ty::ty_str(ty::vstore_box) |
890+
ty::ty_box(_) |
891891
ty::ty_vec(_, ty::vstore_box) |
892892
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
893893
n_box += 1;

src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
179179

180180
ty::ty_box(_) |
181181
ty::ty_vec(_, ty::vstore_box) |
182-
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) |
183-
ty::ty_str(ty::vstore_box) => {
182+
ty::ty_trait(_, _, ty::BoxTraitStore, _, _) => {
184183
Some(deref_ptr(gc_ptr))
185184
}
186185

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,8 +2094,7 @@ fn type_metadata(cx: &CrateContext,
20942094
pointer_type_metadata(cx, t, vec_metadata)
20952095
}
20962096
ty::vstore_box => {
2097-
let boxed_vec_metadata = boxed_vec_metadata(cx, i8_t, usage_site_span);
2098-
pointer_type_metadata(cx, t, boxed_vec_metadata)
2097+
fail!("unexpected managed string")
20992098
}
21002099
ty::vstore_slice(_region) => {
21012100
vec_slice_metadata(cx, t, i8_t, usage_site_span)

src/librustc/middle/trans/type_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
222222
adt::incomplete_type_of(cx, repr, name)
223223
}
224224
ty::ty_str(ty::vstore_box) => {
225-
Type::at_box(cx, Type::vec(cx.sess.targ_cfg.arch, &Type::i8())).ptr_to()
225+
fail!("unexpected managed string")
226226
}
227227
ty::ty_vec(ref mt, ty::vstore_box) => {
228228
let e_ty = type_of(cx, mt.ty);

src/librustc/middle/typeck/astconv.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,17 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:RegionScope>(
413413
// will run after this as long as the path isn't a trait.
414414
let def_map = tcx.def_map.borrow();
415415
match def_map.get().find(&id) {
416-
Some(&ast::DefPrimTy(ast::TyStr)) if a_seq_ty.mutbl == ast::MutImmutable => {
416+
Some(&ast::DefPrimTy(ast::TyStr)) if
417+
a_seq_ty.mutbl == ast::MutImmutable => {
417418
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
419+
match vst {
420+
ty::vstore_box => {
421+
tcx.sess.span_err(path.span,
422+
"managed strings are not \
423+
supported")
424+
}
425+
_ => {}
426+
}
418427
return ty::mk_str(tcx, vst);
419428
}
420429
Some(&ast::DefTrait(trait_def_id)) => {

src/librustdoc/clean.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,14 @@ impl Clean<PathSegment> for ast::PathSegment {
874874
}
875875

876876
fn path_to_str(p: &ast::Path) -> ~str {
877-
use syntax::parse::token::interner_get;
877+
use syntax::parse::token;
878878

879879
let mut s = ~"";
880880
let mut first = true;
881-
for i in p.segments.iter().map(|x| interner_get(x.identifier.name)) {
881+
for i in p.segments.iter().map(|x| {
882+
let string = token::get_ident(x.identifier.name);
883+
string.get().to_str()
884+
}) {
882885
if !first || p.global {
883886
s.push_str("::");
884887
} else {

src/libstd/str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3478,7 +3478,6 @@ mod tests {
34783478
let e = $e;
34793479
assert_eq!(s1 + s2, e.to_owned());
34803480
assert_eq!(s1.to_owned() + s2, e.to_owned());
3481-
assert_eq!(s1.to_managed() + s2, e.to_owned());
34823481
} }
34833482
);
34843483

src/libsyntax/ext/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ mod test {
12241224
fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
12251225
let invalid_name = token::special_idents::invalid.name;
12261226
let (teststr, bound_connections, bound_ident_check) = match *t {
1227-
(ref str,ref conns, bic) => (str.to_managed(), conns.clone(), bic)
1227+
(ref str,ref conns, bic) => (str.to_owned(), conns.clone(), bic)
12281228
};
12291229
let cr = expand_crate_str(teststr.to_owned());
12301230
// find the bindings:
@@ -1304,7 +1304,7 @@ foo_module!()
13041304
13051305
let cxbinds : ~[&ast::Ident] =
13061306
bindings.iter().filter(|b| {
1307-
let string = token::get_ident(b);
1307+
let string = token::get_ident(b.name);
13081308
"xx" == string.get()
13091309
}).collect();
13101310
let cxbind = match cxbinds {

src/libsyntax/parse/obsolete.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub enum ObsoleteSyntax {
4545
ObsoleteMultipleImport,
4646
ObsoleteExternModAttributesInParens,
4747
ObsoleteManagedPattern,
48+
ObsoleteManagedString,
4849
}
4950

5051
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -154,6 +155,10 @@ impl ParserObsoleteMethods for Parser {
154155
"use a nested `match` expression instead of a managed box \
155156
pattern"
156157
),
158+
ObsoleteManagedString => (
159+
"managed string",
160+
"use `Rc<~str>` instead of a managed string"
161+
),
157162
};
158163

159164
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,10 @@ impl Parser {
22952295
ex = match e.node {
22962296
ExprVec(..) |
22972297
ExprRepeat(..) => ExprVstore(e, ExprVstoreBox),
2298-
ExprLit(lit) if lit_is_str(lit) => ExprVstore(e, ExprVstoreBox),
2298+
ExprLit(lit) if lit_is_str(lit) => {
2299+
self.obsolete(self.last_span, ObsoleteManagedString);
2300+
ExprVstore(e, ExprVstoreBox)
2301+
}
22992302
_ => self.mk_unary(UnBox, e)
23002303
};
23012304
}

src/libsyntax/parse/token.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ pub fn get_ident_interner() -> @IdentInterner {
544544
/// interner lives for the life of the task, this can be safely treated as an
545545
/// immortal string, as long as it never crosses between tasks.
546546
///
547-
/// XXX(pcwalton): You must be careful about what you do in the destructors of
548-
/// objects stored in TLS, because they may run after the interner is
547+
/// FIXME(pcwalton): You must be careful about what you do in the destructors
548+
/// of objects stored in TLS, because they may run after the interner is
549549
/// destroyed. In particular, they must not access string contents. This can
550550
/// be fixed in the future by just leaking all strings until task death
551551
/// somehow.
@@ -585,8 +585,9 @@ impl InternedString {
585585

586586
impl BytesContainer for InternedString {
587587
fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
588-
// XXX(pcwalton): This is a workaround for the incorrect signature of
589-
// `BytesContainer`, which is itself a workaround for the lack of DST.
588+
// FIXME(pcwalton): This is a workaround for the incorrect signature
589+
// of `BytesContainer`, which is itself a workaround for the lack of
590+
// DST.
590591
unsafe {
591592
let this = self.get();
592593
cast::transmute(this.container_as_bytes())

src/libsyntax/util/interner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ mod tests {
253253

254254
#[test]
255255
fn i3 () {
256-
let i : Interner<@~str> = Interner::prefill([
256+
let i : Interner<RcStr> = Interner::prefill([
257257
RcStr::new("Alan"),
258258
RcStr::new("Bob"),
259259
RcStr::new("Carol")

src/test/compile-fail/lint-heap-memory.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fn main() {
2525
@[1]; //~ ERROR type uses managed
2626
//~^ ERROR type uses managed
2727
fn f(_: @Clone) {} //~ ERROR type uses managed
28-
//~^ ERROR type uses managed
2928

3029
~2; //~ ERROR type uses owned
3130
~[1]; //~ ERROR type uses owned

0 commit comments

Comments
 (0)