Skip to main content

Module utils

Module utils 

Source

Re-exportsΒ§

use std::cell::RefCell; πŸ”’
use std::collections::BTreeSet; πŸ”’
use std::collections::HashSet; πŸ”’
use std::fmt; πŸ”’
use std::str::FromStr; πŸ”’
use indexmap::IndexMap; πŸ”’
use proc_macro::Span; πŸ”’
use proc_macro2::Ident; πŸ”’
use proc_macro2::TokenStream; πŸ”’
use quote::ToTokens; πŸ”’
use quote::format_ident; πŸ”’
use quote::quote; πŸ”’
use syn::parse::ParseStream; πŸ”’
use syn::punctuated::Punctuated; πŸ”’
use syn::spanned::Spanned; πŸ”’
use syn::Attribute; πŸ”’
use syn::Field; πŸ”’
use syn::LitStr; πŸ”’
use syn::Meta; πŸ”’
use syn::Path; πŸ”’
use syn::Token; πŸ”’
use syn::Type; πŸ”’
use syn::TypeTuple; πŸ”’
use syn::parenthesized; πŸ”’
use synstructure::BindingInfo; πŸ”’
use synstructure::VariantInfo; πŸ”’
use super::error::invalid_attr; πŸ”’
use crate::diagnostics::error::DiagnosticDeriveError; πŸ”’
use crate::diagnostics::error::span_err; πŸ”’
use crate::diagnostics::error::throw_invalid_attr; πŸ”’
use crate::diagnostics::error::throw_span_err; πŸ”’
use crate::diagnostics::message::Message; πŸ”’

StructsΒ§

FieldInfo πŸ”’
Field information passed to the builder. Deliberately omits attrs to discourage the generate_* methods from walking the attributes themselves.
SubdiagnosticVariant πŸ”’

EnumsΒ§

AllowMultipleAlternatives πŸ”’
Applicability πŸ”’
Applicability of a suggestion - mirrors rustc_errors::Applicability - and used to represent the user’s selection of applicability if specified in an attribute.
FieldInnerTy πŸ”’
Inner type of a field and type of wrapper.
SubdiagnosticKind πŸ”’
Types of subdiagnostics that can be created using attributes
SuggestionKind πŸ”’
Possible styles for suggestion subdiagnostics.

ConstantsΒ§

CODE_IDENT_COUNT πŸ”’

TraitsΒ§

SetOnce πŸ”’
Small helper trait for abstracting over Option fields that contain a value and a Span for error reporting if they are set more than once.

FunctionsΒ§

build_field_mapping πŸ”’
Build the mapping of field names to fields. This allows attributes to peek values from other fields.
build_format πŸ”’
In the strings in the attributes supplied to this macro, we want callers to be able to reference fields in the format string. For example:
build_suggestion_code πŸ”’
Constructs the format!() invocation(s) necessary for a #[suggestion*(code = "foo")] or #[suggestion*(code("foo", "bar"))] attribute field
is_doc_comment πŸ”’
new_code_ident πŸ”’
Returns an ident of the form __code_N where N is incremented once with every call.
parse_suggestion_values πŸ”’
report_error_if_not_applied_to_applicability πŸ”’
Reports an error if the field’s type is not Applicability.
report_error_if_not_applied_to_span πŸ”’
Reports an error if the field’s type is not Span.
report_error_if_not_applied_to_ty πŸ”’
Reports an error if the field’s type does not match path.
report_type_error πŸ”’
Reports a type error for field with attr.
should_generate_arg πŸ”’
Returns true if field should generate a arg call rather than any other diagnostic call (like span_label).
type_is_bool πŸ”’
Checks whether the type ty is bool.
type_is_unit πŸ”’
Checks whether the type ty is ().
type_matches_path πŸ”’
Checks whether the type name of ty matches name.

Type AliasesΒ§

FieldMap πŸ”’
SpannedOption πŸ”’
An Option<T> that keeps track of the span that caused it to be set; used with SetOnce.