Struct rustc_errors::DiagnosticBuilder
[−]
[src]
#[must_use]pub struct DiagnosticBuilder<'a> { pub handler: &'a Handler, // some fields omitted }
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Used for emitting structured error messages and other diagnostic information.
Fields
handler: &'a Handler
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Methods
impl<'a> DiagnosticBuilder<'a>[src]
pub fn emit(&mut self)[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Emit the diagnostic.
pub fn sub<S: Into<MultiSpan>>(
&mut self,
level: Level,
message: &str,
span: Option<S>
) -> &mut Self[src]
&mut self,
level: Level,
message: &str,
span: Option<S>
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Convenience function for internal use, clients should use one of the span_* methods instead.
pub fn delay_as_bug(&mut self)[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Delay emission of this diagnostic as a bug.
This can be useful in contexts where an error indicates a bug but typically this only happens when other compilation errors have already happened. In those cases this can be used to defer emission of this diagnostic as a bug in the compiler only if no other errors have been emitted.
In the meantime, though, callsites are required to deal with the "bug" locally in whichever way makes the most sense.
pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
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: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self[src]
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn note_expected_found_extra(
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self[src]
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn note(&mut self, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn warn(&mut self, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn help(&mut self, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_suggestion_short(
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self[src]
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn code(&mut self, s: DiagnosticId) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn new(
handler: &'a Handler,
level: Level,
message: &str
) -> DiagnosticBuilder<'a>[src]
handler: &'a Handler,
level: Level,
message: &str
) -> DiagnosticBuilder<'a>
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Convenience function for internal use, clients should use one of the struct_* methods on Handler.
pub fn new_with_code(
handler: &'a Handler,
level: Level,
code: Option<DiagnosticId>,
message: &str
) -> DiagnosticBuilder<'a>[src]
handler: &'a Handler,
level: Level,
code: Option<DiagnosticId>,
message: &str
) -> DiagnosticBuilder<'a>
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Convenience function for internal use, clients should use one of the struct_* methods on Handler.
pub fn new_diagnostic(
handler: &'a Handler,
diagnostic: Diagnostic
) -> DiagnosticBuilder<'a>[src]
handler: &'a Handler,
diagnostic: Diagnostic
) -> DiagnosticBuilder<'a>
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Creates a new DiagnosticBuilder with an already constructed
diagnostic.
Methods from Deref<Target = Diagnostic>
pub fn cancel(&mut self)[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Cancel the diagnostic (a structured diagnostic must either be emitted or
canceled or it will panic when dropped).
BEWARE: if this DiagnosticBuilder is an error, then creating it will
bump the error count on the Handler and canceling it won't undo that.
If you want to decrement the error count you should use Handler::cancel.
pub fn cancelled(&self) -> bool[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_label<T: Into<String>>(&mut self, span: Span, label: T) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
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: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self[src]
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn note_expected_found_extra(
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self[src]
&mut self,
label: &Display,
expected: DiagnosticStyledString,
found: DiagnosticStyledString,
expected_extra: &Display,
found_extra: &Display
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn note_trait_signature(
&mut self,
name: String,
signature: String
) -> &mut Self[src]
&mut self,
name: String,
signature: String
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn note(&mut self, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn highlighted_note(&mut self, msg: Vec<(String, Style)>) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_note<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn warn(&mut self, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_warn<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn help(&mut self, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_help<S: Into<MultiSpan>>(&mut self, sp: S, msg: &str) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn span_suggestion_short(
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
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.
pub fn span_suggestion(
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self[src]
&mut self,
sp: Span,
msg: &str,
suggestion: String
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
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 span_suggestions(
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self[src]
&mut self,
sp: Span,
msg: &str,
suggestions: Vec<String>
) -> &mut Self
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Prints out a message with multiple suggested edits of the code.
pub fn set_span<S: Into<MultiSpan>>(&mut self, sp: S) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn code(&mut self, s: DiagnosticId) -> &mut Self[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn message(&self) -> String[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn styled_message(&self) -> &Vec<(String, Style)>[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
pub fn copy_details_not_message(&mut self, from: &Diagnostic)[src]
🔬 This is a nightly-only experimental API. (rustc_private)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?
Used by a lint. Copies over all details but the "main message".
Trait Implementations
impl<'a> Clone for DiagnosticBuilder<'a>[src]
fn clone(&self) -> DiagnosticBuilder<'a>[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<'a> Deref for DiagnosticBuilder<'a>[src]
type Target = Diagnostic
The resulting type after dereferencing.
fn deref(&self) -> &Diagnostic[src]
Dereferences the value.
impl<'a> DerefMut for DiagnosticBuilder<'a>[src]
fn deref_mut(&mut self) -> &mut Diagnostic[src]
Mutably dereferences the value.
impl<'a> Debug for DiagnosticBuilder<'a>[src]
fn fmt(&self, f: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl<'a> Drop for DiagnosticBuilder<'a>[src]
Destructor bomb - a DiagnosticBuilder must be either emitted or canceled
or we emit a bug.