Diag in rustc_errors::diagnostic - Rust
Description: Used for emitting structured error messages and other diagnostic information. Wraps a `DiagInner`, adding some useful things.

Skip to main content

## Diag

# Struct Diag

Source

    pub struct Diag<'a, G: EmissionGuarantee = ErrorGuaranteed> {
        pub dcx: DiagCtxtHandle<'a>,
        diag: Option<Box<DiagInner>>,
        _marker: PhantomData<G>,
    }

Expand description

Used for emitting structured error messages and other diagnostic information. Wraps a `DiagInner`, adding some useful things.

- The `dcx` field, allowing it to (a) emit itself, and (b) do a drop check that it has been emitted or cancelled.
- The `EmissionGuarantee`, which determines the type returned from `emit`.

Each constructed `Diag` must be consumed by a function such as `emit`, `cancel`, `delay_as_bug`, or `into_diag`. A panic occurs if a `Diag` is dropped without being consumed by one of these functions.

If there is some state in a downstream crate you would like to access in the methods of `Diag` here, consider extending `DiagCtxtFlags`.

## Fields§

§`dcx: DiagCtxtHandle<'a>`§`diag: Option<Box<DiagInner>>`

Why the `Option`? It is always `Some` until the `Diag` is consumed via `emit`, `cancel`, etc. At that point it is consumed and replaced with `None`. Then `drop` checks that it is `None`; if not, it panics because a diagnostic was built but not used.

Why the Box? `DiagInner` is a large type, and `Diag` is often used as a return value, especially within the frequently-used `PResult` type. In theory, return value optimization (RVO) should avoid unnecessary copying. In practice, it does not (at the time of writing).

§`_marker: PhantomData<G>`

## Implementations§

Source§

### impl<'a, G: EmissionGuarantee> Diag<'a, G>

Source

#### pub fn new( dcx: DiagCtxtHandle<'a>, level: Level, message: impl Into<DiagMessage>, ) -> Self

Source

#### pub fn with_dcx(self, dcx: DiagCtxtHandle<'_>) -> Diag<'_, G>

Allow moving diagnostics between different error tainting contexts

Source

#### pub(crate) fn new_diagnostic(dcx: DiagCtxtHandle<'a>, diag: DiagInner) -> Self

Creates a new `Diag` with an already constructed diagnostic.

Source

#### pub fn downgrade_to_delayed_bug(&mut self)

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.

Source

#### pub fn upgrade_to_fatal(self) -> Diag<'a, FatalAbort>

Make emitting this diagnostic fatal

Changes the level of this diagnostic to Fatal, and importantly also changes the emission guarantee. This is sound for errors that would otherwise be printed, but now simply exit the process instead. This function still gives an emission guarantee, the guarantee is now just that it exits fatally. For delayed bugs this is different, since those are buffered. If we upgrade one to fatal, another might now be ignored.

Source

#### pub fn span_label( &mut self, span: Span, label: impl Into<DiagMessage>, ) -> &mut Self

Appends a labeled span to the diagnostic.

Labels are used to convey additional context for the diagnostic’s primary span. They will be shown together with the original diagnostic’s span, not with spans added by `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because the span is `DUMMY_SP` or the source code isn’t found), labels will not be displayed either.

Implementation-wise, the label span is pushed onto the `MultiSpan` that was created when the diagnostic was constructed. However, the label span is not considered a “primary span”; only the `Span` supplied when creating the diagnostic is primary. See `Diag::span_label()`.

Source

#### pub fn with_span_label(self, span: Span, label: impl Into<DiagMessage>) -> Self

Appends a labeled span to the diagnostic.

Labels are used to convey additional context for the diagnostic’s primary span. They will be shown together with the original diagnostic’s span, not with spans added by `span_note`, `span_help`, etc. Therefore, if the primary span is not displayable (because the span is `DUMMY_SP` or the source code isn’t found), labels will not be displayed either.

Implementation-wise, the label span is pushed onto the `MultiSpan` that was created when the diagnostic was constructed. However, the label span is not considered a “primary span”; only the `Span` supplied when creating the diagnostic is primary. See `Diag::span_label()`.

Source

#### pub fn span_labels( &mut self, spans: impl IntoIterator<Item = Span>, label: &str, ) -> &mut Self

Labels all the given spans with the provided label. See `Self::span_label()` for more information. See `Diag::span_labels()`.

Source

#### pub fn with_span_labels( self, spans: impl IntoIterator<Item = Span>, label: &str, ) -> Self

Labels all the given spans with the provided label. See `Self::span_label()` for more information. See `Diag::span_labels()`.

Source

#### pub fn replace_span_with(&mut self, after: Span, keep_label: bool) -> &mut Self

Source

#### pub fn note_expected_found( &mut self, expected_label: &str, expected: DiagStyledString, found_label: &str, found: DiagStyledString, ) -> &mut Self

Source

#### pub fn note_expected_found_extra( &mut self, expected_label: &str, expected: DiagStyledString, found_label: &str, found: DiagStyledString, expected_extra: DiagStyledString, found_extra: DiagStyledString, ) -> &mut Self

Source

#### pub fn note_trait_signature( &mut self, name: Symbol, signature: String, ) -> &mut Self

Source

#### pub fn note(&mut self, msg: impl Into<DiagMessage>) -> &mut Self

Add a note attached to this diagnostic. See `Diag::note()`.

Source

#### pub fn with_note(self, msg: impl Into<DiagMessage>) -> Self

Add a note attached to this diagnostic. See `Diag::note()`.

Source

#### pub fn highlighted_note(&mut self, msg: Vec<StringPart>) -> &mut Self

Source

#### pub fn highlighted_span_note( &mut self, span: impl Into<MultiSpan>, msg: Vec<StringPart>, ) -> &mut Self

Source

#### pub fn note_once(&mut self, msg: impl Into<DiagMessage>) -> &mut Self

This is like `Diag::note()`, but it’s only printed once.

Source

#### pub fn span_note( &mut self, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>, ) -> &mut Self

Prints the span with a note above it. This is like `Diag::note()`, but it gets its own span. See `Diag::span_note()`.

Source

#### pub fn with_span_note( self, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>, ) -> Self

Prints the span with a note above it. This is like `Diag::note()`, but it gets its own span. See `Diag::span_note()`.

Source

#### pub fn span_note_once<S: Into<MultiSpan>>( &mut self, sp: S, msg: impl Into<DiagMessage>, ) -> &mut Self

Prints the span with a note above it. This is like `Diag::note_once()`, but it gets its own span.

Source

#### pub fn warn(&mut self, msg: impl Into<DiagMessage>) -> &mut Self

Add a warning attached to this diagnostic. See `Diag::warn()`.

Source

#### pub fn with_warn(self, msg: impl Into<DiagMessage>) -> Self

Add a warning attached to this diagnostic. See `Diag::warn()`.

Source

#### pub fn span_warn<S: Into<MultiSpan>>( &mut self, sp: S, msg: impl Into<DiagMessage>, ) -> &mut Self

Prints the span with a warning above it. This is like `Diag::warn()`, but it gets its own span.

Source

#### pub fn help(&mut self, msg: impl Into<DiagMessage>) -> &mut Self

Add a help message attached to this diagnostic. See `Diag::help()`.

Source

#### pub fn with_help(self, msg: impl Into<DiagMessage>) -> Self

Add a help message attached to this diagnostic. See `Diag::help()`.

Source

#### pub fn help_once(&mut self, msg: impl Into<DiagMessage>) -> &mut Self

This is like `Diag::help()`, but it’s only printed once.

Source

#### pub fn highlighted_help(&mut self, msg: Vec<StringPart>) -> &mut Self

Add a help message attached to this diagnostic with a customizable highlighted message.

Source

#### pub fn highlighted_span_help( &mut self, span: impl Into<MultiSpan>, msg: Vec<StringPart>, ) -> &mut Self

Add a help message attached to this diagnostic with a customizable highlighted message.

Source

#### pub fn span_help( &mut self, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>, ) -> &mut Self

Prints the span with some help above it. This is like `Diag::help()`, but it gets its own span. See `Diag::span_help()`.

Source

#### pub fn with_span_help( self, sp: impl Into<MultiSpan>, msg: impl Into<DiagMessage>, ) -> Self

Prints the span with some help above it. This is like `Diag::help()`, but it gets its own span. See `Diag::span_help()`.

Source

#### pub fn disable_suggestions(&mut self) -> &mut Self

Disallow attaching suggestions to this diagnostic. Any suggestions attached e.g. with the `span_suggestion_*` methods (before and after the call to `disable_suggestions`) will be ignored.

Source

#### pub fn seal_suggestions(&mut self) -> &mut Self

Prevent new suggestions from being added to this diagnostic.

Suggestions added before the call to `.seal_suggestions()` will be preserved and new suggestions will be ignored.

Source

#### fn push_suggestion(&mut self, suggestion: CodeSuggestion)

Helper for pushing to `self.suggestions`.

A new suggestion is added if suggestions are enabled for this diagnostic. Otherwise, they are ignored.

Source

#### pub fn multipart_suggestion( &mut self, msg: impl Into<DiagMessage>, suggestion: Vec<(Span, String)>, applicability: Applicability, ) -> &mut Self

Show a suggestion that has multiple parts to it, always as its own subdiagnostic. In other words, multiple changes need to be applied as part of this suggestion. See `Diag::multipart_suggestion()`.

Source

#### pub fn with_multipart_suggestion( self, msg: impl Into<DiagMessage>, suggestion: Vec<(Span, String)>, applicability: Applicability, ) -> Self

Show a suggestion that has multiple parts to it, always as its own subdiagnostic. In other words, multiple changes need to be applied as part of this suggestion. See `Diag::multipart_suggestion()`.

Source

#### pub fn multipart_suggestion_with_style( &mut self, msg: impl Into<DiagMessage>, suggestion: Vec<(Span, String)>, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self

`Diag::multipart_suggestion()` but you can set the `SuggestionStyle`.

Source

#### pub fn tool_only_multipart_suggestion( &mut self, msg: impl Into<DiagMessage>, suggestion: Vec<(Span, String)>, applicability: Applicability, ) -> &mut Self

Prints out a message with for a multipart suggestion without showing the suggested code.

This is intended to be used for suggestions that are obvious in what the changes need to be from the message, showing the span label inline would be visually unpleasant (marginally overlapping spans or multiline spans) and showing the snippet window wouldn’t improve understandability.

Source

#### pub fn span_suggestion( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> &mut Self

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:

    try adding parentheses: `(tup.0).1`

The message

- should not end in any punctuation (a `:` is added automatically)
- should not be a question (avoid language like “did you mean”)
- should not contain any phrases like “the following”, “as shown”, etc.
- 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. See `Diag::span_suggestion()`.

Source

#### pub fn with_span_suggestion( self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> Self

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:

    try adding parentheses: `(tup.0).1`

The message

- should not end in any punctuation (a `:` is added automatically)
- should not be a question (avoid language like “did you mean”)
- should not contain any phrases like “the following”, “as shown”, etc.
- 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. See `Diag::span_suggestion()`.

Source

#### pub fn span_suggestion_with_style( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self

`Diag::span_suggestion()` but you can set the `SuggestionStyle`. See `Diag::span_suggestion_with_style()`.

Source

#### pub fn with_span_suggestion_with_style( self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, style: SuggestionStyle, ) -> Self

`Diag::span_suggestion()` but you can set the `SuggestionStyle`. See `Diag::span_suggestion_with_style()`.

Source

#### pub fn span_suggestion_verbose( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> &mut Self

Always show the suggested change. See `Diag::span_suggestion_verbose()`.

Source

#### pub fn with_span_suggestion_verbose( self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> Self

Always show the suggested change. See `Diag::span_suggestion_verbose()`.

Source

#### pub fn span_suggestions( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestions: impl IntoIterator<Item = String>, applicability: Applicability, ) -> &mut Self

Prints out a message with multiple suggested edits of the code. See also `Diag::span_suggestion()`. See `Diag::span_suggestions()`.

Source

#### pub fn with_span_suggestions( self, sp: Span, msg: impl Into<DiagMessage>, suggestions: impl IntoIterator<Item = String>, applicability: Applicability, ) -> Self

Prints out a message with multiple suggested edits of the code. See also `Diag::span_suggestion()`. See `Diag::span_suggestions()`.

Source

#### pub fn span_suggestions_with_style( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestions: impl IntoIterator<Item = String>, applicability: Applicability, style: SuggestionStyle, ) -> &mut Self

Source

#### pub fn multipart_suggestions( &mut self, msg: impl Into<DiagMessage>, suggestions: impl IntoIterator<Item = Vec<(Span, String)>>, applicability: Applicability, ) -> &mut Self

Prints out a message with multiple suggested edits of the code, where each edit consists of multiple parts. See also `Diag::multipart_suggestion()`.

Source

#### pub fn span_suggestion_short( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> &mut Self

Prints out a message with a suggested edit of the code. If the suggestion is presented inline, it will only show the message and not the suggestion.

See `CodeSuggestion` for more information. See `Diag::span_suggestion_short()`.

Source

#### pub fn with_span_suggestion_short( self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> Self

Prints out a message with a suggested edit of the code. If the suggestion is presented inline, it will only show the message and not the suggestion.

See `CodeSuggestion` for more information. See `Diag::span_suggestion_short()`.

Source

#### pub fn span_suggestion_hidden( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> &mut Self

Prints out a message for a suggestion without showing the suggested code.

This is intended to be used for suggestions that are obvious in what the changes need to be from the message, showing the span label inline would be visually unpleasant (marginally overlapping spans or multiline spans) and showing the snippet window wouldn’t improve understandability.

Source

#### pub fn tool_only_span_suggestion( &mut self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> &mut Self

Adds a suggestion to the JSON output that will not be shown in the CLI.

This is intended to be used for suggestions that are very obvious in what the changes need to be from the message, but we still want other tools to be able to apply them. See `Diag::tool_only_span_suggestion()`.

Source

#### pub fn with_tool_only_span_suggestion( self, sp: Span, msg: impl Into<DiagMessage>, suggestion: impl ToString, applicability: Applicability, ) -> Self

Adds a suggestion to the JSON output that will not be shown in the CLI.

This is intended to be used for suggestions that are very obvious in what the changes need to be from the message, but we still want other tools to be able to apply them. See `Diag::tool_only_span_suggestion()`.

Source

#### pub fn subdiagnostic(&mut self, subdiagnostic: impl Subdiagnostic) -> &mut Self

Add a subdiagnostic from a type that implements `Subdiagnostic` (see rustc_macros::Subdiagnostic). Performs eager formatting of any messages used in the subdiagnostic, so suitable for use with repeated messages (i.e. re-use of interpolated variables).

Source

#### pub fn span(&mut self, sp: impl Into<MultiSpan>) -> &mut Self

Add a span. See `Diag::span()`.

Source

#### pub fn with_span(self, sp: impl Into<MultiSpan>) -> Self

Add a span. See `Diag::span()`.

Source

#### pub fn is_lint(&mut self, name: String, has_future_breakage: bool) -> &mut Self

Source

#### pub fn code(&mut self, code: ErrCode) -> &mut Self

Add an error code. See `Diag::code()`.

Source

#### pub fn with_code(self, code: ErrCode) -> Self

Add an error code. See `Diag::code()`.

Source

#### pub fn lint_id(&mut self, id: LintExpectationId) -> &mut Self

Add an argument. See `Diag::lint_id()`.

Source

#### pub fn with_lint_id(self, id: LintExpectationId) -> Self

Add an argument. See `Diag::lint_id()`.

Source

#### pub fn primary_message(&mut self, msg: impl Into<DiagMessage>) -> &mut Self

Add a primary message. See `Diag::primary_message()`.

Source

#### pub fn with_primary_message(self, msg: impl Into<DiagMessage>) -> Self

Add a primary message. See `Diag::primary_message()`.

Source

#### pub fn arg( &mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg, ) -> &mut Self

Add an argument. See `Diag::arg()`.

Source

#### pub fn with_arg( self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg, ) -> Self

Add an argument. See `Diag::arg()`.

Source

#### pub fn sub( &mut self, level: Level, message: impl Into<DiagMessage>, span: MultiSpan, )

Convenience function for internal use, clients should use one of the public methods above.

Used by `proc_macro_server` for implementing `server::Diagnostic`.

Source

#### fn sub_with_highlights( &mut self, level: Level, messages: Vec<StringPart>, span: MultiSpan, )

Convenience function for internal use, clients should use one of the public methods above.

Source

#### fn take_diag(&mut self) -> DiagInner

Takes the diagnostic. For use by methods that consume the Diag: `emit`, `cancel`, etc. Afterwards, `drop` is the only code that will be run on `self`.

Source

#### pub fn long_ty_path(&mut self) -> &mut Option<PathBuf>

This method allows us to access the path of the file where “long types” are written to.

When calling `Diag::emit`, as part of that we will check if a `long_ty_path` has been set, and if it has been then we add a note mentioning the file where the “long types” were written to.

When calling `tcx.short_string()` after a `Diag` is constructed, the preferred way of doing so is `tcx.short_string(ty, diag.long_ty_path())`. The diagnostic itself is the one that keeps the existence of a “long type” anywhere in the diagnostic, so the note telling the user where we wrote the file to is only printed once at most, and it makes it much harder to forget to set it.

If the diagnostic hasn’t been created before a “short ty string” is created, then you should ensure that this method is called to set it `*diag.long_ty_path() = path`.

As a rule of thumb, if you see or add at least one `tcx.short_string()` call anywhere, in a scope, `diag.long_ty_path()` should be called once somewhere close by.

Source

#### pub fn with_long_ty_path(self, long_ty_path: Option<PathBuf>) -> Self

Source

#### fn emit_producing_nothing(self)

Most `emit_producing_guarantee` functions use this as a starting point.

Source

#### fn emit_producing_error_guaranteed(self) -> ErrorGuaranteed

`ErrorGuaranteed::emit_producing_guarantee` uses this.

Source

#### pub fn emit(self) -> G::EmitResult

Emit and consume the diagnostic.

Source

#### pub fn emit_unless_delay(self, delay: bool) -> G::EmitResult

Emit the diagnostic unless `delay` is true, in which case the emission will be delayed as a bug.

See `emit` and `delay_as_bug` for details.

Source

#### pub fn cancel(self)

Cancel and consume the diagnostic. (A diagnostic must either be emitted or cancelled or it will panic when dropped).

Source

#### pub fn cancel_into_message(self) -> Option<String>

Cancels this diagnostic and returns its first message, if it exists.

Source

#### pub fn stash(self, span: Span, key: StashKey) -> Option<ErrorGuaranteed>

See `DiagCtxt::stash_diagnostic` for details.

Source

#### pub fn delay_as_bug(self) -> G::EmitResult

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.

## Methods from Deref<Target = DiagInner>§

Source

#### pub fn level(&self) -> Level

Source

#### pub fn is_error(&self) -> bool

Source

#### pub(crate) fn has_future_breakage(&self) -> bool

Indicates whether this diagnostic should show up in cargo’s future breakage report.

Source

#### pub(crate) fn is_force_warn(&self) -> bool

Source

#### pub(crate) fn sub( &mut self, level: Level, message: impl Into<DiagMessage>, span: MultiSpan, )

Source

#### pub(crate) fn arg( &mut self, name: impl Into<DiagArgName>, arg: impl IntoDiagArg, )

Source

#### pub fn remove_arg(&mut self, name: &str)

Source

#### pub fn emitted_at_sub_diag(&self) -> Subdiag

Source

#### fn keys( &self, ) -> (&Level, &[(DiagMessage, Style)], &Option<ErrCode>, &MultiSpan, &[Subdiag], &Suggestions, Vec<(&DiagArgName, &DiagArgValue)>, &Option<IsLint>)

Fields used for Hash, and PartialEq trait.

## Trait Implementations§

Source§

### impl<G> !Clone for Diag<'_, G>

Source§

### impl<G: EmissionGuarantee> Debug for Diag<'_, G>

Source§

#### fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

### impl<G: EmissionGuarantee> Deref for Diag<'_, G>

Source§

#### type Target = DiagInner

The resulting type after dereferencing.
Source§

#### fn deref(&self) -> &DiagInner

Dereferences the value.
Source§

### impl<G: EmissionGuarantee> DerefMut for Diag<'_, G>

Source§

#### fn deref_mut(&mut self) -> &mut DiagInner

Mutably dereferences the value.
Source§

### impl<G: EmissionGuarantee> Drop for Diag<'_, G>

Destructor bomb: every `Diag` must be consumed (emitted, cancelled, etc.) or we emit a bug.

Source§

#### fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

#### fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (`pin_ergonomics`)
Execute the destructor for this type, but different to `Drop::drop`, it requires `self` to be pinned. Read more

## Auto Trait Implementations§

§

### impl<'a, G = ErrorGuaranteed> !DynSend for Diag<'a, G>

§

### impl<'a, G = ErrorGuaranteed> !DynSync for Diag<'a, G>

§

### impl<'a, G = ErrorGuaranteed> !RefUnwindSafe for Diag<'a, G>

§

### impl<'a, G = ErrorGuaranteed> !Send for Diag<'a, G>

§

### impl<'a, G = ErrorGuaranteed> !Sync for Diag<'a, G>

§

### impl<'a, G = ErrorGuaranteed> !UnwindSafe for Diag<'a, G>

§

### impl<'a, G> Freeze for Diag<'a, G>

§

### impl<'a, G> Unpin for Diag<'a, G>
where G: Unpin,

§

### impl<'a, G> UnsafeUnpin for Diag<'a, G>

## Blanket Implementations§

Source§

### impl<T> Aligned for T

Source§

#### const ALIGN: Alignment

Alignment of `Self`.
Source§

### impl<T> Any for T
where T: 'static + ?Sized,

Source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
Source§

### impl<T> Borrow<T> for T
where T: ?Sized,

Source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

### impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

### impl<T> ErasedDestructor for T
where T: 'static,

Source§

### impl<T> From<T> for T

Source§

#### fn from(t: T) -> T

Returns the argument unchanged.

Source§

### impl<T> Instrument for T

Source§

#### fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided `Span`, returning an `Instrumented` wrapper. Read more
Source§

#### fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current `Span`, returning an `Instrumented` wrapper. Read more
Source§

### impl<T, U> Into<U> for T
where U: From<T>,

Source§

#### fn into(self) -> U

Calls `U::from(self)`.

That is, this conversion is whatever the implementation of `From<T> for U` chooses to do.

Source§

### impl<T> IntoEither for T

Source§

#### fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

#### fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

### impl<T> Pointable for T

Source§

#### const ALIGN: usize

The alignment of pointer.
Source§

#### type Init = T

The type for initializers.
Source§

#### unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

#### unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

#### unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

#### unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

### impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

#### type Target = T

🔬This is a nightly-only experimental API. (`arbitrary_self_types`)
The target type on which the method may be called.
Source§

### impl<T> Same for T

Source§

#### type Output = T

Should always be `Self`
Source§

### impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

#### type Error = Infallible

The type returned in the event of a conversion error.
Source§

#### fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

### impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

#### fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

### impl<T> WithSubscriber for T

Source§

#### fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more
Source§

#### fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more

## Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain `repr(...)` attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 24 bytes