diff options
| author | David Wood <david.wood@huawei.com> | 2022-10-17 14:11:26 +0100 | 
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2023-02-22 09:15:54 +0000 | 
| commit | 26255186e2e94e0fe62cfd0965662494b6aab27c (patch) | |
| tree | 0f067abfaeeada0568afcf197354b77720efd87c /compiler/rustc_expand/src | |
| parent | a8e37507f4815c789a6fcb204f209806a4c3952d (diff) | |
| download | rust-26255186e2e94e0fe62cfd0965662494b6aab27c.tar.gz rust-26255186e2e94e0fe62cfd0965662494b6aab27c.zip | |
various: translation resources from cg backend
Extend `CodegenBackend` trait with a function returning the translation resources from the codegen backend, which can be added to the complete list of resources provided to the emitter. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_expand/src')
| -rw-r--r-- | compiler/rustc_expand/src/parse/tests.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/tests.rs | 18 | 
2 files changed, 16 insertions, 10 deletions
| diff --git a/compiler/rustc_expand/src/parse/tests.rs b/compiler/rustc_expand/src/parse/tests.rs index a416300ba7e..8b37728b60f 100644 --- a/compiler/rustc_expand/src/parse/tests.rs +++ b/compiler/rustc_expand/src/parse/tests.rs @@ -17,11 +17,11 @@ use rustc_span::{BytePos, FileName, Pos, Span}; use std::path::PathBuf; -static TEST_LOCALE_RESOURCES: &[&str] = - &[crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE]; - fn sess() -> ParseSess { - ParseSess::new(TEST_LOCALE_RESOURCES, FilePathMapping::empty()) + ParseSess::new( + vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], + FilePathMapping::empty(), + ) } /// Parses an item. diff --git a/compiler/rustc_expand/src/tests.rs b/compiler/rustc_expand/src/tests.rs index bd1b3ff28b7..14918d3c190 100644 --- a/compiler/rustc_expand/src/tests.rs +++ b/compiler/rustc_expand/src/tests.rs @@ -34,7 +34,10 @@ 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(TEST_LOCALE_RESOURCES, FilePathMapping::empty()); + let ps = ParseSess::new( + vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], + FilePathMapping::empty(), + ); source_file_to_stream( &ps, ps.source_map().new_source_file(PathBuf::from("bogofile").into(), source_str), @@ -45,7 +48,10 @@ 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(TEST_LOCALE_RESOURCES, FilePathMapping::empty()); + let ps = ParseSess::new( + vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], + FilePathMapping::empty(), + ); with_error_checking_parse(source_str, &ps, |p| p.parse_crate_mod()) } @@ -123,14 +129,14 @@ impl<T: Write> Write for Shared<T> { } } -static TEST_LOCALE_RESOURCES: &[&str] = - &[crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE]; - fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) { create_default_session_if_not_set_then(|_| { let output = Arc::new(Mutex::new(Vec::new())); - let fallback_bundle = rustc_errors::fallback_fluent_bundle(TEST_LOCALE_RESOURCES, false); + let fallback_bundle = rustc_errors::fallback_fluent_bundle( + vec![crate::DEFAULT_LOCALE_RESOURCE, rustc_parse::DEFAULT_LOCALE_RESOURCE], + false, + ); let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty())); source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned()); | 
