Rollup merge of #131344 - nnethercote:ref-Lrc, r=compiler-errors
Avoid `&Lrc<T>` in various places Seeing `&Lrc<T>` is a bit suspicious, and `&T` or `Lrc<T>` is often better. r? `@oli-obk`
This commit is contained in:
commit
df61a0b1b2
16 changed files with 45 additions and 39 deletions
|
@ -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 @@ impl Emitter for AnnotateSnippetEmitter {
|
|||
);
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -205,7 +205,7 @@ pub trait Emitter: Translate {
|
|||
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 @@ pub trait Emitter: Translate {
|
|||
}
|
||||
|
||||
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 @@ impl Translate for HumanEmitter {
|
|||
}
|
||||
|
||||
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 @@ impl Translate for SilentEmitter {
|
|||
}
|
||||
|
||||
impl Emitter for SilentEmitter {
|
||||
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
|
||||
fn source_map(&self) -> Option<&SourceMap> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ impl Emitter for JsonEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
|
||||
fn source_map(&self) -> Option<&SourceMap> {
|
||||
Some(&self.sm)
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ use registry::Registry;
|
|||
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 @@ impl DiagCtxt {
|
|||
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`")
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::borrow::Cow;
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue