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,
impl<'a, 'f, 'sess: 'f, S> AttributeDiagnosticContext<'a, 'f, 'sess, S>where
S: Stage,
fn emit_parse_error( &mut self, span: Span, reason: AttributeParseErrorReason<'_>, ) -> ErrorGuaranteed
Sourcepub(crate) fn push_suggestion(
&mut self,
msg: String,
span: Span,
code: String,
) -> &mut Self
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.
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.
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.
pub(crate) fn expected_integer_literal_in_range( &mut self, span: Span, lower_bound: isize, upper_bound: isize, ) -> ErrorGuaranteed
Sourcepub(crate) fn expected_list(
&mut self,
span: Span,
args: &ArgParser,
) -> ErrorGuaranteed
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.
pub(crate) fn expected_list_with_num_args_or_more( &mut self, args: usize, span: Span, ) -> ErrorGuaranteed
pub(crate) fn expected_list_or_no_args(&mut self, span: Span) -> ErrorGuaranteed
pub(crate) fn expected_nv_or_no_args(&mut self, span: Span) -> ErrorGuaranteed
pub(crate) fn expected_non_empty_string_literal( &mut self, span: Span, ) -> ErrorGuaranteed
pub(crate) fn expected_no_args(&mut self, span: Span) -> ErrorGuaranteed
Sourcepub(crate) fn expected_identifier(&mut self, span: Span) -> ErrorGuaranteed
pub(crate) fn expected_identifier(&mut self, span: Span) -> ErrorGuaranteed
Emit an error that a name was expected here
Sourcepub(crate) fn expected_name_value(
&mut self,
span: Span,
name: Option<Symbol>,
) -> ErrorGuaranteed
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.
Sourcepub(crate) fn missing_name_value(
&mut self,
span: Span,
name: Symbol,
) -> ErrorGuaranteed
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.
Sourcepub(crate) fn duplicate_key(
&mut self,
span: Span,
key: Symbol,
) -> ErrorGuaranteed
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.
Sourcepub(crate) fn expected_not_literal(&mut self, span: Span) -> ErrorGuaranteed
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.
Sourcepub(crate) fn expected_single_argument(
&mut self,
span: Span,
provided_arguments: usize,
) -> ErrorGuaranteed
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).
pub(crate) fn expected_at_least_one_argument( &mut self, span: Span, ) -> ErrorGuaranteed
Sourcepub(crate) fn expected_specific_argument(
&mut self,
span: Span,
possibilities: &[Symbol],
) -> ErrorGuaranteed
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]
Sourcepub(crate) fn expected_specific_argument_and_list(
&mut self,
span: Span,
possibilities: &[Symbol],
) -> ErrorGuaranteed
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.
Sourcepub(crate) fn expected_specific_argument_strings(
&mut self,
span: Span,
possibilities: &[Symbol],
) -> ErrorGuaranteed
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"]
pub(crate) fn warn_empty_attribute(&mut self, span: Span)
pub(crate) fn warn_ill_formed_attribute_input(&mut self, lint: &'static Lint)
pub(crate) fn warn_ill_formed_attribute_input_with_help( &mut self, lint: &'static Lint, help: Option<String>, )
pub(crate) fn suggestions(&self) -> Vec<String>
Sourcepub(crate) fn expected_string_literal(
&mut self,
span: Span,
actual_literal: Option<&MetaItemLit>,
) -> ErrorGuaranteed
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.
Sourcepub(crate) fn expected_filename_literal(&mut self, span: Span)
pub(crate) fn expected_filename_literal(&mut self, span: Span)
Error that a filename string literal was expected.
pub(crate) fn expected_integer_literal(&mut self, span: Span) -> ErrorGuaranteed
Methods from Deref<Target = AcceptContext<'f, 'sess, S>>§
pub(crate) fn parse_limit_int(&mut self, nv: &NameValueParser) -> Option<Limit>
pub(crate) fn adcx(&mut self) -> AttributeDiagnosticContext<'_, 'f, 'sess, S>
Sourcepub(crate) fn single_element_list<'arg>(
&mut self,
arg: &'arg ArgParser,
span: Span,
) -> Option<&'arg MetaItemOrLitParser>
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)],warningsis returned - In
#[cfg_attr(docsrs, doc = "foo")],Noneis returned, “expected a single argument here” is emitted. - In
#[cfg()],Noneis 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>>§
Methods from Deref<Target = AttributeParser<'sess, S>>§
pub(crate) fn sess(&self) -> &'sess Session
pub(crate) fn features(&self) -> &'sess Features
pub(crate) fn features_option(&self) -> Option<&'sess Features>
pub(crate) fn dcx(&self) -> DiagCtxtHandle<'sess>
Sourcepub 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>
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.
fn lower_attr_args( &self, args: &AttrArgs, lower_span: impl Fn(Span) -> Span, ) -> AttrArgs
pub fn check_attribute_safety( &mut self, attr_path: &AttrPath, attr_span: Span, attr_safety: Safety, emit_lint: &mut impl FnMut(LintId, MultiSpan, AttributeLintKind), )
pub(crate) fn check_invalid_crate_level_attr_item( &self, attr: &AttrItem, inner_span: Span, )
fn first_line_of_next_item(&self, span: Span) -> Option<Span>
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,
impl<'a, 'f, 'sess: 'f, S> Deref for AttributeDiagnosticContext<'a, 'f, 'sess, S>where
S: Stage,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
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