Skip to content

Commit 731469f

Browse files
committed
Convert Option<&Lrc<T>> return types to Option<&T>.
It's simpler and more concise.
1 parent 55a22d2 commit 731469f

File tree

9 files changed

+28
-30
lines changed

9 files changed

+28
-30
lines changed

compiler/rustc_codegen_ssa/src/back/write.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_ast::attr;
1111
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
1212
use rustc_data_structures::memmap::Mmap;
1313
use rustc_data_structures::profiling::{SelfProfilerRef, VerboseTimingGuard};
14-
use rustc_data_structures::sync::Lrc;
1514
use rustc_errors::emitter::Emitter;
1615
use rustc_errors::translation::Translate;
1716
use rustc_errors::{
@@ -1889,7 +1888,7 @@ impl SharedEmitter {
18891888
}
18901889

18911890
impl Translate for SharedEmitter {
1892-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
1891+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
18931892
None
18941893
}
18951894

@@ -1924,7 +1923,7 @@ impl Emitter for SharedEmitter {
19241923
);
19251924
}
19261925

1927-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
1926+
fn source_map(&self) -> Option<&SourceMap> {
19281927
None
19291928
}
19301929
}

compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub struct AnnotateSnippetEmitter {
3434
}
3535

3636
impl Translate for AnnotateSnippetEmitter {
37-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
38-
self.fluent_bundle.as_ref()
37+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
38+
self.fluent_bundle.as_deref()
3939
}
4040

4141
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -69,8 +69,8 @@ impl Emitter for AnnotateSnippetEmitter {
6969
);
7070
}
7171

72-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
73-
self.source_map.as_ref()
72+
fn source_map(&self) -> Option<&SourceMap> {
73+
self.source_map.as_deref()
7474
}
7575

7676
fn should_show_explain(&self) -> bool {

compiler/rustc_errors/src/emitter.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub trait Emitter: Translate {
205205
false
206206
}
207207

208-
fn source_map(&self) -> Option<&Lrc<SourceMap>>;
208+
fn source_map(&self) -> Option<&SourceMap>;
209209

210210
/// Formats the substitutions of the primary_span
211211
///
@@ -481,8 +481,8 @@ pub trait Emitter: Translate {
481481
}
482482

483483
impl Translate for HumanEmitter {
484-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
485-
self.fluent_bundle.as_ref()
484+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
485+
self.fluent_bundle.as_deref()
486486
}
487487

488488
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -491,8 +491,8 @@ impl Translate for HumanEmitter {
491491
}
492492

493493
impl Emitter for HumanEmitter {
494-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
495-
self.sm.as_ref()
494+
fn source_map(&self) -> Option<&SourceMap> {
495+
self.sm.as_deref()
496496
}
497497

498498
fn emit_diagnostic(&mut self, mut diag: DiagInner) {
@@ -540,7 +540,7 @@ pub struct SilentEmitter {
540540
}
541541

542542
impl Translate for SilentEmitter {
543-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
543+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
544544
None
545545
}
546546

@@ -552,7 +552,7 @@ impl Translate for SilentEmitter {
552552
}
553553

554554
impl Emitter for SilentEmitter {
555-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
555+
fn source_map(&self) -> Option<&SourceMap> {
556556
None
557557
}
558558

compiler/rustc_errors/src/json.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ enum EmitTyped<'a> {
111111
}
112112

113113
impl Translate for JsonEmitter {
114-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
115-
self.fluent_bundle.as_ref()
114+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
115+
self.fluent_bundle.as_deref()
116116
}
117117

118118
fn fallback_fluent_bundle(&self) -> &FluentBundle {
@@ -172,7 +172,7 @@ impl Emitter for JsonEmitter {
172172
}
173173
}
174174

175-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
175+
fn source_map(&self) -> Option<&SourceMap> {
176176
Some(&self.sm)
177177
}
178178

compiler/rustc_errors/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use registry::Registry;
5959
use rustc_data_structures::AtomicRef;
6060
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
6161
use rustc_data_structures::stable_hasher::{Hash128, StableHasher};
62-
use rustc_data_structures::sync::{Lock, Lrc};
62+
use rustc_data_structures::sync::Lock;
6363
pub use rustc_error_messages::{
6464
DiagMessage, FluentBundle, LanguageIdentifier, LazyFallbackBundle, MultiSpan, SpanLabel,
6565
SubdiagMessage, fallback_fluent_bundle, fluent_bundle,
@@ -685,13 +685,13 @@ impl DiagCtxt {
685685
unimplemented!("false emitter must only used during `wrap_emitter`")
686686
}
687687

688-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
688+
fn source_map(&self) -> Option<&SourceMap> {
689689
unimplemented!("false emitter must only used during `wrap_emitter`")
690690
}
691691
}
692692

693693
impl translation::Translate for FalseEmitter {
694-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
694+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
695695
unimplemented!("false emitter must only used during `wrap_emitter`")
696696
}
697697

compiler/rustc_errors/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc};
1+
use rustc_data_structures::sync::IntoDynSyncSend;
22
use rustc_error_messages::fluent_bundle::resolver::errors::{ReferenceKind, ResolverError};
33
use rustc_error_messages::{DiagMessage, langid};
44

@@ -12,7 +12,7 @@ struct Dummy {
1212
}
1313

1414
impl Translate for Dummy {
15-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>> {
15+
fn fluent_bundle(&self) -> Option<&FluentBundle> {
1616
None
1717
}
1818

compiler/rustc_errors/src/translation.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::borrow::Cow;
22
use std::env;
33
use std::error::Report;
44

5-
use rustc_data_structures::sync::Lrc;
65
pub use rustc_error_messages::FluentArgs;
76
use tracing::{debug, trace};
87

@@ -33,7 +32,7 @@ pub trait Translate {
3332
/// Return `FluentBundle` with localized diagnostics for the locale requested by the user. If no
3433
/// language was requested by the user then this will be `None` and `fallback_fluent_bundle`
3534
/// should be used.
36-
fn fluent_bundle(&self) -> Option<&Lrc<FluentBundle>>;
35+
fn fluent_bundle(&self) -> Option<&FluentBundle>;
3736

3837
/// Return `FluentBundle` with localized diagnostics for the default locale of the compiler.
3938
/// Used when the user has not requested a specific language or when a localized diagnostic is

src/librustdoc/passes/lint/check_code_block_syntax.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct BufferEmitter {
145145
}
146146

147147
impl Translate for BufferEmitter {
148-
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
148+
fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
149149
None
150150
}
151151

@@ -169,7 +169,7 @@ impl Emitter for BufferEmitter {
169169
}
170170
}
171171

172-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
172+
fn source_map(&self) -> Option<&SourceMap> {
173173
None
174174
}
175175
}

src/tools/rustfmt/src/parse/session.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl SilentOnIgnoredFilesEmitter {
4646
}
4747

4848
impl Translate for SilentOnIgnoredFilesEmitter {
49-
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
49+
fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
5050
self.emitter.fluent_bundle()
5151
}
5252

@@ -56,7 +56,7 @@ impl Translate for SilentOnIgnoredFilesEmitter {
5656
}
5757

5858
impl Emitter for SilentOnIgnoredFilesEmitter {
59-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
59+
fn source_map(&self) -> Option<&SourceMap> {
6060
None
6161
}
6262

@@ -344,7 +344,7 @@ mod tests {
344344
}
345345

346346
impl Translate for TestEmitter {
347-
fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
347+
fn fluent_bundle(&self) -> Option<&rustc_errors::FluentBundle> {
348348
None
349349
}
350350

@@ -354,7 +354,7 @@ mod tests {
354354
}
355355

356356
impl Emitter for TestEmitter {
357-
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
357+
fn source_map(&self) -> Option<&SourceMap> {
358358
None
359359
}
360360

0 commit comments

Comments
 (0)