Skip to content

Commit 8d6ef2e

Browse files
pcwaltonhuonw
authored andcommitted
libsyntax: De-@str pathnames
1 parent e68108b commit 8d6ef2e

File tree

8 files changed

+43
-48
lines changed

8 files changed

+43
-48
lines changed

src/librustc/driver/driver.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ pub enum PpMode {
6161
* The name used for source code that doesn't originate in a file
6262
* (e.g. source from stdin or a string)
6363
*/
64-
pub fn anon_src() -> @str { @"<anon>" }
64+
pub fn anon_src() -> ~str {
65+
"<anon>".to_str()
66+
}
6567

66-
pub fn source_name(input: &Input) -> @str {
68+
pub fn source_name(input: &Input) -> ~str {
6769
match *input {
6870
// FIXME (#9639): This needs to handle non-utf8 paths
69-
FileInput(ref ifile) => ifile.as_str().unwrap().to_managed(),
71+
FileInput(ref ifile) => ifile.as_str().unwrap().to_str(),
7072
StrInput(_) => anon_src()
7173
}
7274
}
@@ -138,7 +140,7 @@ fn parse_cfgspecs(cfgspecs: ~[~str], demitter: @diagnostic::Emitter)
138140
-> ast::CrateConfig {
139141
cfgspecs.move_iter().map(|s| {
140142
let sess = parse::new_parse_sess(Some(demitter));
141-
parse::parse_meta_from_source_str(@"cfgspec", s, ~[], sess)
143+
parse::parse_meta_from_source_str("cfgspec".to_str(), s, ~[], sess)
142144
}).collect::<ast::CrateConfig>()
143145
}
144146

@@ -484,13 +486,13 @@ fn write_out_deps(sess: Session, input: &Input, outputs: &OutputFilenames, crate
484486

485487
// Build a list of files used to compile the output and
486488
// write Makefile-compatible dependency rules
487-
let files: ~[@str] = {
489+
let files: ~[~str] = {
488490
let files = sess.codemap.files.borrow();
489491
files.get()
490492
.iter()
491493
.filter_map(|fmap| {
492494
if fmap.is_real_file() {
493-
Some(fmap.name)
495+
Some(fmap.name.clone())
494496
} else {
495497
None
496498
}

src/librustc/middle/trans/debuginfo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ fn declare_local(bcx: &Block,
931931
span: Span) {
932932
let cx: &CrateContext = bcx.ccx();
933933

934-
let filename = span_start(cx, span).file.name;
934+
let filename = span_start(cx, span).file.name.clone();
935935
let file_metadata = file_metadata(cx, filename);
936936

937937
let name: &str = token::ident_to_str(&variable_ident);
@@ -1165,7 +1165,7 @@ fn prepare_struct_metadata(cx: &CrateContext,
11651165

11661166
let (containing_scope, definition_span) = get_namespace_and_span_for_item(cx, def_id, span);
11671167

1168-
let file_name = span_start(cx, definition_span).file.name;
1168+
let file_name = span_start(cx, definition_span).file.name.clone();
11691169
let file_metadata = file_metadata(cx, file_name);
11701170

11711171
let struct_metadata_stub = create_struct_stub(cx,
@@ -2006,7 +2006,7 @@ fn trait_metadata(cx: &CrateContext,
20062006
let (containing_scope, definition_span) =
20072007
get_namespace_and_span_for_item(cx, def_id, usage_site_span);
20082008

2009-
let file_name = span_start(cx, definition_span).file.name;
2009+
let file_name = span_start(cx, definition_span).file.name.clone();
20102010
let file_metadata = file_metadata(cx, file_name);
20112011

20122012
let trait_llvm_type = type_of::type_of(cx, trait_type);

src/libsyntax/codemap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub struct ExpnInfo {
183183
callee: NameAndSpan
184184
}
185185

186-
pub type FileName = @str;
186+
pub type FileName = ~str;
187187

188188
pub struct FileLines
189189
{
@@ -301,7 +301,7 @@ impl CodeMap {
301301
pub fn lookup_char_pos_adj(&self, pos: BytePos) -> LocWithOpt {
302302
let loc = self.lookup_char_pos(pos);
303303
LocWithOpt {
304-
filename: loc.file.name,
304+
filename: loc.file.name.to_str(),
305305
line: loc.line,
306306
col: loc.col,
307307
file: Some(loc.file)
@@ -324,7 +324,7 @@ impl CodeMap {
324324

325325
pub fn span_to_filename(&self, sp: Span) -> FileName {
326326
let lo = self.lookup_char_pos(sp.lo);
327-
lo.file.name
327+
lo.file.name.to_str()
328328
}
329329

330330
pub fn span_to_lines(&self, sp: Span) -> @FileLines {

src/libsyntax/ext/quote.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub mod rt {
250250

251251
fn parse_item(&self, s: ~str) -> @ast::Item {
252252
let res = parse::parse_item_from_source_str(
253-
@"<quote expansion>",
253+
"<quote expansion>".to_str(),
254254
s,
255255
self.cfg(),
256256
self.parse_sess());
@@ -264,28 +264,25 @@ pub mod rt {
264264
}
265265

266266
fn parse_stmt(&self, s: ~str) -> @ast::Stmt {
267-
parse::parse_stmt_from_source_str(
268-
@"<quote expansion>",
269-
s,
270-
self.cfg(),
271-
~[],
272-
self.parse_sess())
267+
parse::parse_stmt_from_source_str("<quote expansion>".to_str(),
268+
s,
269+
self.cfg(),
270+
~[],
271+
self.parse_sess())
273272
}
274273

275274
fn parse_expr(&self, s: ~str) -> @ast::Expr {
276-
parse::parse_expr_from_source_str(
277-
@"<quote expansion>",
278-
s,
279-
self.cfg(),
280-
self.parse_sess())
275+
parse::parse_expr_from_source_str("<quote expansion>".to_str(),
276+
s,
277+
self.cfg(),
278+
self.parse_sess())
281279
}
282280

283281
fn parse_tts(&self, s: ~str) -> ~[ast::TokenTree] {
284-
parse::parse_tts_from_source_str(
285-
@"<quote expansion>",
286-
s,
287-
self.cfg(),
288-
self.parse_sess())
282+
parse::parse_tts_from_source_str("<quote expansion>".to_str(),
283+
s,
284+
self.cfg(),
285+
self.parse_sess())
289286
}
290287
}
291288

src/libsyntax/ext/source_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
114114
Some(src) => {
115115
// Add this input file to the code map to make it available as
116116
// dependency information
117-
let filename = file.display().to_str().to_managed();
117+
let filename = file.display().to_str();
118118
let interned = token::intern_and_get_ident(src);
119119
cx.parse_sess.cm.new_filemap(filename, src);
120120

src/libsyntax/parse/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ pub struct Literal {
347347
// probably not a good thing.
348348
pub fn gather_comments_and_literals(span_diagnostic:
349349
@diagnostic::SpanHandler,
350-
path: @str,
350+
path: ~str,
351351
srdr: &mut io::Reader)
352352
-> (~[Comment], ~[Literal]) {
353353
let src = str::from_utf8_owned(srdr.read_to_end()).unwrap();

src/libsyntax/parse/mod.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub fn parse_crate_attrs_from_file(
8989
return inner;
9090
}
9191

92-
pub fn parse_crate_from_source_str(name: @str,
92+
pub fn parse_crate_from_source_str(name: ~str,
9393
source: ~str,
9494
cfg: ast::CrateConfig,
9595
sess: @ParseSess)
@@ -101,7 +101,7 @@ pub fn parse_crate_from_source_str(name: @str,
101101
maybe_aborted(p.parse_crate_mod(),p)
102102
}
103103

104-
pub fn parse_crate_attrs_from_source_str(name: @str,
104+
pub fn parse_crate_attrs_from_source_str(name: ~str,
105105
source: ~str,
106106
cfg: ast::CrateConfig,
107107
sess: @ParseSess)
@@ -114,7 +114,7 @@ pub fn parse_crate_attrs_from_source_str(name: @str,
114114
return inner;
115115
}
116116

117-
pub fn parse_expr_from_source_str(name: @str,
117+
pub fn parse_expr_from_source_str(name: ~str,
118118
source: ~str,
119119
cfg: ast::CrateConfig,
120120
sess: @ParseSess)
@@ -123,7 +123,7 @@ pub fn parse_expr_from_source_str(name: @str,
123123
maybe_aborted(p.parse_expr(), p)
124124
}
125125

126-
pub fn parse_item_from_source_str(name: @str,
126+
pub fn parse_item_from_source_str(name: ~str,
127127
source: ~str,
128128
cfg: ast::CrateConfig,
129129
sess: @ParseSess)
@@ -133,7 +133,7 @@ pub fn parse_item_from_source_str(name: @str,
133133
maybe_aborted(p.parse_item(attrs),p)
134134
}
135135

136-
pub fn parse_meta_from_source_str(name: @str,
136+
pub fn parse_meta_from_source_str(name: ~str,
137137
source: ~str,
138138
cfg: ast::CrateConfig,
139139
sess: @ParseSess)
@@ -142,7 +142,7 @@ pub fn parse_meta_from_source_str(name: @str,
142142
maybe_aborted(p.parse_meta_item(),p)
143143
}
144144

145-
pub fn parse_stmt_from_source_str(name: @str,
145+
pub fn parse_stmt_from_source_str(name: ~str,
146146
source: ~str,
147147
cfg: ast::CrateConfig,
148148
attrs: ~[ast::Attribute],
@@ -157,7 +157,7 @@ pub fn parse_stmt_from_source_str(name: @str,
157157
maybe_aborted(p.parse_stmt(attrs),p)
158158
}
159159

160-
pub fn parse_tts_from_source_str(name: @str,
160+
pub fn parse_tts_from_source_str(name: ~str,
161161
source: ~str,
162162
cfg: ast::CrateConfig,
163163
sess: @ParseSess)
@@ -176,7 +176,7 @@ pub fn parse_tts_from_source_str(name: @str,
176176
// Create a new parser from a source string
177177
pub fn new_parser_from_source_str(sess: @ParseSess,
178178
cfg: ast::CrateConfig,
179-
name: @str,
179+
name: ~str,
180180
source: ~str)
181181
-> Parser {
182182
filemap_to_parser(sess,string_to_filemap(sess,source,name),cfg)
@@ -241,21 +241,17 @@ pub fn file_to_filemap(sess: @ParseSess, path: &Path, spanopt: Option<Span>)
241241
};
242242
match str::from_utf8_owned(bytes) {
243243
Some(s) => {
244-
return string_to_filemap(sess,
245-
s,
246-
path.as_str().unwrap().to_managed());
247-
}
248-
None => {
249-
err(format!("{} is not UTF-8 encoded", path.display()))
244+
return string_to_filemap(sess, s, path.as_str().unwrap().to_str())
250245
}
246+
None => err(format!("{} is not UTF-8 encoded", path.display())),
251247
}
252248
unreachable!()
253249
}
254250

255251
// given a session and a string, add the string to
256252
// the session's codemap and return the new filemap
257-
pub fn string_to_filemap(sess: @ParseSess, source: ~str, path: @str)
258-
-> @FileMap {
253+
pub fn string_to_filemap(sess: @ParseSess, source: ~str, path: ~str)
254+
-> @FileMap {
259255
sess.cm.new_filemap(path, source)
260256
}
261257

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn print_crate(cm: @CodeMap,
117117
intr: @IdentInterner,
118118
span_diagnostic: @diagnostic::SpanHandler,
119119
crate: &ast::Crate,
120-
filename: @str,
120+
filename: ~str,
121121
input: &mut io::Reader,
122122
out: ~io::Writer,
123123
ann: @PpAnn,

0 commit comments

Comments
 (0)