Remove file_path_mapping
param from ParseSess::new
.
It's always empty.
This commit is contained in:
parent
aa38c26bbf
commit
3996447b37
6 changed files with 11 additions and 25 deletions
|
@ -14,17 +14,13 @@ use rustc_parse::new_parser_from_source_str;
|
|||
use rustc_parse::parser::ForceCollect;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::create_default_session_globals_then;
|
||||
use rustc_span::source_map::FilePathMapping;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{BytePos, FileName, Pos, Span};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn sess() -> ParseSess {
|
||||
ParseSess::new(
|
||||
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||
FilePathMapping::empty(),
|
||||
)
|
||||
ParseSess::new(vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE])
|
||||
}
|
||||
|
||||
/// Parses an item.
|
||||
|
|
|
@ -72,10 +72,8 @@ where
|
|||
|
||||
/// Maps a string to tts, using a made-up filename.
|
||||
pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
|
||||
let ps = ParseSess::new(
|
||||
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||
FilePathMapping::empty(),
|
||||
);
|
||||
let ps =
|
||||
ParseSess::new(vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE]);
|
||||
source_file_to_stream(
|
||||
&ps,
|
||||
ps.source_map().new_source_file(PathBuf::from("bogofile").into(), source_str),
|
||||
|
@ -85,10 +83,8 @@ pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
|
|||
|
||||
/// Parses a string, returns a crate.
|
||||
pub(crate) fn string_to_crate(source_str: String) -> ast::Crate {
|
||||
let ps = ParseSess::new(
|
||||
vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||
FilePathMapping::empty(),
|
||||
);
|
||||
let ps =
|
||||
ParseSess::new(vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE]);
|
||||
with_error_checking_parse(source_str, &ps, |p| p.parse_crate_mod())
|
||||
}
|
||||
|
||||
|
|
|
@ -233,9 +233,9 @@ pub struct ParseSess {
|
|||
|
||||
impl ParseSess {
|
||||
/// Used for testing.
|
||||
pub fn new(locale_resources: Vec<&'static str>, file_path_mapping: FilePathMapping) -> Self {
|
||||
pub fn new(locale_resources: Vec<&'static str>) -> Self {
|
||||
let fallback_bundle = fallback_fluent_bundle(locale_resources, false);
|
||||
let sm = Lrc::new(SourceMap::new(file_path_mapping));
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let emitter = Box::new(
|
||||
HumanEmitter::new(stderr_destination(ColorConfig::Auto), fallback_bundle)
|
||||
.sm(Some(sm.clone())),
|
||||
|
|
|
@ -4,7 +4,6 @@ use rustc_ast_pretty::pprust::state::State as Printer;
|
|||
use rustc_ast_pretty::pprust::PrintState;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::source_map::FilePathMapping;
|
||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
|
||||
|
@ -63,8 +62,7 @@ fn snippet_equal_to_token(tcx: TyCtxt<'_>, matcher: &TokenTree) -> Option<String
|
|||
let snippet = source_map.span_to_snippet(span).ok()?;
|
||||
|
||||
// Create a Parser.
|
||||
let sess =
|
||||
ParseSess::new(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec(), FilePathMapping::empty());
|
||||
let sess = ParseSess::new(rustc_driver::DEFAULT_LOCALE_RESOURCES.to_vec());
|
||||
let file_name = source_map.span_to_filename(span);
|
||||
let mut parser =
|
||||
match rustc_parse::maybe_new_parser_from_source_str(&sess, file_name, snippet.clone()) {
|
||||
|
|
|
@ -18,7 +18,6 @@ extern crate rustc_driver;
|
|||
|
||||
use rustc_parse::new_parser_from_file;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::source_map::FilePathMapping;
|
||||
use std::path::Path;
|
||||
|
||||
#[path = "mod_dir_simple/test.rs"]
|
||||
|
@ -31,10 +30,7 @@ pub fn main() {
|
|||
}
|
||||
|
||||
fn parse() {
|
||||
let parse_session = ParseSess::new(
|
||||
vec![rustc_parse::DEFAULT_LOCALE_RESOURCE],
|
||||
FilePathMapping::empty()
|
||||
);
|
||||
let parse_session = ParseSess::new(vec![rustc_parse::DEFAULT_LOCALE_RESOURCE]);
|
||||
|
||||
let path = Path::new(file!());
|
||||
let path = path.canonicalize().unwrap();
|
||||
|
|
|
@ -38,7 +38,7 @@ use rustc_ast::*;
|
|||
use rustc_ast_pretty::pprust;
|
||||
use rustc_parse::new_parser_from_source_str;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::source_map::{FilePathMapping, Spanned};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{FileName, DUMMY_SP};
|
||||
use thin_vec::{thin_vec, ThinVec};
|
||||
|
@ -225,7 +225,7 @@ fn main() {
|
|||
}
|
||||
|
||||
fn run() {
|
||||
let ps = ParseSess::new(vec![rustc_parse::DEFAULT_LOCALE_RESOURCE], FilePathMapping::empty());
|
||||
let ps = ParseSess::new(vec![rustc_parse::DEFAULT_LOCALE_RESOURCE]);
|
||||
|
||||
iter_exprs(2, &mut |mut e| {
|
||||
// If the pretty printer is correct, then `parse(print(e))` should be identical to `e`,
|
||||
|
|
Loading…
Add table
Reference in a new issue