From e186d3f3e057eef69c60c7d34e474461432ee544 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 21 May 2019 13:18:20 +0900 Subject: [PATCH 1/3] Add stream_to_parser_with_base_dir --- src/libsyntax/parse/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 0611c1d9b42a5..53d6838939d05 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -329,6 +329,13 @@ pub fn stream_to_parser(sess: &ParseSess, stream: TokenStream) -> Parser<'_> { Parser::new(sess, stream, None, true, false) } +/// Given stream, the `ParseSess` and the base directory, produces a parser. +pub fn stream_to_parser_with_base_dir<'a>(sess: &'a ParseSess, + stream: TokenStream, + base_dir: Directory<'a>) -> Parser<'a> { + Parser::new(sess, stream, Some(base_dir), true, false) +} + /// A sequence separator. pub struct SeqSep { /// The seperator token. From b07dbe1d44038b84e722cbe1efe3201e8fa934d8 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 21 May 2019 22:57:34 +0900 Subject: [PATCH 2/3] Add doc comment --- src/libsyntax/parse/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 53d6838939d05..8c1810e3efa01 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -330,6 +330,16 @@ pub fn stream_to_parser(sess: &ParseSess, stream: TokenStream) -> Parser<'_> { } /// Given stream, the `ParseSess` and the base directory, produces a parser. +/// +/// Use this function when you are creating a parser from the token stream +/// and also care about the current working directory of the parser (e.g., +/// you are trying to resolve modules defined inside a macro invocation). +/// +/// # Note +/// +/// The main usage of this function is outside of rustc, for those who uses +/// libsyntax as a library. Please do not remove this function while refactoring +/// just because it is not used in rustc codebase! pub fn stream_to_parser_with_base_dir<'a>(sess: &'a ParseSess, stream: TokenStream, base_dir: Directory<'a>) -> Parser<'a> { From 1f1a9176e7963b43155ce56d2a4cea3bee4a4f7e Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 21 May 2019 23:17:59 +0900 Subject: [PATCH 3/3] Fix tidy: remove a trailing whitespace --- src/libsyntax/parse/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 8c1810e3efa01..d0af1afd8fdbd 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -334,7 +334,7 @@ pub fn stream_to_parser(sess: &ParseSess, stream: TokenStream) -> Parser<'_> { /// Use this function when you are creating a parser from the token stream /// and also care about the current working directory of the parser (e.g., /// you are trying to resolve modules defined inside a macro invocation). -/// +/// /// # Note /// /// The main usage of this function is outside of rustc, for those who uses