Struct swc_common::errors::Diagnostic [−][src]
pub struct Diagnostic {
pub level: Level,
pub message: Vec<(String, Style)>,
pub code: Option<DiagnosticId>,
pub span: MultiSpan,
pub children: Vec<SubDiagnostic>,
pub suggestions: Vec<CodeSuggestion>,
}
Fields
level: Level
message: Vec<(String, Style)>
code: Option<DiagnosticId>
span: MultiSpan
children: Vec<SubDiagnostic>
suggestions: Vec<CodeSuggestion>
Implementations
Cancel the diagnostic (a structured diagnostic must either be emitted or canceled or it will panic when dropped).
Add a span/label to be included in the resulting snippet.
This is pushed onto the MultiSpan
that was created when the
diagnostic was first built. If you don’t call this function at
all, and you just supplied a Span
to create the diagnostic,
then the snippet will just include that Span
, which is
called the primary span.
pub fn note_expected_found(
&mut self,
label: &dyn Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
pub fn note_expected_found_extra(
&mut self,
label: &dyn Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &dyn Display,
found_extra: &dyn Display
) -> &mut Self
👎 Deprecated: Use span_suggestion_short_with_applicability
Use span_suggestion_short_with_applicability
Prints out a message with a suggested edit of the code. If the suggestion is presented inline it will only show the text message and not the text.
See CodeSuggestion
for more information.
👎 Deprecated: Use span_suggestion_with_applicability
Use span_suggestion_with_applicability
Prints out a message with a suggested edit of the code.
In case of short messages and a simple suggestion, rustc displays it as a label like
“try adding parentheses: (tup.0).1
”
The message
- should not end in any punctuation (a
:
is added automatically) - should not be a question
- should not contain any parts like “the following”, “as shown”
- may look like “to do xyz, use” or “to do xyz, use abc”
- may contain a name of a function, variable or type, but not whole expressions
See CodeSuggestion
for more information.
pub fn multipart_suggestion_with_applicability(
&mut self,
msg: &str,
suggestion: Vec<(Span, String)>,
applicability: Applicability
) -> &mut Self
Use multipart_suggestion_with_applicability
👎 Deprecated: Use span_suggestions_with_applicability
Use span_suggestions_with_applicability
Prints out a message with multiple suggested edits of the code.
pub fn span_suggestion_with_applicability(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
pub fn span_suggestion_with_applicability(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
This is a suggestion that may contain mistakes or fillers and should be read and understood by a human.
pub fn span_suggestions_with_applicability(
&mut self,
sp: Span,
msg: &str,
suggestions: impl Iterator<Item = String>,
applicability: Applicability
) -> &mut Self
pub fn span_suggestion_short_with_applicability(
&mut self,
sp: Span,
msg: &str,
suggestion: String,
applicability: Applicability
) -> &mut Self
pub fn styled_message(&self) -> &Vec<(String, Style)>ⓘ
Used by a lint. Copies over all details but the “main message”.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnwindSafe for Diagnostic
Blanket Implementations
Mutably borrows from an owned value. Read more
type ROwned = T
type ROwned = T
The owned type, stored in RCow::Owned
pub fn r_borrow(
this: &'a <T as BorrowOwned<'a>>::ROwned
) -> <T as BorrowOwned<'a>>::RBorrowed
type ForSelf = WithMetadata_<T, T>
type ForSelf = WithMetadata_<T, T>
This is always WithMetadata_<Self, Self>
Gets a reference to a field, determined by offset
. Read more
Gets a muatble reference to a field, determined by offset
. Read more
Gets a const pointer to a field,
the field is determined by offset
. Read more
pub fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
pub fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
Gets a mutable pointer to a field, determined by offset
. Read more
pub fn f_replace<F>(
&mut self,
offset: FieldOffset<S, F, Aligned>,
value: F
) -> F
pub fn f_replace<F>(
&mut self,
offset: FieldOffset<S, F, Aligned>,
value: F
) -> F
Replaces a field (determined by offset
) with value
,
returning the previous value of the field. Read more
Swaps a field (determined by offset
) with the same field in right
. Read more
pub fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> F where
F: Copy,
pub fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> F where
F: Copy,
Gets a copy of a field (determined by offset
).
The field is determined by offset
. Read more
pub fn f_replace<F>(
&mut self,
offset: FieldOffset<S, F, Unaligned>,
value: F
) -> F
pub fn f_replace<F>(
&mut self,
offset: FieldOffset<S, F, Unaligned>,
value: F
) -> F
Replaces a field (determined by offset
) with value
,
returning the previous value of the field. Read more
Swaps a field (determined by offset
) with the same field in right
. Read more
pub fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> F where
F: Copy,
pub fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> F where
F: Copy,
Gets a copy of a field (determined by offset
).
The field is determined by offset
. Read more
impl<T> SelfOps for T where
T: ?Sized,
impl<T> SelfOps for T where
T: ?Sized,
Compares the address of self
with the address of other
. Read more
Emulates the pipeline operator, allowing method syntax in more places. Read more
The same as piped
except that the function takes &Self
Useful for functions that take &Self
instead of Self
. Read more
The same as piped
, except that the function takes &mut Self
.
Useful for functions that take &mut Self
instead of Self
. Read more
Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Performs a conversion with Into
.
using the turbofish .into_::<_>()
syntax. Read more
Performs a reference to reference conversion with AsRef
,
using the turbofish .as_ref_::<_>()
syntax. Read more
Performs a mutable reference to mutable reference conversion with AsMut
,
using the turbofish .as_mut_::<_>()
syntax. Read more
unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
unsafe fn transmute_element<T>(self) -> Self::TransmutedPtr where
Self: CanTransmuteElement<T>,
Transmutes the element type of this pointer.. Read more
impl<T> TypeIdentity for T where
T: ?Sized,
impl<T> TypeIdentity for T where
T: ?Sized,
type Type = T
type Type = T
This is always Self
.
Converts a value back to the original type.
fn as_type(&self) -> &Self::Type
fn as_type(&self) -> &Self::Type
Converts a reference back to the original type.
fn as_type_mut(&mut self) -> &mut Self::Type
fn as_type_mut(&mut self) -> &mut Self::Type
Converts a mutable reference back to the original type.
fn into_type_box(self: Box<Self, Global>) -> Box<Self::Type, Global>
fn into_type_box(self: Box<Self, Global>) -> Box<Self::Type, Global>
Converts a box back to the original type.
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
Converts an Arc back to the original type. Read more
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
Converts an Rc back to the original type. Read more
Converts a value back to the original type.
fn from_type_ref(this: &Self::Type) -> &Self
fn from_type_ref(this: &Self::Type) -> &Self
Converts a reference back to the original type.
fn from_type_mut(this: &mut Self::Type) -> &mut Self
fn from_type_mut(this: &mut Self::Type) -> &mut Self
Converts a mutable reference back to the original type.
fn from_type_box(this: Box<Self::Type, Global>) -> Box<Self, Global>
fn from_type_box(this: Box<Self::Type, Global>) -> Box<Self, Global>
Converts a box back to the original type.
fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self>
fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self>
Converts an Arc back to the original type.
fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>
fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>
Converts an Rc back to the original type.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more