mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Add more track_caller
This commit is contained in:
parent
0f35c0c672
commit
cbeb244b05
@ -763,6 +763,7 @@ impl Handler {
|
||||
|
||||
/// Construct a builder at the `Allow` level with the `msg`.
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||
DiagnosticBuilder::new(self, Level::Allow, msg)
|
||||
}
|
||||
@ -864,6 +865,7 @@ impl Handler {
|
||||
|
||||
/// Construct a builder at the `Fatal` level at the given `span`, with the `msg`, and `code`.
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_fatal_with_code(
|
||||
&self,
|
||||
span: impl Into<MultiSpan>,
|
||||
@ -877,6 +879,7 @@ impl Handler {
|
||||
|
||||
/// Construct a builder at the `Error` level with the `msg`.
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_fatal(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, !> {
|
||||
DiagnosticBuilder::new_fatal(self, msg)
|
||||
}
|
||||
@ -898,6 +901,7 @@ impl Handler {
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
|
||||
self.emit_diag_at_span(Diagnostic::new(Fatal, msg), span);
|
||||
FatalError.raise()
|
||||
@ -956,7 +960,6 @@ impl Handler {
|
||||
self.emit_diag_at_span(Diagnostic::new_with_code(Warning(None), Some(code), msg), span);
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn span_bug(&self, span: impl Into<MultiSpan>, msg: impl Into<DiagnosticMessage>) -> ! {
|
||||
self.inner.borrow_mut().span_bug(span, msg)
|
||||
}
|
||||
@ -972,7 +975,6 @@ impl Handler {
|
||||
|
||||
// FIXME(eddyb) note the comment inside `impl Drop for HandlerInner`, that's
|
||||
// where the explanation of what "good path" is (also, it should be renamed).
|
||||
#[track_caller]
|
||||
pub fn delay_good_path_bug(&self, msg: impl Into<DiagnosticMessage>) {
|
||||
self.inner.borrow_mut().delay_good_path_bug(msg)
|
||||
}
|
||||
|
@ -252,6 +252,7 @@ pub struct MissingTypeParams {
|
||||
|
||||
// Manual implementation of `IntoDiagnostic` to be able to call `span_to_snippet`.
|
||||
impl<'a> IntoDiagnostic<'a> for MissingTypeParams {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
|
||||
let mut err = handler.struct_span_err_with_code(
|
||||
self.span,
|
||||
|
@ -69,6 +69,8 @@ impl<'a> DiagnosticDerive<'a> {
|
||||
for @Self
|
||||
where G: rustc_errors::EmissionGuarantee
|
||||
{
|
||||
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
#handler: &'__diagnostic_handler_sess rustc_errors::Handler
|
||||
@ -133,6 +135,7 @@ impl<'a> LintDiagnosticDerive<'a> {
|
||||
let diag = &builder.diag;
|
||||
structure.gen_impl(quote! {
|
||||
gen impl<'__a> rustc_errors::DecorateLint<'__a, ()> for @Self {
|
||||
#[track_caller]
|
||||
fn decorate_lint<'__b>(
|
||||
self,
|
||||
#diag: &'__b mut rustc_errors::DiagnosticBuilder<'__a, ()>
|
||||
|
@ -578,6 +578,7 @@ pub struct InvalidMetadataFiles {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for InvalidMetadataFiles {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'_ rustc_errors::Handler,
|
||||
@ -606,6 +607,7 @@ pub struct CannotFindCrate {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for CannotFindCrate {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'_ rustc_errors::Handler,
|
||||
|
@ -45,6 +45,7 @@ pub struct UnusedGenericParams {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for UnusedGenericParams {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'_ rustc_errors::Handler,
|
||||
|
@ -930,6 +930,7 @@ pub(crate) struct ExpectedIdentifier {
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'a rustc_errors::Handler,
|
||||
@ -977,6 +978,7 @@ pub(crate) struct ExpectedSemi {
|
||||
}
|
||||
|
||||
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'a rustc_errors::Handler,
|
||||
|
@ -744,6 +744,7 @@ pub struct InvalidAttrAtCrateLevel {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'_ rustc_errors::Handler,
|
||||
@ -877,6 +878,7 @@ pub struct BreakNonLoop<'a> {
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &rustc_errors::Handler,
|
||||
@ -1014,6 +1016,7 @@ pub struct NakedFunctionsAsmBlock {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for NakedFunctionsAsmBlock {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &rustc_errors::Handler,
|
||||
@ -1137,6 +1140,7 @@ pub struct NoMainErr {
|
||||
}
|
||||
|
||||
impl<'a> IntoDiagnostic<'a> for NoMainErr {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &'a rustc_errors::Handler,
|
||||
@ -1197,6 +1201,7 @@ pub struct DuplicateLangItem {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for DuplicateLangItem {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &rustc_errors::Handler,
|
||||
|
@ -97,6 +97,7 @@ pub fn feature_err<'a>(
|
||||
///
|
||||
/// This variant allows you to control whether it is a library or language feature.
|
||||
/// Almost always, you want to use this for a language feature. If so, prefer `feature_err`.
|
||||
#[track_caller]
|
||||
pub fn feature_err_issue<'a>(
|
||||
sess: &'a ParseSess,
|
||||
feature: Symbol,
|
||||
@ -332,6 +333,7 @@ impl ParseSess {
|
||||
self.proc_macro_quoted_spans.lock().clone()
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_err<'a>(
|
||||
&'a self,
|
||||
err: impl IntoDiagnostic<'a>,
|
||||
@ -339,10 +341,12 @@ impl ParseSess {
|
||||
err.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
self.create_err(err).emit()
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn create_warning<'a>(
|
||||
&'a self,
|
||||
warning: impl IntoDiagnostic<'a, ()>,
|
||||
@ -350,6 +354,7 @@ impl ParseSess {
|
||||
warning.into_diagnostic(&self.span_diagnostic)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||
self.create_warning(warning).emit()
|
||||
}
|
||||
@ -377,6 +382,7 @@ impl ParseSess {
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_err(
|
||||
&self,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
|
@ -330,6 +330,7 @@ impl Session {
|
||||
self.diagnostic().struct_warn_with_expectation(msg, id)
|
||||
}
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_allow<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
sp: S,
|
||||
@ -338,10 +339,12 @@ impl Session {
|
||||
self.diagnostic().struct_span_allow(sp, msg)
|
||||
}
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_allow(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
|
||||
self.diagnostic().struct_allow(msg)
|
||||
}
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_expect(
|
||||
&self,
|
||||
msg: impl Into<DiagnosticMessage>,
|
||||
@ -396,6 +399,7 @@ impl Session {
|
||||
self.diagnostic().struct_warn_with_code(msg, code)
|
||||
}
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn struct_span_fatal<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
sp: S,
|
||||
@ -418,6 +422,7 @@ impl Session {
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
#[track_caller]
|
||||
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
|
||||
self.diagnostic().span_fatal(sp, msg)
|
||||
}
|
||||
@ -490,33 +495,40 @@ impl Session {
|
||||
add_feature_diagnostics(&mut err, &self.parse_sess, feature);
|
||||
err
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed {
|
||||
self.parse_sess.emit_err(err)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn create_warning<'a>(
|
||||
&'a self,
|
||||
err: impl IntoDiagnostic<'a, ()>,
|
||||
) -> DiagnosticBuilder<'a, ()> {
|
||||
self.parse_sess.create_warning(err)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) {
|
||||
self.parse_sess.emit_warning(warning)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn create_note<'a>(
|
||||
&'a self,
|
||||
note: impl IntoDiagnostic<'a, Noted>,
|
||||
) -> DiagnosticBuilder<'a, Noted> {
|
||||
self.parse_sess.create_note(note)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, Noted>) -> Noted {
|
||||
self.parse_sess.emit_note(note)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn create_fatal<'a>(
|
||||
&'a self,
|
||||
fatal: impl IntoDiagnostic<'a, !>,
|
||||
) -> DiagnosticBuilder<'a, !> {
|
||||
self.parse_sess.create_fatal(fatal)
|
||||
}
|
||||
#[track_caller]
|
||||
pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! {
|
||||
self.parse_sess.emit_fatal(fatal)
|
||||
}
|
||||
@ -556,6 +568,7 @@ impl Session {
|
||||
}
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
#[allow(rustc::diagnostic_outside_of_impl)]
|
||||
#[track_caller]
|
||||
pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) {
|
||||
self.diagnostic().span_warn(sp, msg)
|
||||
}
|
||||
@ -602,6 +615,8 @@ impl Session {
|
||||
pub fn note_without_error(&self, msg: impl Into<DiagnosticMessage>) {
|
||||
self.diagnostic().note_without_error(msg)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn span_note_without_error<S: Into<MultiSpan>>(
|
||||
&self,
|
||||
sp: S,
|
||||
|
@ -67,6 +67,7 @@ pub struct NegativePositiveConflict<'a> {
|
||||
}
|
||||
|
||||
impl IntoDiagnostic<'_> for NegativePositiveConflict<'_> {
|
||||
#[track_caller]
|
||||
fn into_diagnostic(
|
||||
self,
|
||||
handler: &Handler,
|
||||
|
@ -10,7 +10,7 @@ error[E0268]: `break` outside of a loop
|
||||
|
|
||||
LL | break rust
|
||||
| ^^^^^^^^^^ cannot `break` outside of a loop
|
||||
-Ztrack-diagnostics: created at compiler/rustc_passes/src/errors.rs:LL:CC
|
||||
-Ztrack-diagnostics: created at compiler/rustc_passes/src/loops.rs:LL:CC
|
||||
|
||||
error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?
|
||||
|
||||
|
14
src/test/ui/track-diagnostics/track6.rs
Normal file
14
src/test/ui/track-diagnostics/track6.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// compile-flags: -Z track-diagnostics
|
||||
// error-pattern: created at
|
||||
|
||||
|
||||
|
||||
pub trait Foo {
|
||||
fn bar();
|
||||
}
|
||||
|
||||
impl <T> Foo for T {
|
||||
default fn bar() {}
|
||||
}
|
||||
|
||||
fn main() {}
|
13
src/test/ui/track-diagnostics/track6.stderr
Normal file
13
src/test/ui/track-diagnostics/track6.stderr
Normal file
@ -0,0 +1,13 @@
|
||||
error[E0658]: specialization is unstable
|
||||
--> $DIR/track6.rs:11:5
|
||||
|
|
||||
LL | default fn bar() {}
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
-Ztrack-diagnostics: created at $COMPILER_DIR/rustc_session/src/parse.rs:93:5
|
||||
|
|
||||
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
|
||||
= help: add `#![feature(specialization)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
Loading…
Reference in New Issue
Block a user