pub trait DiagnosticExt<T: LintContext> {
    // Required methods
    fn suggest_item_with_attr<D: Display + ?Sized>(
        &mut self,
        cx: &T,
        item: Span,
        msg: &str,
        attr: &D,
        applicability: Applicability
    );
    fn suggest_prepend_item(
        &mut self,
        cx: &T,
        item: Span,
        msg: &str,
        new_item: &str,
        applicability: Applicability
    );
    fn suggest_remove_item(
        &mut self,
        cx: &T,
        item: Span,
        msg: &str,
        applicability: Applicability
    );
}
Expand description

Convenience extension trait for Diagnostic.

Required Methods§

source

fn suggest_item_with_attr<D: Display + ?Sized>( &mut self, cx: &T, item: Span, msg: &str, attr: &D, applicability: Applicability )

Suggests to add an attribute to an item.

Correctly handles indentation of the attribute and item.

Example
diag.suggest_item_with_attr(cx, item, "#[derive(Default)]");
source

fn suggest_prepend_item( &mut self, cx: &T, item: Span, msg: &str, new_item: &str, applicability: Applicability )

Suggest to add an item before another.

The item should not be indented (except for inner indentation).

Example
diag.suggest_prepend_item(cx, item,
"fn foo() {
    bar();
}");
source

fn suggest_remove_item( &mut self, cx: &T, item: Span, msg: &str, applicability: Applicability )

Suggest to completely remove an item.

This will remove an item and all following whitespace until the next non-whitespace character. This should work correctly if item is on the same indentation level as the following item.

Example
diag.suggest_remove_item(cx, item, "remove this")

Implementations on Foreign Types§

source§

impl<T: LintContext> DiagnosticExt<T> for Diagnostic

source§

fn suggest_item_with_attr<D: Display + ?Sized>( &mut self, cx: &T, item: Span, msg: &str, attr: &D, applicability: Applicability )

source§

fn suggest_prepend_item( &mut self, cx: &T, item: Span, msg: &str, new_item: &str, applicability: Applicability )

source§

fn suggest_remove_item( &mut self, cx: &T, item: Span, msg: &str, applicability: Applicability )

Implementors§