FIX - adopt new Diagnostic naming in newly migrated modules
FIX - ambiguous Diagnostic link in docs UPDATE - rename diagnostic_items to IntoDiagnostic and AddToDiagnostic [Gardening] FIX - formatting via `x fmt` FIX - rebase conflicts. NOTE: Confirm wheather or not we want to handle TargetDataLayoutErrorsWrapper this way DELETE - unneeded allow attributes in Handler method FIX - broken test FIX - Rebase conflict UPDATE - rename residual _SessionDiagnostic and fix LintDiag link
This commit is contained in:
parent
5f91719f75
commit
e52e2344dc
28 changed files with 88 additions and 127 deletions
|
@ -335,7 +335,7 @@ pub struct InclusiveRangeWithNoEnd {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic, Clone, Copy)]
|
#[derive(Diagnostic, Clone, Copy)]
|
||||||
#[diag(ast_lowering::trait_fn_async, code = "E0706")]
|
#[diag(ast_lowering::trait_fn_async, code = "E0706")]
|
||||||
#[note]
|
#[note]
|
||||||
#[note(ast_lowering::note2)]
|
#[note(ast_lowering::note2)]
|
||||||
|
|
|
@ -2,8 +2,7 @@ use std::num::IntErrorKind;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, fluent, Applicability, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed,
|
error_code, fluent, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic,
|
||||||
Handler,
|
|
||||||
};
|
};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
|
|
@ -178,7 +178,7 @@ impl IntoDiagnosticArg for hir::ConstContext {
|
||||||
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
||||||
/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
|
/// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic].
|
||||||
#[cfg_attr(bootstrap, rustc_diagnostic_item = "AddSubdiagnostic")]
|
#[cfg_attr(bootstrap, rustc_diagnostic_item = "AddSubdiagnostic")]
|
||||||
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "Subdiagnostic")]
|
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "AddToDiagnostic")]
|
||||||
pub trait AddToDiagnostic {
|
pub trait AddToDiagnostic {
|
||||||
/// Add a subdiagnostic to an existing diagnostic.
|
/// Add a subdiagnostic to an existing diagnostic.
|
||||||
fn add_to_diagnostic(self, diag: &mut Diagnostic);
|
fn add_to_diagnostic(self, diag: &mut Diagnostic);
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::thread::panicking;
|
||||||
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
/// Trait implemented by error types. This should not be implemented manually. Instead, use
|
||||||
/// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic].
|
/// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic].
|
||||||
#[cfg_attr(bootstrap, rustc_diagnostic_item = "SessionDiagnostic")]
|
#[cfg_attr(bootstrap, rustc_diagnostic_item = "SessionDiagnostic")]
|
||||||
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "Diagnostic")]
|
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "IntoDiagnostic")]
|
||||||
pub trait IntoDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
|
pub trait IntoDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
|
||||||
/// Write out as a diagnostic out of `Handler`.
|
/// Write out as a diagnostic out of `Handler`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|
|
@ -437,11 +437,11 @@ struct HandlerInner {
|
||||||
/// have been converted.
|
/// have been converted.
|
||||||
check_unstable_expect_diagnostics: bool,
|
check_unstable_expect_diagnostics: bool,
|
||||||
|
|
||||||
/// Expected [`Diagnostic`]s store a [`LintExpectationId`] as part of
|
/// Expected [`Diagnostic`][diagnostic::Diagnostic]s store a [`LintExpectationId`] as part of
|
||||||
/// the lint level. [`LintExpectationId`]s created early during the compilation
|
/// the lint level. [`LintExpectationId`]s created early during the compilation
|
||||||
/// (before `HirId`s have been defined) are not stable and can therefore not be
|
/// (before `HirId`s have been defined) are not stable and can therefore not be
|
||||||
/// stored on disk. This buffer stores these diagnostics until the ID has been
|
/// stored on disk. This buffer stores these diagnostics until the ID has been
|
||||||
/// replaced by a stable [`LintExpectationId`]. The [`Diagnostic`]s are the
|
/// replaced by a stable [`LintExpectationId`]. The [`Diagnostic`][diagnostic::Diagnostic]s are the
|
||||||
/// submitted for storage and added to the list of fulfilled expectations.
|
/// submitted for storage and added to the list of fulfilled expectations.
|
||||||
unstable_expect_diagnostics: Vec<Diagnostic>,
|
unstable_expect_diagnostics: Vec<Diagnostic>,
|
||||||
|
|
||||||
|
@ -647,8 +647,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder with the `msg` at the level appropriate for the specific `EmissionGuarantee`.
|
/// Construct a builder with the `msg` at the level appropriate for the specific `EmissionGuarantee`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_diagnostic<G: EmissionGuarantee>(
|
pub fn struct_diagnostic<G: EmissionGuarantee>(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -662,8 +660,6 @@ impl Handler {
|
||||||
/// * `can_emit_warnings` is `true`
|
/// * `can_emit_warnings` is `true`
|
||||||
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_warn(
|
pub fn struct_span_warn(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -680,8 +676,6 @@ impl Handler {
|
||||||
/// Attempting to `.emit()` the builder will only emit if either:
|
/// Attempting to `.emit()` the builder will only emit if either:
|
||||||
/// * `can_emit_warnings` is `true`
|
/// * `can_emit_warnings` is `true`
|
||||||
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_warn_with_expectation(
|
pub fn struct_span_warn_with_expectation(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -695,8 +689,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Allow` level at the given `span` and with the `msg`.
|
/// Construct a builder at the `Allow` level at the given `span` and with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_allow(
|
pub fn struct_span_allow(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -710,8 +702,6 @@ impl Handler {
|
||||||
/// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
|
/// Construct a builder at the `Warning` level at the given `span` and with the `msg`.
|
||||||
/// Also include a code.
|
/// Also include a code.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_warn_with_code(
|
pub fn struct_span_warn_with_code(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -729,8 +719,6 @@ impl Handler {
|
||||||
/// * `can_emit_warnings` is `true`
|
/// * `can_emit_warnings` is `true`
|
||||||
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||||
DiagnosticBuilder::new(self, Level::Warning(None), msg)
|
DiagnosticBuilder::new(self, Level::Warning(None), msg)
|
||||||
}
|
}
|
||||||
|
@ -741,8 +729,6 @@ impl Handler {
|
||||||
/// Attempting to `.emit()` the builder will only emit if either:
|
/// Attempting to `.emit()` the builder will only emit if either:
|
||||||
/// * `can_emit_warnings` is `true`
|
/// * `can_emit_warnings` is `true`
|
||||||
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
/// * `is_force_warn` was set in `DiagnosticId::Lint`
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_warn_with_expectation(
|
pub fn struct_warn_with_expectation(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -753,16 +739,12 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Allow` level with the `msg`.
|
/// Construct a builder at the `Allow` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||||
DiagnosticBuilder::new(self, Level::Allow, msg)
|
DiagnosticBuilder::new(self, Level::Allow, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Expect` level with the `msg`.
|
/// Construct a builder at the `Expect` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_expect(
|
pub fn struct_expect(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -773,8 +755,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Error` level at the given `span` and with the `msg`.
|
/// Construct a builder at the `Error` level at the given `span` and with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_err(
|
pub fn struct_span_err(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -787,8 +767,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Error` level at the given `span`, with the `msg`, and `code`.
|
/// Construct a builder at the `Error` level at the given `span`, with the `msg`, and `code`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_err_with_code(
|
pub fn struct_span_err_with_code(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -803,8 +781,6 @@ impl Handler {
|
||||||
/// Construct a builder at the `Error` level with the `msg`.
|
/// Construct a builder at the `Error` level with the `msg`.
|
||||||
// FIXME: This method should be removed (every error should have an associated error code).
|
// FIXME: This method should be removed (every error should have an associated error code).
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_err(
|
pub fn struct_err(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -814,16 +790,12 @@ impl Handler {
|
||||||
|
|
||||||
/// This should only be used by `rustc_middle::lint::struct_lint_level`. Do not use it for hard errors.
|
/// This should only be used by `rustc_middle::lint::struct_lint_level`. Do not use it for hard errors.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_err_lint(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
pub fn struct_err_lint(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||||
DiagnosticBuilder::new(self, Level::Error { lint: true }, msg)
|
DiagnosticBuilder::new(self, Level::Error { lint: true }, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Error` level with the `msg` and the `code`.
|
/// Construct a builder at the `Error` level with the `msg` and the `code`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_err_with_code(
|
pub fn struct_err_with_code(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -836,8 +808,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Warn` level with the `msg` and the `code`.
|
/// Construct a builder at the `Warn` level with the `msg` and the `code`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_warn_with_code(
|
pub fn struct_warn_with_code(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
@ -850,8 +820,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
|
/// Construct a builder at the `Fatal` level at the given `span` and with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_fatal(
|
pub fn struct_span_fatal(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -864,8 +832,6 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Fatal` level at the given `span`, with the `msg`, and `code`.
|
/// Construct a builder at the `Fatal` level at the given `span`, with the `msg`, and `code`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_span_fatal_with_code(
|
pub fn struct_span_fatal_with_code(
|
||||||
&self,
|
&self,
|
||||||
span: impl Into<MultiSpan>,
|
span: impl Into<MultiSpan>,
|
||||||
|
@ -879,24 +845,18 @@ impl Handler {
|
||||||
|
|
||||||
/// Construct a builder at the `Error` level with the `msg`.
|
/// Construct a builder at the `Error` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
||||||
DiagnosticBuilder::new_fatal(self, msg)
|
DiagnosticBuilder::new_fatal(self, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Help` level with the `msg`.
|
/// Construct a builder at the `Help` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_help(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
pub fn struct_help(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||||
DiagnosticBuilder::new(self, Level::Help, msg)
|
DiagnosticBuilder::new(self, Level::Help, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct a builder at the `Note` level with the `msg`.
|
/// Construct a builder at the `Note` level with the `msg`.
|
||||||
#[rustc_lint_diagnostics]
|
#[rustc_lint_diagnostics]
|
||||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
|
||||||
#[allow(rustc::untranslatable_diagnostic)]
|
|
||||||
pub fn struct_note_without_error(
|
pub fn struct_note_without_error(
|
||||||
&self,
|
&self,
|
||||||
msg: impl Into<DiagnosticMessage>,
|
msg: impl Into<DiagnosticMessage>,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use rustc_attr::{self as attr, Deprecation, Stability};
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
|
||||||
use rustc_data_structures::sync::{self, Lrc};
|
use rustc_data_structures::sync::{self, Lrc};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Applicability, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed, MultiSpan, PResult,
|
Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, MultiSpan, PResult,
|
||||||
};
|
};
|
||||||
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
|
use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
|
||||||
use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics};
|
use rustc_lint_defs::{BufferedEarlyLint, BuiltinLintDiagnostics};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use hir::GenericParamKind;
|
use hir::GenericParamKind;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
fluent, AddSubdiagnostic, Applicability, DiagnosticMessage, DiagnosticStyledString, MultiSpan,
|
fluent, AddToDiagnostic, Applicability, DiagnosticMessage, DiagnosticStyledString, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::{FnRetTy, Ty};
|
use rustc_hir::{FnRetTy, Ty};
|
||||||
use rustc_macros::SessionDiagnostic;
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
use rustc_middle::ty::{Region, TyCtxt};
|
use rustc_middle::ty::{Region, TyCtxt};
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
use rustc_span::{symbol::Ident, BytePos, Span};
|
use rustc_span::{symbol::Ident, BytePos, Span};
|
||||||
|
@ -16,7 +16,7 @@ use crate::infer::error_reporting::{
|
||||||
|
|
||||||
pub mod note_and_explain;
|
pub mod note_and_explain;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::opaque_hidden_type)]
|
#[diag(infer::opaque_hidden_type)]
|
||||||
pub struct OpaqueHiddenTypeDiag {
|
pub struct OpaqueHiddenTypeDiag {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -28,7 +28,7 @@ pub struct OpaqueHiddenTypeDiag {
|
||||||
pub hidden_type: Span,
|
pub hidden_type: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::type_annotations_needed, code = "E0282")]
|
#[diag(infer::type_annotations_needed, code = "E0282")]
|
||||||
pub struct AnnotationRequired<'a> {
|
pub struct AnnotationRequired<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -46,7 +46,7 @@ pub struct AnnotationRequired<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy of `AnnotationRequired` for E0283
|
// Copy of `AnnotationRequired` for E0283
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::type_annotations_needed, code = "E0283")]
|
#[diag(infer::type_annotations_needed, code = "E0283")]
|
||||||
pub struct AmbigousImpl<'a> {
|
pub struct AmbigousImpl<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -64,7 +64,7 @@ pub struct AmbigousImpl<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy of `AnnotationRequired` for E0284
|
// Copy of `AnnotationRequired` for E0284
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::type_annotations_needed, code = "E0284")]
|
#[diag(infer::type_annotations_needed, code = "E0284")]
|
||||||
pub struct AmbigousReturn<'a> {
|
pub struct AmbigousReturn<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -81,7 +81,7 @@ pub struct AmbigousReturn<'a> {
|
||||||
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
|
pub multi_suggestions: Vec<SourceKindMultiSuggestion<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::need_type_info_in_generator, code = "E0698")]
|
#[diag(infer::need_type_info_in_generator, code = "E0698")]
|
||||||
pub struct NeedTypeInfoInGenerator<'a> {
|
pub struct NeedTypeInfoInGenerator<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -92,7 +92,7 @@ pub struct NeedTypeInfoInGenerator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used when a better one isn't available
|
// Used when a better one isn't available
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
#[label(infer::label_bad)]
|
#[label(infer::label_bad)]
|
||||||
pub struct InferenceBadError<'a> {
|
pub struct InferenceBadError<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -106,7 +106,7 @@ pub struct InferenceBadError<'a> {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum SourceKindSubdiag<'a> {
|
pub enum SourceKindSubdiag<'a> {
|
||||||
#[suggestion_verbose(
|
#[suggestion_verbose(
|
||||||
infer::source_kind_subdiag_let,
|
infer::source_kind_subdiag_let,
|
||||||
|
@ -147,7 +147,7 @@ pub enum SourceKindSubdiag<'a> {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum SourceKindMultiSuggestion<'a> {
|
pub enum SourceKindMultiSuggestion<'a> {
|
||||||
#[multipart_suggestion_verbose(
|
#[multipart_suggestion_verbose(
|
||||||
infer::source_kind_fully_qualified,
|
infer::source_kind_fully_qualified,
|
||||||
|
@ -228,7 +228,7 @@ pub enum RegionOriginNote<'a> {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddSubdiagnostic for RegionOriginNote<'_> {
|
impl AddToDiagnostic for RegionOriginNote<'_> {
|
||||||
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
let mut label_or_note = |span, msg: DiagnosticMessage| {
|
let mut label_or_note = |span, msg: DiagnosticMessage| {
|
||||||
let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count();
|
let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count();
|
||||||
|
@ -289,7 +289,7 @@ pub enum LifetimeMismatchLabels {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddSubdiagnostic for LifetimeMismatchLabels {
|
impl AddToDiagnostic for LifetimeMismatchLabels {
|
||||||
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
match self {
|
match self {
|
||||||
LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => {
|
LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => {
|
||||||
|
@ -339,7 +339,7 @@ pub struct AddLifetimeParamsSuggestion<'a> {
|
||||||
pub add_note: bool,
|
pub add_note: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddSubdiagnostic for AddLifetimeParamsSuggestion<'_> {
|
impl AddToDiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||||
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
let mut mk_suggestion = || {
|
let mut mk_suggestion = || {
|
||||||
let (
|
let (
|
||||||
|
@ -422,7 +422,7 @@ impl AddSubdiagnostic for AddLifetimeParamsSuggestion<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::lifetime_mismatch, code = "E0623")]
|
#[diag(infer::lifetime_mismatch, code = "E0623")]
|
||||||
pub struct LifetimeMismatch<'a> {
|
pub struct LifetimeMismatch<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -438,7 +438,7 @@ pub struct IntroducesStaticBecauseUnmetLifetimeReq {
|
||||||
pub binding_span: Span,
|
pub binding_span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddSubdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
impl AddToDiagnostic for IntroducesStaticBecauseUnmetLifetimeReq {
|
||||||
fn add_to_diagnostic(mut self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(mut self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
self.unmet_requirements
|
self.unmet_requirements
|
||||||
.push_span_label(self.binding_span, fluent::infer::msl_introduces_static);
|
.push_span_label(self.binding_span, fluent::infer::msl_introduces_static);
|
||||||
|
@ -450,7 +450,7 @@ pub struct ImplNote {
|
||||||
pub impl_span: Option<Span>,
|
pub impl_span: Option<Span>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddSubdiagnostic for ImplNote {
|
impl AddToDiagnostic for ImplNote {
|
||||||
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
match self.impl_span {
|
match self.impl_span {
|
||||||
Some(span) => diag.span_note(span, fluent::infer::msl_impl_note),
|
Some(span) => diag.span_note(span, fluent::infer::msl_impl_note),
|
||||||
|
@ -465,7 +465,7 @@ pub enum TraitSubdiag {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(#100717) used in `Vec<TraitSubdiag>` so requires eager translation/list support
|
// FIXME(#100717) used in `Vec<TraitSubdiag>` so requires eager translation/list support
|
||||||
impl AddSubdiagnostic for TraitSubdiag {
|
impl AddToDiagnostic for TraitSubdiag {
|
||||||
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
match self {
|
match self {
|
||||||
TraitSubdiag::Note { span } => {
|
TraitSubdiag::Note { span } => {
|
||||||
|
@ -483,7 +483,7 @@ impl AddSubdiagnostic for TraitSubdiag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(infer::mismatched_static_lifetime)]
|
#[diag(infer::mismatched_static_lifetime)]
|
||||||
pub struct MismatchedStaticLifetime<'a> {
|
pub struct MismatchedStaticLifetime<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::infer::error_reporting::nice_region_error::find_anon_type;
|
use crate::infer::error_reporting::nice_region_error::find_anon_type;
|
||||||
use rustc_errors::{self, fluent, AddSubdiagnostic, IntoDiagnosticArg};
|
use rustc_errors::{self, fluent, AddToDiagnostic, IntoDiagnosticArg};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_span::{symbol::kw, Span};
|
use rustc_span::{symbol::kw, Span};
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ impl RegionExplanation<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddSubdiagnostic for RegionExplanation<'_> {
|
impl AddToDiagnostic for RegionExplanation<'_> {
|
||||||
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
fn add_to_diagnostic(self, diag: &mut rustc_errors::Diagnostic) {
|
||||||
if let Some(span) = self.desc.span {
|
if let Some(span) = self.desc.span {
|
||||||
diag.span_note(span, fluent::infer::region_explanation);
|
diag.span_note(span, fluent::infer::region_explanation);
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
||||||
use crate::infer::SubregionOrigin;
|
use crate::infer::SubregionOrigin;
|
||||||
use crate::infer::TyCtxt;
|
use crate::infer::TyCtxt;
|
||||||
|
|
||||||
use rustc_errors::AddSubdiagnostic;
|
use rustc_errors::AddToDiagnostic;
|
||||||
use rustc_errors::{Diagnostic, ErrorGuaranteed};
|
use rustc_errors::{Diagnostic, ErrorGuaranteed};
|
||||||
use rustc_hir::Ty;
|
use rustc_hir::Ty;
|
||||||
use rustc_middle::ty::Region;
|
use rustc_middle::ty::Region;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use rustc_errors::{fluent, AddToDiagnostic, IntoDiagnostic, ErrorGuaranteed, Handler};
|
use rustc_errors::{fluent, AddToDiagnostic, ErrorGuaranteed, Handler, IntoDiagnostic};
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
use rustc_session::lint::Level;
|
use rustc_session::lint::Level;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
|
|
@ -404,7 +404,7 @@ impl LateLintPass<'_> for Diagnostics {
|
||||||
let Impl { of_trait: Some(of_trait), .. } = impl_ &&
|
let Impl { of_trait: Some(of_trait), .. } = impl_ &&
|
||||||
let Some(def_id) = of_trait.trait_def_id() &&
|
let Some(def_id) = of_trait.trait_def_id() &&
|
||||||
let Some(name) = cx.tcx.get_diagnostic_name(def_id) &&
|
let Some(name) = cx.tcx.get_diagnostic_name(def_id) &&
|
||||||
matches!(name, sym::Diagnostic | sym::Subdiagnostic | sym::DecorateLint)
|
matches!(name, sym::IntoDiagnostic | sym::AddToDiagnostic | sym::DecorateLint)
|
||||||
{
|
{
|
||||||
found_impl = true;
|
found_impl = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,13 +9,13 @@ use syn::spanned::Spanned;
|
||||||
use synstructure::Structure;
|
use synstructure::Structure;
|
||||||
|
|
||||||
/// The central struct for constructing the `into_diagnostic` method from an annotated struct.
|
/// The central struct for constructing the `into_diagnostic` method from an annotated struct.
|
||||||
pub(crate) struct SessionDiagnosticDerive<'a> {
|
pub(crate) struct DiagnosticDerive<'a> {
|
||||||
structure: Structure<'a>,
|
structure: Structure<'a>,
|
||||||
handler: syn::Ident,
|
handler: syn::Ident,
|
||||||
builder: DiagnosticDeriveBuilder,
|
builder: DiagnosticDeriveBuilder,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SessionDiagnosticDerive<'a> {
|
impl<'a> DiagnosticDerive<'a> {
|
||||||
pub(crate) fn new(diag: syn::Ident, handler: syn::Ident, structure: Structure<'a>) -> Self {
|
pub(crate) fn new(diag: syn::Ident, handler: syn::Ident, structure: Structure<'a>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
builder: DiagnosticDeriveBuilder {
|
builder: DiagnosticDeriveBuilder {
|
||||||
|
@ -31,7 +31,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn into_tokens(self) -> TokenStream {
|
pub(crate) fn into_tokens(self) -> TokenStream {
|
||||||
let SessionDiagnosticDerive { mut structure, handler, mut builder } = self;
|
let DiagnosticDerive { mut structure, handler, mut builder } = self;
|
||||||
|
|
||||||
let ast = structure.ast();
|
let ast = structure.ast();
|
||||||
let implementation = {
|
let implementation = {
|
||||||
|
|
|
@ -5,7 +5,7 @@ mod fluent;
|
||||||
mod subdiagnostic;
|
mod subdiagnostic;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use diagnostic::{LintDiagnosticDerive, SessionDiagnosticDerive};
|
use diagnostic::{DiagnosticDerive, LintDiagnosticDerive};
|
||||||
pub(crate) use fluent::fluent_messages;
|
pub(crate) use fluent::fluent_messages;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::format_ident;
|
use quote::format_ident;
|
||||||
|
@ -59,7 +59,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(s: Structure<'_>) -> TokenStream {
|
pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
SessionDiagnosticDerive::new(format_ident!("diag"), format_ident!("handler"), s).into_tokens()
|
DiagnosticDerive::new(format_ident!("diag"), format_ident!("handler"), s).into_tokens()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements `#[derive(LintDiagnostic)]`, which allows for lints to be specified as a struct,
|
/// Implements `#[derive(LintDiagnostic)]`, which allows for lints to be specified as a struct,
|
||||||
|
@ -103,7 +103,7 @@ pub fn session_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
|
/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
|
||||||
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/sessiondiagnostic.html>
|
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#reference>
|
||||||
pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
pub fn lint_diagnostic_derive(s: Structure<'_>) -> TokenStream {
|
||||||
LintDiagnosticDerive::new(format_ident!("diag"), s).into_tokens()
|
LintDiagnosticDerive::new(format_ident!("diag"), s).into_tokens()
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use rustc_errors::{error_code, IntoDiagnostic, ErrorGuaranteed};
|
use rustc_errors::{error_code, ErrorGuaranteed, IntoDiagnostic};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_session::config;
|
use rustc_session::config;
|
||||||
use rustc_span::{sym, Span, Symbol};
|
use rustc_span::{sym, Span, Symbol};
|
||||||
|
|
|
@ -53,6 +53,7 @@ use rustc_query_system::ich::StableHashingContext;
|
||||||
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
|
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
|
||||||
use rustc_session::config::{CrateType, OutputFilenames};
|
use rustc_session::config::{CrateType, OutputFilenames};
|
||||||
use rustc_session::cstore::CrateStoreDyn;
|
use rustc_session::cstore::CrateStoreDyn;
|
||||||
|
use rustc_session::errors::TargetDataLayoutErrorsWrapper;
|
||||||
use rustc_session::lint::Lint;
|
use rustc_session::lint::Lint;
|
||||||
use rustc_session::Limit;
|
use rustc_session::Limit;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
@ -1245,7 +1246,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
output_filenames: OutputFilenames,
|
output_filenames: OutputFilenames,
|
||||||
) -> GlobalCtxt<'tcx> {
|
) -> GlobalCtxt<'tcx> {
|
||||||
let data_layout = TargetDataLayout::parse(&s.target).unwrap_or_else(|err| {
|
let data_layout = TargetDataLayout::parse(&s.target).unwrap_or_else(|err| {
|
||||||
s.emit_fatal(err);
|
s.emit_fatal(TargetDataLayoutErrorsWrapper(err));
|
||||||
});
|
});
|
||||||
let interners = CtxtInterners::new(arena);
|
let interners = CtxtInterners::new(arena);
|
||||||
let common_types = CommonTypes::new(
|
let common_types = CommonTypes::new(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use rustc_errors::IntoDiagnostic;
|
|
||||||
use rustc_errors::ErrorGuaranteed;
|
use rustc_errors::ErrorGuaranteed;
|
||||||
|
use rustc_errors::IntoDiagnostic;
|
||||||
use rustc_macros::{Diagnostic, LintDiagnostic};
|
use rustc_macros::{Diagnostic, LintDiagnostic};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
|
|
@ -434,7 +434,7 @@ pub(crate) struct NotAsNegationOperator {
|
||||||
pub sub: NotAsNegationOperatorSub,
|
pub sub: NotAsNegationOperatorSub,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionSubdiagnostic)]
|
#[derive(Subdiagnostic)]
|
||||||
pub enum NotAsNegationOperatorSub {
|
pub enum NotAsNegationOperatorSub {
|
||||||
#[suggestion_short(
|
#[suggestion_short(
|
||||||
parser::unexpected_token_after_not_default,
|
parser::unexpected_token_after_not_default,
|
||||||
|
@ -737,7 +737,7 @@ pub(crate) struct RemoveLet {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(parser::use_eq_instead)]
|
#[diag(parser::use_eq_instead)]
|
||||||
pub(crate) struct UseEqInstead {
|
pub(crate) struct UseEqInstead {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
|
|
@ -650,7 +650,7 @@ pub struct RustcLintOptDenyFieldAccess {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(passes::collapse_debuginfo)]
|
#[diag(passes::collapse_debuginfo)]
|
||||||
pub struct CollapseDebuginfo {
|
pub struct CollapseDebuginfo {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use rustc_errors::AddToDiagnostic;
|
use rustc_errors::AddToDiagnostic;
|
||||||
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||||
use rustc_session::Limit;
|
use rustc_session::Limit;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
|
||||||
|
|
||||||
pub struct CycleStack {
|
pub struct CycleStack {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::query::{QueryContext, QueryStackFrame};
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
Diagnostic, DiagnosticBuilder, IntoDiagnostic, ErrorGuaranteed, Handler, Level,
|
Diagnostic, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, Level,
|
||||||
};
|
};
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
pub use crate::options::*;
|
pub use crate::options::*;
|
||||||
|
|
||||||
|
use crate::errors::TargetDataLayoutErrorsWrapper;
|
||||||
use crate::search_paths::SearchPath;
|
use crate::search_paths::SearchPath;
|
||||||
use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
|
use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
|
||||||
use crate::{early_error, early_warn, Session};
|
use crate::{early_error, early_warn, Session};
|
||||||
|
@ -898,7 +899,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
|
||||||
let max_atomic_width = sess.target.max_atomic_width();
|
let max_atomic_width = sess.target.max_atomic_width();
|
||||||
let atomic_cas = sess.target.atomic_cas;
|
let atomic_cas = sess.target.atomic_cas;
|
||||||
let layout = TargetDataLayout::parse(&sess.target).unwrap_or_else(|err| {
|
let layout = TargetDataLayout::parse(&sess.target).unwrap_or_else(|err| {
|
||||||
sess.emit_fatal(err);
|
sess.emit_fatal(TargetDataLayoutErrorsWrapper(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut ret = CrateConfig::default();
|
let mut ret = CrateConfig::default();
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use std::num::NonZeroU32;
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
use crate::cgu_reuse_tracker::CguReuse;
|
use crate::cgu_reuse_tracker::CguReuse;
|
||||||
use crate::{self as rustc_session, SessionDiagnostic};
|
use rustc_errors::{
|
||||||
use rustc_errors::{fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, MultiSpan};
|
fluent, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan,
|
||||||
use rustc_macros::SessionDiagnostic;
|
};
|
||||||
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
use rustc_target::abi::TargetDataLayoutErrors;
|
use rustc_target::abi::TargetDataLayoutErrors;
|
||||||
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
|
use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
|
||||||
|
@ -46,10 +47,12 @@ pub struct FeatureDiagnosticHelp {
|
||||||
pub feature: Symbol,
|
pub feature: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
|
pub struct TargetDataLayoutErrorsWrapper<'a>(pub TargetDataLayoutErrors<'a>);
|
||||||
|
|
||||||
|
impl IntoDiagnostic<'_, !> for TargetDataLayoutErrorsWrapper<'_> {
|
||||||
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
|
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
|
||||||
let mut diag;
|
let mut diag;
|
||||||
match self {
|
match self.0 {
|
||||||
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => {
|
||||||
diag = handler.struct_fatal(fluent::session::target_invalid_address_space);
|
diag = handler.struct_fatal(fluent::session::target_invalid_address_space);
|
||||||
diag.set_arg("addr_space", addr_space);
|
diag.set_arg("addr_space", addr_space);
|
||||||
|
@ -97,87 +100,87 @@ impl IntoDiagnostic<'_, !> for TargetDataLayoutErrors<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::not_circumvent_feature)]
|
#[diag(session::not_circumvent_feature)]
|
||||||
pub struct NotCircumventFeature;
|
pub struct NotCircumventFeature;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::linker_plugin_lto_windows_not_supported)]
|
#[diag(session::linker_plugin_lto_windows_not_supported)]
|
||||||
pub struct LinkerPluginToWindowsNotSupported;
|
pub struct LinkerPluginToWindowsNotSupported;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::profile_use_file_does_not_exist)]
|
#[diag(session::profile_use_file_does_not_exist)]
|
||||||
pub struct ProfileUseFileDoesNotExist<'a> {
|
pub struct ProfileUseFileDoesNotExist<'a> {
|
||||||
pub path: &'a std::path::Path,
|
pub path: &'a std::path::Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::profile_sample_use_file_does_not_exist)]
|
#[diag(session::profile_sample_use_file_does_not_exist)]
|
||||||
pub struct ProfileSampleUseFileDoesNotExist<'a> {
|
pub struct ProfileSampleUseFileDoesNotExist<'a> {
|
||||||
pub path: &'a std::path::Path,
|
pub path: &'a std::path::Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::target_requires_unwind_tables)]
|
#[diag(session::target_requires_unwind_tables)]
|
||||||
pub struct TargetRequiresUnwindTables;
|
pub struct TargetRequiresUnwindTables;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::sanitizer_not_supported)]
|
#[diag(session::sanitizer_not_supported)]
|
||||||
pub struct SanitizerNotSupported {
|
pub struct SanitizerNotSupported {
|
||||||
pub us: String,
|
pub us: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::sanitizers_not_supported)]
|
#[diag(session::sanitizers_not_supported)]
|
||||||
pub struct SanitizersNotSupported {
|
pub struct SanitizersNotSupported {
|
||||||
pub us: String,
|
pub us: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::cannot_mix_and_match_sanitizers)]
|
#[diag(session::cannot_mix_and_match_sanitizers)]
|
||||||
pub struct CannotMixAndMatchSanitizers {
|
pub struct CannotMixAndMatchSanitizers {
|
||||||
pub first: String,
|
pub first: String,
|
||||||
pub second: String,
|
pub second: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::cannot_enable_crt_static_linux)]
|
#[diag(session::cannot_enable_crt_static_linux)]
|
||||||
pub struct CannotEnableCrtStaticLinux;
|
pub struct CannotEnableCrtStaticLinux;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::sanitizer_cfi_enabled)]
|
#[diag(session::sanitizer_cfi_enabled)]
|
||||||
pub struct SanitizerCfiEnabled;
|
pub struct SanitizerCfiEnabled;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::unstable_virtual_function_elimination)]
|
#[diag(session::unstable_virtual_function_elimination)]
|
||||||
pub struct UnstableVirtualFunctionElimination;
|
pub struct UnstableVirtualFunctionElimination;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::unsupported_dwarf_version)]
|
#[diag(session::unsupported_dwarf_version)]
|
||||||
pub struct UnsupportedDwarfVersion {
|
pub struct UnsupportedDwarfVersion {
|
||||||
pub dwarf_version: u32,
|
pub dwarf_version: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::target_stack_protector_not_supported)]
|
#[diag(session::target_stack_protector_not_supported)]
|
||||||
pub struct StackProtectorNotSupportedForTarget<'a> {
|
pub struct StackProtectorNotSupportedForTarget<'a> {
|
||||||
pub stack_protector: StackProtector,
|
pub stack_protector: StackProtector,
|
||||||
pub target_triple: &'a TargetTriple,
|
pub target_triple: &'a TargetTriple,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::split_debuginfo_unstable_platform)]
|
#[diag(session::split_debuginfo_unstable_platform)]
|
||||||
pub struct SplitDebugInfoUnstablePlatform {
|
pub struct SplitDebugInfoUnstablePlatform {
|
||||||
pub debuginfo: SplitDebuginfo,
|
pub debuginfo: SplitDebuginfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::file_is_not_writeable)]
|
#[diag(session::file_is_not_writeable)]
|
||||||
pub struct FileIsNotWriteable<'a> {
|
pub struct FileIsNotWriteable<'a> {
|
||||||
pub file: &'a std::path::Path,
|
pub file: &'a std::path::Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::crate_name_does_not_match)]
|
#[diag(session::crate_name_does_not_match)]
|
||||||
pub struct CrateNameDoesNotMatch<'a> {
|
pub struct CrateNameDoesNotMatch<'a> {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -186,13 +189,13 @@ pub struct CrateNameDoesNotMatch<'a> {
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::crate_name_invalid)]
|
#[diag(session::crate_name_invalid)]
|
||||||
pub struct CrateNameInvalid<'a> {
|
pub struct CrateNameInvalid<'a> {
|
||||||
pub s: &'a str,
|
pub s: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(session::crate_name_empty)]
|
#[diag(session::crate_name_empty)]
|
||||||
pub struct CrateNameEmpty {
|
pub struct CrateNameEmpty {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
|
@ -205,11 +208,8 @@ pub struct InvalidCharacterInCrateName<'a> {
|
||||||
pub crate_name: &'a str,
|
pub crate_name: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::SessionDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
|
impl IntoDiagnostic<'_> for InvalidCharacterInCrateName<'_> {
|
||||||
fn into_diagnostic(
|
fn into_diagnostic(self, sess: &Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
|
||||||
self,
|
|
||||||
sess: &Handler,
|
|
||||||
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
|
|
||||||
let mut diag = sess.struct_err(fluent::session::invalid_character_in_create_name);
|
let mut diag = sess.struct_err(fluent::session::invalid_character_in_create_name);
|
||||||
if let Some(sp) = self.span {
|
if let Some(sp) = self.span {
|
||||||
diag.set_span(sp);
|
diag.set_span(sp);
|
||||||
|
|
|
@ -11,8 +11,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
|
||||||
use rustc_data_structures::sync::{Lock, Lrc};
|
use rustc_data_structures::sync::{Lock, Lrc};
|
||||||
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
|
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, IntoDiagnostic,
|
fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId,
|
||||||
DiagnosticId, DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, MultiSpan, StashKey,
|
DiagnosticMessage, EmissionGuarantee, ErrorGuaranteed, IntoDiagnostic, MultiSpan, StashKey,
|
||||||
};
|
};
|
||||||
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
|
|
|
@ -27,8 +27,8 @@ use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType};
|
||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::registry::Registry;
|
use rustc_errors::registry::Registry;
|
||||||
use rustc_errors::{
|
use rustc_errors::{
|
||||||
error_code, fallback_fluent_bundle, DiagnosticBuilder, IntoDiagnostic, DiagnosticId,
|
error_code, fallback_fluent_bundle, DiagnosticBuilder, DiagnosticId, DiagnosticMessage,
|
||||||
DiagnosticMessage, ErrorGuaranteed, FluentBundle, LazyFallbackBundle, MultiSpan,
|
ErrorGuaranteed, FluentBundle, IntoDiagnostic, LazyFallbackBundle, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
pub use rustc_span::def_id::StableCrateId;
|
pub use rustc_span::def_id::StableCrateId;
|
||||||
|
|
|
@ -125,6 +125,7 @@ symbols! {
|
||||||
Symbols {
|
Symbols {
|
||||||
AcqRel,
|
AcqRel,
|
||||||
Acquire,
|
Acquire,
|
||||||
|
AddToDiagnostic,
|
||||||
Alignment,
|
Alignment,
|
||||||
Any,
|
Any,
|
||||||
Arc,
|
Arc,
|
||||||
|
@ -176,7 +177,6 @@ symbols! {
|
||||||
DecorateLint,
|
DecorateLint,
|
||||||
Default,
|
Default,
|
||||||
Deref,
|
Deref,
|
||||||
Diagnostic,
|
|
||||||
DiagnosticMessage,
|
DiagnosticMessage,
|
||||||
DirBuilder,
|
DirBuilder,
|
||||||
Display,
|
Display,
|
||||||
|
@ -210,6 +210,7 @@ symbols! {
|
||||||
Implied,
|
Implied,
|
||||||
Input,
|
Input,
|
||||||
Into,
|
Into,
|
||||||
|
IntoDiagnostic,
|
||||||
IntoFuture,
|
IntoFuture,
|
||||||
IntoIterator,
|
IntoIterator,
|
||||||
IoRead,
|
IoRead,
|
||||||
|
@ -282,7 +283,6 @@ symbols! {
|
||||||
String,
|
String,
|
||||||
StructuralEq,
|
StructuralEq,
|
||||||
StructuralPartialEq,
|
StructuralPartialEq,
|
||||||
Subdiagnostic,
|
|
||||||
SubdiagnosticMessage,
|
SubdiagnosticMessage,
|
||||||
Sync,
|
Sync,
|
||||||
T,
|
T,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use rustc_errors::{fluent, IntoDiagnostic, ErrorGuaranteed, Handler};
|
use rustc_errors::{fluent, ErrorGuaranteed, Handler, IntoDiagnostic};
|
||||||
use rustc_macros::Diagnostic;
|
use rustc_macros::Diagnostic;
|
||||||
use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated};
|
use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated};
|
||||||
use rustc_session::Limit;
|
use rustc_session::Limit;
|
||||||
|
|
|
@ -20,7 +20,7 @@ use rustc_span::Span;
|
||||||
|
|
||||||
#[derive(Diagnostic)]
|
#[derive(Diagnostic)]
|
||||||
#[diag(parser::expect_path)]
|
#[diag(parser::expect_path)]
|
||||||
struct DeriveSessionDiagnostic {
|
struct DeriveDiagnostic {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@ struct Note {
|
||||||
span: Span,
|
span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UntranslatableInSessionDiagnostic;
|
pub struct UntranslatableInIntoDiagnostic;
|
||||||
|
|
||||||
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInSessionDiagnostic {
|
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for UntranslatableInIntoDiagnostic {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
handler.struct_err("untranslatable diagnostic")
|
handler.struct_err("untranslatable diagnostic")
|
||||||
//~^ ERROR diagnostics should be created using translatable messages
|
//~^ ERROR diagnostics should be created using translatable messages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TranslatableInSessionDiagnostic;
|
pub struct TranslatableInIntoDiagnostic;
|
||||||
|
|
||||||
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInSessionDiagnostic {
|
impl<'a> IntoDiagnostic<'a, ErrorGuaranteed> for TranslatableInIntoDiagnostic {
|
||||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||||
handler.struct_err(fluent::parser::expect_path)
|
handler.struct_err(fluent::parser::expect_path)
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,7 +449,7 @@ error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
|
||||||
--> $DIR/diagnostic-derive.rs:331:10
|
--> $DIR/diagnostic-derive.rs:331:10
|
||||||
|
|
|
|
||||||
LL | #[derive(Diagnostic)]
|
LL | #[derive(Diagnostic)]
|
||||||
| ^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
|
| ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
|
||||||
|
|
|
|
||||||
= help: normalized in stderr
|
= help: normalized in stderr
|
||||||
note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg`
|
note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue