about summary refs log tree commit diff
path: root/src/libsyntax/parse/mod.rs
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-12-14 08:09:19 +0100
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-12-14 11:22:08 +0100
commitd732da813bac73d2c81caddd06df3df3d9609e3d (patch)
treecd0e25895e11c8c70e296b98de5fc8a16073c324 /src/libsyntax/parse/mod.rs
parent8954b16beb844fcac0cefe229e1c714a17de16e5 (diff)
downloadrust-d732da813bac73d2c81caddd06df3df3d9609e3d.tar.gz
rust-d732da813bac73d2c81caddd06df3df3d9609e3d.zip
Use PathBuf instead of String where applicable
Diffstat (limited to 'src/libsyntax/parse/mod.rs')
-rw-r--r--src/libsyntax/parse/mod.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs
index c679efd41ea..4d435665d3c 100644
--- a/src/libsyntax/parse/mod.rs
+++ b/src/libsyntax/parse/mod.rs
@@ -12,7 +12,7 @@
 
 use ast::{self, CrateConfig};
 use codemap::{CodeMap, FilePathMapping};
-use syntax_pos::{self, Span, FileMap, NO_EXPANSION};
+use syntax_pos::{self, Span, FileMap, NO_EXPANSION, FileName};
 use errors::{Handler, ColorConfig, DiagnosticBuilder};
 use feature_gate::UnstableFeatures;
 use parse::parser::Parser;
@@ -107,17 +107,17 @@ pub fn parse_crate_attrs_from_file<'a>(input: &Path, sess: &'a ParseSess)
     parser.parse_inner_attributes()
 }
 
-pub fn parse_crate_from_source_str(name: String, source: String, sess: &ParseSess)
+pub fn parse_crate_from_source_str(name: FileName, source: String, sess: &ParseSess)
                                        -> PResult<ast::Crate> {
     new_parser_from_source_str(sess, name, source).parse_crate_mod()
 }
 
-pub fn parse_crate_attrs_from_source_str(name: String, source: String, sess: &ParseSess)
+pub fn parse_crate_attrs_from_source_str(name: FileName, source: String, sess: &ParseSess)
                                              -> PResult<Vec<ast::Attribute>> {
     new_parser_from_source_str(sess, name, source).parse_inner_attributes()
 }
 
-pub fn parse_expr_from_source_str(name: String, source: String, sess: &ParseSess)
+pub fn parse_expr_from_source_str(name: FileName, source: String, sess: &ParseSess)
                                       -> PResult<P<ast::Expr>> {
     new_parser_from_source_str(sess, name, source).parse_expr()
 }
@@ -126,29 +126,29 @@ pub fn parse_expr_from_source_str(name: String, source: String, sess: &ParseSess
 ///
 /// Returns `Ok(Some(item))` when successful, `Ok(None)` when no item was found, and `Err`
 /// when a syntax error occurred.
-pub fn parse_item_from_source_str(name: String, source: String, sess: &ParseSess)
+pub fn parse_item_from_source_str(name: FileName, source: String, sess: &ParseSess)
                                       -> PResult<Option<P<ast::Item>>> {
     new_parser_from_source_str(sess, name, source).parse_item()
 }
 
-pub fn parse_meta_from_source_str(name: String, source: String, sess: &ParseSess)
+pub fn parse_meta_from_source_str(name: FileName, source: String, sess: &ParseSess)
                                       -> PResult<ast::MetaItem> {
     new_parser_from_source_str(sess, name, source).parse_meta_item()
 }
 
-pub fn parse_stmt_from_source_str(name: String, source: String, sess: &ParseSess)
+pub fn parse_stmt_from_source_str(name: FileName, source: String, sess: &ParseSess)
                                       -> PResult<Option<ast::Stmt>> {
     new_parser_from_source_str(sess, name, source).parse_stmt()
 }
 
-pub fn parse_stream_from_source_str(name: String, source: String, sess: &ParseSess,
+pub fn parse_stream_from_source_str(name: FileName, source: String, sess: &ParseSess,
                                     override_span: Option<Span>)
                                     -> TokenStream {
     filemap_to_stream(sess, sess.codemap().new_filemap(name, source), override_span)
 }
 
 // Create a new parser from a source string
-pub fn new_parser_from_source_str(sess: &ParseSess, name: String, source: String)
+pub fn new_parser_from_source_str(sess: &ParseSess, name: FileName, source: String)
                                       -> Parser {
     let mut parser = filemap_to_parser(sess, sess.codemap().new_filemap(name, source));
     parser.recurse_into_file_modules = false;
@@ -1018,7 +1018,7 @@ mod tests {
     #[test] fn crlf_doc_comments() {
         let sess = ParseSess::new(FilePathMapping::empty());
 
-        let name = "<source>".to_string();
+        let name = FileName::Custom("source".to_string());
         let source = "/// doc comment\r\nfn foo() {}".to_string();
         let item = parse_item_from_source_str(name.clone(), source, &sess)
             .unwrap().unwrap();
@@ -1042,7 +1042,7 @@ mod tests {
     #[test]
     fn ttdelim_span() {
         let sess = ParseSess::new(FilePathMapping::empty());
-        let expr = parse::parse_expr_from_source_str("foo".to_string(),
+        let expr = parse::parse_expr_from_source_str(PathBuf::from("foo").into(),
             "foo!( fn main() { body } )".to_string(), &sess).unwrap();
 
         let tts: Vec<_> = match expr.node {
@@ -1065,7 +1065,7 @@ mod tests {
     fn out_of_line_mod() {
         let sess = ParseSess::new(FilePathMapping::empty());
         let item = parse_item_from_source_str(
-            "foo".to_owned(),
+            PathBuf::from("foo").into(),
             "mod foo { struct S; mod this_does_not_exist; }".to_owned(),
             &sess,
         ).unwrap().unwrap();