Skip to main content

AttributeDiagnosticContext

Struct AttributeDiagnosticContext 

Source
pub(crate) struct AttributeDiagnosticContext<'a, 'f, 'sess, S: Stage> {
    ctx: &'a mut AcceptContext<'f, 'sess, S>,
    custom_suggestions: Vec<Suggestion>,
}

Fields§

§ctx: &'a mut AcceptContext<'f, 'sess, S>§custom_suggestions: Vec<Suggestion>

Implementations§

Source§

impl<'a, 'f, 'sess: 'f, S> AttributeDiagnosticContext<'a, 'f, 'sess, S>
where S: Stage,

Source

fn emit_parse_error( &mut self, span: Span, reason: AttributeParseErrorReason<'_>, ) -> ErrorGuaranteed

Source

pub(crate) fn push_suggestion( &mut self, msg: String, span: Span, code: String, ) -> &mut Self

Adds a custom suggestion to the diagnostic. This also prevents the default (template-based) suggestion to be emitted.

Source

pub(crate) fn template_suggestions(&self) -> Vec<String>

Source§

impl<'a, 'f, 'sess: 'f, S> AttributeDiagnosticContext<'a, 'f, 'sess, S>
where S: Stage,

Helpers that can be used to generate errors during attribute parsing.

Source

pub(crate) fn expected_integer_literal_in_range( &mut self, span: Span, lower_bound: isize, upper_bound: isize, ) -> ErrorGuaranteed

Source

pub(crate) fn expected_list( &mut self, span: Span, args: &ArgParser, ) -> ErrorGuaranteed

The provided span is used as a fallback in case args does not contain any. It should be the span of the node that contains args.

Source

pub(crate) fn expected_list_with_num_args_or_more( &mut self, args: usize, span: Span, ) -> ErrorGuaranteed

Source

pub(crate) fn expected_list_or_no_args(&mut self, span: Span) -> ErrorGuaranteed

Source

pub(crate) fn expected_nv_or_no_args(&mut self, span: Span) -> ErrorGuaranteed

Source

pub(crate) fn expected_non_empty_string_literal( &mut self, span: Span, ) -> ErrorGuaranteed

Source

pub(crate) fn expected_no_args(&mut self, span: Span) -> ErrorGuaranteed

Source

pub(crate) fn expected_identifier(&mut self, span: Span) -> ErrorGuaranteed

Emit an error that a name was expected here

Source

pub(crate) fn expected_name_value( &mut self, span: Span, name: Option<Symbol>, ) -> ErrorGuaranteed

Emit an error that a name = value pair was expected at this span. The symbol can be given for a nicer error message talking about the specific name that was found lacking a value.

Source

pub(crate) fn missing_name_value( &mut self, span: Span, name: Symbol, ) -> ErrorGuaranteed

Emit an error that a name = value argument is missing in a list of name-value pairs.

Source

pub(crate) fn duplicate_key( &mut self, span: Span, key: Symbol, ) -> ErrorGuaranteed

Emit an error that a name = value pair was found where that name was already seen.

Source

pub(crate) fn expected_not_literal(&mut self, span: Span) -> ErrorGuaranteed

An error that should be emitted when a MetaItemOrLitParser was expected not to be a literal, but instead a meta item.

Source

pub(crate) fn expected_single_argument( &mut self, span: Span, provided_arguments: usize, ) -> ErrorGuaranteed

Signals that we expected exactly one argument and that we got either zero or two or more. The provided_arguments argument allows distinguishing between “expected an argument here” (when zero arguments are provided) and “expect a single argument here” (when two or more arguments are provided).

Source

pub(crate) fn expected_at_least_one_argument( &mut self, span: Span, ) -> ErrorGuaranteed

Source

pub(crate) fn expected_specific_argument( &mut self, span: Span, possibilities: &[Symbol], ) -> ErrorGuaranteed

Produces an error along the lines of expected one of [foo, meow]

Source

pub(crate) fn expected_specific_argument_and_list( &mut self, span: Span, possibilities: &[Symbol], ) -> ErrorGuaranteed

Produces an error along the lines of expected one of [foo, meow] as an argument. i.e. slightly different wording to expected_specific_argument.

Source

pub(crate) fn expected_specific_argument_strings( &mut self, span: Span, possibilities: &[Symbol], ) -> ErrorGuaranteed

produces an error along the lines of expected one of ["foo", "meow"]

Source

pub(crate) fn warn_empty_attribute(&mut self, span: Span)

Source

pub(crate) fn warn_ill_formed_attribute_input(&mut self, lint: &'static Lint)

Source

pub(crate) fn warn_ill_formed_attribute_input_with_help( &mut self, lint: &'static Lint, help: Option<String>, )

Source

pub(crate) fn suggestions(&self) -> Vec<String>

Source

pub(crate) fn expected_string_literal( &mut self, span: Span, actual_literal: Option<&MetaItemLit>, ) -> ErrorGuaranteed

Error that a string literal was expected. You can optionally give the literal you did find (which you found not to be a string literal) which can make better errors. For example, if the literal was a byte string it will suggest removing the b prefix.

Source

pub(crate) fn expected_filename_literal(&mut self, span: Span)

Error that a filename string literal was expected.

Source

pub(crate) fn expected_integer_literal(&mut self, span: Span) -> ErrorGuaranteed

Methods from Deref<Target = AcceptContext<'f, 'sess, S>>§

Source

pub(crate) fn parse_limit_int(&mut self, nv: &NameValueParser) -> Option<Limit>

Source

pub(crate) fn adcx(&mut self) -> AttributeDiagnosticContext<'_, 'f, 'sess, S>

Source

pub(crate) fn single_element_list<'arg>( &mut self, arg: &'arg ArgParser, span: Span, ) -> Option<&'arg MetaItemOrLitParser>

Asserts that this MetaItem is a list that contains a single element. Emits an error and returns None if it is not the case.

Some examples:

  • In #[allow(warnings)], warnings is returned
  • In #[cfg_attr(docsrs, doc = "foo")], None is returned, “expected a single argument here” is emitted.
  • In #[cfg()], None is returned, “expected an argument here” is emitted.

The provided span is used as a fallback for diagnostic generation in case arg does not contain any. It should be the span of the node that contains arg.

Methods from Deref<Target = SharedContext<'f, 'sess, S>>§

Source

pub(crate) fn emit_err( &self, diag: impl for<'x> Diagnostic<'x>, ) -> ErrorGuaranteed

Source

pub(crate) fn emit_lint<M: Into<MultiSpan>>( &mut self, lint: &'static Lint, kind: AttributeLintKind, span: M, )

Emit a lint. This method is somewhat special, since lints emitted during attribute parsing must be delayed until after HIR is built. This method will take care of the details of that.

Source

pub(crate) fn warn_unused_duplicate( &mut self, used_span: Span, unused_span: Span, )

Source

pub(crate) fn warn_unused_duplicate_future_error( &mut self, used_span: Span, unused_span: Span, )

Methods from Deref<Target = AttributeParser<'sess, S>>§

Source

pub(crate) fn sess(&self) -> &'sess Session

Source

pub(crate) fn features(&self) -> &'sess Features

Source

pub(crate) fn features_option(&self) -> Option<&'sess Features>

Source

pub(crate) fn dcx(&self) -> DiagCtxtHandle<'sess>

Source

pub fn parse_attribute_list( &mut self, attrs: &[Attribute], target_span: Span, target: Target, omit_doc: OmitDoc, lower_span: impl Copy + Fn(Span) -> Span, emit_lint: impl FnMut(LintId, MultiSpan, AttributeLintKind), ) -> Vec<Attribute>

Parse a list of attributes.

target_span is the span of the thing this list of attributes is applied to, and when omit_doc is set, doc attributes are filtered out.

Source

fn lower_attr_args( &self, args: &AttrArgs, lower_span: impl Fn(Span) -> Span, ) -> AttrArgs

Source

pub fn check_attribute_safety( &mut self, attr_path: &AttrPath, attr_span: Span, attr_safety: Safety, emit_lint: &mut impl FnMut(LintId, MultiSpan, AttributeLintKind), )

Source

pub(crate) fn check_invalid_crate_level_attr_item( &self, attr: &AttrItem, inner_span: Span, )

Source

fn first_line_of_next_item(&self, span: Span) -> Option<Span>

Source

pub(crate) fn check_invalid_where_predicate_attrs<'attr>( &self, attrs: impl IntoIterator<Item = &'attr Attribute>, )

Trait Implementations§

Source§

impl<'a, 'f, 'sess: 'f, S> Deref for AttributeDiagnosticContext<'a, 'f, 'sess, S>
where S: Stage,

Source§

type Target = AcceptContext<'f, 'sess, S>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, 'f, 'sess: 'f, S> DerefMut for AttributeDiagnosticContext<'a, 'f, 'sess, S>
where S: Stage,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, 'f, 'sess, S> !DynSend for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> !DynSync for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> Freeze for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> !RefUnwindSafe for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> !Send for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> !Sync for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> Unpin for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> UnsafeUnpin for AttributeDiagnosticContext<'a, 'f, 'sess, S>

§

impl<'a, 'f, 'sess, S> !UnwindSafe for AttributeDiagnosticContext<'a, 'f, 'sess, S>

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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

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

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: 32 bytes