Skip to content

Commit

Permalink
Reorder source_str_to_stream arguments.
Browse files Browse the repository at this point in the history
It's the only one of these functions where `psess` isn't the first
argument.
  • Loading branch information
nnethercote committed May 31, 2024
1 parent aef3300 commit 2b9f414
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,9 @@ impl server::TokenStream for Rustc<'_, '_> {

fn from_str(&mut self, src: &str) -> Self::TokenStream {
source_str_to_stream(
self.psess(),
FileName::proc_macro_source_code(src),
src.to_string(),
self.psess(),
Some(self.call_site),
)
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ fn maybe_new_parser_from_source_file(
}

pub fn source_str_to_stream(
psess: &ParseSess,
name: FileName,
source: String,
psess: &ParseSess,
override_span: Option<Span>,
) -> TokenStream {
source_file_to_stream(psess, psess.source_map().new_source_file(name, source), override_span)
Expand Down Expand Up @@ -147,13 +147,13 @@ pub fn parse_in<'a, T>(
pub fn fake_token_stream_for_item(psess: &ParseSess, item: &ast::Item) -> TokenStream {
let source = pprust::item_to_string(item);
let filename = FileName::macro_expansion_source_code(&source);
source_str_to_stream(filename, source, psess, Some(item.span))
source_str_to_stream(psess, filename, source, Some(item.span))
}

pub fn fake_token_stream_for_crate(psess: &ParseSess, krate: &ast::Crate) -> TokenStream {
let source = pprust::crate_to_string_for_macros(krate);
let filename = FileName::macro_expansion_source_code(&source);
source_str_to_stream(filename, source, psess, Some(krate.spans.inner_span))
source_str_to_stream(psess, filename, source, Some(krate.spans.inner_span))
}

pub fn parse_cfg_attr(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ where
/// Maps a string to tts, using a made-up filename.
pub(crate) fn string_to_stream(source_str: String) -> TokenStream {
let psess = psess();
source_str_to_stream(PathBuf::from("bogofile").into(), source_str, &psess, None)
source_str_to_stream(&psess, PathBuf::from("bogofile").into(), source_str, None)
}

/// Parses a string, returns a crate.
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/lint/check_code_block_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn check_rust_syntax(
let span = DUMMY_SP.apply_mark(expn_id.to_expn_id(), Transparency::Transparent);

let is_empty = rustc_driver::catch_fatal_errors(|| {
source_str_to_stream(FileName::Custom(String::from("doctest")), source, &psess, Some(span))
source_str_to_stream(&psess, FileName::Custom(String::from("doctest")), source, Some(span))
.is_empty()
})
.unwrap_or(false);
Expand Down

0 comments on commit 2b9f414

Please sign in to comment.