mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Rename diagnostic derive things.
For increased consistency. - session_diagnostic_derive -> diagnostic_derive - session_subdiagnostic_derive -> subdiagnostic_derive - SubdiagnosticDeriveBuilder -> SubdiagnosticDerive
This commit is contained in:
parent
e9f0d9be0e
commit
43c06335cf
@ -352,8 +352,7 @@ declare_tool_lint! {
|
|||||||
declare_tool_lint! {
|
declare_tool_lint! {
|
||||||
/// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with
|
/// The `diagnostic_outside_of_impl` lint detects calls to functions annotated with
|
||||||
/// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or
|
/// `#[rustc_lint_diagnostics]` that are outside an `Diagnostic`, `Subdiagnostic`, or
|
||||||
/// `LintDiagnostic` impl, or a `#[derive(Diagnostic)]`, `#[derive(Subdiagnostic)]`,
|
/// `LintDiagnostic` impl (either hand-written or derived).
|
||||||
/// `#[derive(LintDiagnostic)]` expansion.
|
|
||||||
///
|
///
|
||||||
/// More details on diagnostics implementations can be found
|
/// More details on diagnostics implementations can be found
|
||||||
/// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html).
|
/// [here](https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html).
|
||||||
|
@ -6,7 +6,7 @@ mod utils;
|
|||||||
|
|
||||||
use diagnostic::{DiagnosticDerive, LintDiagnosticDerive};
|
use diagnostic::{DiagnosticDerive, LintDiagnosticDerive};
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use subdiagnostic::SubdiagnosticDeriveBuilder;
|
use subdiagnostic::SubdiagnosticDerive;
|
||||||
use synstructure::Structure;
|
use synstructure::Structure;
|
||||||
|
|
||||||
/// Implements `#[derive(Diagnostic)]`, which allows for errors to be specified as a struct,
|
/// Implements `#[derive(Diagnostic)]`, which allows for errors to be specified as a struct,
|
||||||
@ -55,7 +55,7 @@ use synstructure::Structure;
|
|||||||
///
|
///
|
||||||
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
|
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
|
||||||
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
|
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
|
||||||
pub fn session_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||||
s.underscore_const(true);
|
s.underscore_const(true);
|
||||||
DiagnosticDerive::new(s).into_tokens()
|
DiagnosticDerive::new(s).into_tokens()
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
|||||||
///
|
///
|
||||||
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
|
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
|
||||||
/// ```
|
/// ```
|
||||||
pub fn session_subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
pub fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
|
||||||
s.underscore_const(true);
|
s.underscore_const(true);
|
||||||
SubdiagnosticDeriveBuilder::new().into_tokens(s)
|
SubdiagnosticDerive::new().into_tokens(s)
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ use synstructure::{BindingInfo, Structure, VariantInfo};
|
|||||||
use super::utils::SubdiagnosticVariant;
|
use super::utils::SubdiagnosticVariant;
|
||||||
|
|
||||||
/// The central struct for constructing the `add_to_diag` method from an annotated struct.
|
/// The central struct for constructing the `add_to_diag` method from an annotated struct.
|
||||||
pub(crate) struct SubdiagnosticDeriveBuilder {
|
pub(crate) struct SubdiagnosticDerive {
|
||||||
diag: syn::Ident,
|
diag: syn::Ident,
|
||||||
f: syn::Ident,
|
f: syn::Ident,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SubdiagnosticDeriveBuilder {
|
impl SubdiagnosticDerive {
|
||||||
pub(crate) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
let diag = format_ident!("diag");
|
let diag = format_ident!("diag");
|
||||||
let f = format_ident!("f");
|
let f = format_ident!("f");
|
||||||
@ -109,7 +109,7 @@ impl SubdiagnosticDeriveBuilder {
|
|||||||
/// double mut borrow later on.
|
/// double mut borrow later on.
|
||||||
struct SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
struct SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
|
||||||
/// The identifier to use for the generated `Diag` instance.
|
/// The identifier to use for the generated `Diag` instance.
|
||||||
parent: &'parent SubdiagnosticDeriveBuilder,
|
parent: &'parent SubdiagnosticDerive,
|
||||||
|
|
||||||
/// Info for the current variant (or the type if not an enum).
|
/// Info for the current variant (or the type if not an enum).
|
||||||
variant: &'a VariantInfo<'a>,
|
variant: &'a VariantInfo<'a>,
|
||||||
|
@ -118,7 +118,7 @@ decl_derive!(
|
|||||||
suggestion,
|
suggestion,
|
||||||
suggestion_short,
|
suggestion_short,
|
||||||
suggestion_hidden,
|
suggestion_hidden,
|
||||||
suggestion_verbose)] => diagnostics::session_diagnostic_derive
|
suggestion_verbose)] => diagnostics::diagnostic_derive
|
||||||
);
|
);
|
||||||
decl_derive!(
|
decl_derive!(
|
||||||
[LintDiagnostic, attributes(
|
[LintDiagnostic, attributes(
|
||||||
@ -156,5 +156,5 @@ decl_derive!(
|
|||||||
skip_arg,
|
skip_arg,
|
||||||
primary_span,
|
primary_span,
|
||||||
suggestion_part,
|
suggestion_part,
|
||||||
applicability)] => diagnostics::session_subdiagnostic_derive
|
applicability)] => diagnostics::subdiagnostic_derive
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user