Convert `Option<&Lrc<T>>` return types to `Option<&T>`.
It's simpler and more concise.
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs
index 4d81ff9..e22dd83 100644
--- a/compiler/rustc_codegen_ssa/src/back/write.rs
+++ b/compiler/rustc_codegen_ssa/src/back/write.rs
@@ -11,7 +11,6 @@
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_data_structures::memmap::Mmap;
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
-use rustc_data_structures::sync::Lrc;
use rustc_errors::emitter::Emitter;
use rustc_errors::translation::Translate;
use rustc_errors::{
@@ -1889,7 +1888,7 @@ fn fatal(&self, msg: &str) {
}
impl Translate for SharedEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
None
}
@@ -1924,7 +1923,7 @@ fn emit_diagnostic(&mut self, mut diag: rustc_errors::DiagInner) {
);
}
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
None
}
}
diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
index f468fbf..335432c 100644
--- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
+++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
@@ -34,8 +34,8 @@ pub struct AnnotateSnippetEmitter {
}
impl Translate for AnnotateSnippetEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
- self.fluent_bundle.as_ref()
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
+ self.fluent_bundle.as_deref()
}
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -69,8 +69,8 @@ fn emit_diagnostic(&mut self, mut diag: DiagInner) {
);
}
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
- self.source_map.as_ref()
+ fn source_map(&self) -> Option<&SourceMap> {
+ self.source_map.as_deref()
}
fn should_show_explain(&self) -> bool {
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 1dc52c4..1adb6b9 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -205,7 +205,7 @@ fn supports_color(&self) -> bool {
false
}
- fn source_map(&self) -> Option<&Lrc<SourceMap>>;
+ fn source_map(&self) -> Option<&SourceMap>;
/// Formats the substitutions of the primary_span
///
@@ -481,8 +481,8 @@ fn fix_multispan_in_extern_macros(&self, span: &mut MultiSpan) {
}
impl Translate for HumanEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
- self.fluent_bundle.as_ref()
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
+ self.fluent_bundle.as_deref()
}
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -491,8 +491,8 @@ fn fallback_fluent_bundle(&self) -> &FluentBundle {
}
impl Emitter for HumanEmitter {
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
- self.sm.as_ref()
+ fn source_map(&self) -> Option<&SourceMap> {
+ self.sm.as_deref()
}
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
@@ -540,7 +540,7 @@ pub struct SilentEmitter {
}
impl Translate for SilentEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
None
}
@@ -552,7 +552,7 @@ fn fallback_fluent_bundle(&self) -> &FluentBundle {
}
impl Emitter for SilentEmitter {
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
None
}
diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs
index 1972a52..1534e25 100644
--- a/compiler/rustc_errors/src/json.rs
+++ b/compiler/rustc_errors/src/json.rs
@@ -111,8 +111,8 @@ enum EmitTyped<'a> {
}
impl Translate for JsonEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
- self.fluent_bundle.as_ref()
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
+ self.fluent_bundle.as_deref()
}
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -172,7 +172,7 @@ fn emit_unused_externs(&mut self, lint_level: rustc_lint_defs::Level, unused_ext
}
}
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
Some(&self.sm)
}
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 39acacf..e5560be 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -59,7 +59,7 @@
use rustc_data_structures::AtomicRef;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
-use rustc_data_structures::sync::{Lock, Lrc};
+use rustc_data_structures::sync::Lock;
pub use rustc_error_messages::{
DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel,
SubdiagMessage, fallback_fluent_bundle, fluent_bundle,
@@ -685,13 +685,13 @@ fn emit_diagnostic(&mut self, _: DiagInner) {
unimplemented!("false emitter must only used during `wrap_emitter`")
}
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
unimplemented!("false emitter must only used during `wrap_emitter`")
}
}
impl translation::Translate for FalseEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
unimplemented!("false emitter must only used during `wrap_emitter`")
}
diff --git a/compiler/rustc_errors/src/tests.rs b/compiler/rustc_errors/src/tests.rs
index 17a1635..7017923 100644
--- a/compiler/rustc_errors/src/tests.rs
+++ b/compiler/rustc_errors/src/tests.rs
@@ -1,4 +1,4 @@
-use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
+use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
use rustc_error_messages::{DiagMessage, langid};
@@ -12,7 +12,7 @@ struct Dummy {
}
impl Translate for Dummy {
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&FluentBundle> {
None
}
diff --git a/compiler/rustc_errors/src/translation.rs b/compiler/rustc_errors/src/translation.rs
index e0b64b2..156f5e5 100644
--- a/compiler/rustc_errors/src/translation.rs
+++ b/compiler/rustc_errors/src/translation.rs
@@ -2,7 +2,6 @@
use std::env;
use std::error::Report;
-use rustc_data_structures::sync::Lrc;
pub use rustc_error_messages::FluentArgs;
use tracing::{debug, trace};
@@ -33,7 +32,7 @@ pub trait Translate {
/// Return `FluentBundle` with localized diagnostics for the locale requested by the user. If no
/// language was requested by the user then this will be `None` and `fallback_fluent_bundle`
/// should be used.
- fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>>;
+ fn fluent_bundle(&self) -> Option<&FluentBundle>;
/// Return `FluentBundle` with localized diagnostics for the default locale of the compiler.
/// Used when the user has not requested a specific language or when a localized diagnostic is
diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs
index 848e70a..e0dc5b4 100644
--- a/src/librustdoc/passes/lint/check_code_block_syntax.rs
+++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs
@@ -145,7 +145,7 @@ struct BufferEmitter {
}
impl Translate for BufferEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
None
}
@@ -169,7 +169,7 @@ fn emit_diagnostic(&mut self, diag: DiagInner) {
}
}
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
None
}
}
diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs
index 9f27a05..54ad56e 100644
--- a/src/tools/rustfmt/src/parse/session.rs
+++ b/src/tools/rustfmt/src/parse/session.rs
@@ -46,7 +46,7 @@ fn handle_non_ignoreable_error(&mut self, diag: DiagInner) {
}
impl Translate for SilentOnIgnoredFilesEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
self.emitter.fluent_bundle()
}
@@ -56,7 +56,7 @@ fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
}
impl Emitter for SilentOnIgnoredFilesEmitter {
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
None
}
@@ -344,7 +344,7 @@ struct TestEmitter {
}
impl Translate for TestEmitter {
- fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
+ fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
None
}
@@ -354,7 +354,7 @@ fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
}
impl Emitter for TestEmitter {
- fn source_map(&self) -> Option<&Lrc<SourceMap>> {
+ fn source_map(&self) -> Option<&SourceMap> {
None
}