Introduce the #[diagnostic]
attribute namespace
Co-authored-by: est31 <est31@users.noreply.github.com> Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
This commit is contained in:
parent
d150dbb067
commit
5b576665e5
15 changed files with 202 additions and 4 deletions
|
@ -24,7 +24,9 @@ use rustc_hir::def_id::{CrateNum, LocalDefId};
|
|||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::RegisteredTools;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE};
|
||||
use rustc_session::lint::builtin::{
|
||||
LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE, UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
|
||||
};
|
||||
use rustc_session::lint::builtin::{UNUSED_MACROS, UNUSED_MACRO_RULES};
|
||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||
use rustc_session::parse::feature_err;
|
||||
|
@ -140,9 +142,9 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
|||
}
|
||||
}
|
||||
}
|
||||
// We implicitly add `rustfmt` and `clippy` to known tools,
|
||||
// We implicitly add `rustfmt`, `clippy`, `diagnostic` to known tools,
|
||||
// but it's not an error to register them explicitly.
|
||||
let predefined_tools = [sym::clippy, sym::rustfmt];
|
||||
let predefined_tools = [sym::clippy, sym::rustfmt, sym::diagnostic];
|
||||
registered_tools.extend(predefined_tools.iter().cloned().map(Ident::with_dummy_span));
|
||||
registered_tools
|
||||
}
|
||||
|
@ -595,6 +597,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
if res == Res::NonMacroAttr(NonMacroAttrKind::Tool)
|
||||
&& path.segments.len() >= 2
|
||||
&& path.segments[0].ident.name == sym::diagnostic
|
||||
{
|
||||
self.tcx.sess.parse_sess.buffer_lint(
|
||||
UNKNOWN_DIAGNOSTIC_ATTRIBUTES,
|
||||
path.segments[1].span(),
|
||||
node_id,
|
||||
"unknown diagnostic attribute",
|
||||
);
|
||||
}
|
||||
|
||||
Ok((ext, res))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue