Rollup merge of #134202 - nnethercote:rm-existing_doc_keyword, r=GuillaumeGomez
Remove `rustc::existing_doc_keyword` lint The check doesn't require a lint. r? ``@GuillaumeGomez``
This commit is contained in:
commit
52b4557639
25 changed files with 119 additions and 176 deletions
|
@ -536,9 +536,6 @@ lint_non_camel_case_type = {$sort} `{$name}` should have an upper camel case nam
|
|||
.suggestion = convert the identifier to upper camel case
|
||||
.label = should have an UpperCamelCase name
|
||||
|
||||
lint_non_existent_doc_keyword = found non-existing keyword `{$keyword}` used in `#[doc(keyword = "...")]`
|
||||
.help = only existing keywords are allowed in core/std
|
||||
|
||||
lint_non_fmt_panic = panic message is not a string literal
|
||||
.note = this usage of `{$name}!()` is deprecated; it will be a hard error in Rust 2021
|
||||
.more_info_note = for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
|
|
|
@ -12,11 +12,11 @@ use rustc_middle::ty::{self, GenericArgsRef, Ty as MiddleTy};
|
|||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use rustc_span::symbol::sym;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::lints::{
|
||||
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
|
||||
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand,
|
||||
NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag,
|
||||
SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrInherentUsage,
|
||||
UntranslatableDiag,
|
||||
|
@ -375,46 +375,6 @@ impl EarlyLintPass for LintPassImpl {
|
|||
}
|
||||
}
|
||||
|
||||
declare_tool_lint! {
|
||||
/// The `existing_doc_keyword` lint detects use `#[doc()]` keywords
|
||||
/// that don't exist, e.g. `#[doc(keyword = "..")]`.
|
||||
pub rustc::EXISTING_DOC_KEYWORD,
|
||||
Allow,
|
||||
"Check that documented keywords in std and core actually exist",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_lint_pass!(ExistingDocKeyword => [EXISTING_DOC_KEYWORD]);
|
||||
|
||||
fn is_doc_keyword(s: Symbol) -> bool {
|
||||
s <= kw::Union
|
||||
}
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for ExistingDocKeyword {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::Item<'_>) {
|
||||
for attr in cx.tcx.hir().attrs(item.hir_id()) {
|
||||
if !attr.has_name(sym::doc) {
|
||||
continue;
|
||||
}
|
||||
if let Some(list) = attr.meta_item_list() {
|
||||
for nested in list {
|
||||
if nested.has_name(sym::keyword) {
|
||||
let keyword = nested
|
||||
.value_str()
|
||||
.expect("#[doc(keyword = \"...\")] expected a value!");
|
||||
if is_doc_keyword(keyword) {
|
||||
return;
|
||||
}
|
||||
cx.emit_span_lint(EXISTING_DOC_KEYWORD, attr.span, NonExistentDocKeyword {
|
||||
keyword,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare_tool_lint! {
|
||||
/// The `untranslatable_diagnostic` lint detects messages passed to functions with `impl
|
||||
/// Into<{D,Subd}iagMessage` parameters without using translatable Fluent strings.
|
||||
|
|
|
@ -600,8 +600,6 @@ fn register_internals(store: &mut LintStore) {
|
|||
store.register_late_mod_pass(|_| Box::new(DefaultHashTypes));
|
||||
store.register_lints(&QueryStability::lint_vec());
|
||||
store.register_late_mod_pass(|_| Box::new(QueryStability));
|
||||
store.register_lints(&ExistingDocKeyword::lint_vec());
|
||||
store.register_late_mod_pass(|_| Box::new(ExistingDocKeyword));
|
||||
store.register_lints(&TyTyKind::lint_vec());
|
||||
store.register_late_mod_pass(|_| Box::new(TyTyKind));
|
||||
store.register_lints(&TypeIr::lint_vec());
|
||||
|
@ -629,7 +627,6 @@ fn register_internals(store: &mut LintStore) {
|
|||
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
|
||||
LintId::of(USAGE_OF_QUALIFIED_TY),
|
||||
LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT),
|
||||
LintId::of(EXISTING_DOC_KEYWORD),
|
||||
LintId::of(BAD_OPT_ACCESS),
|
||||
LintId::of(SPAN_USE_EQ_CTXT),
|
||||
]);
|
||||
|
|
|
@ -950,13 +950,6 @@ pub(crate) struct NonGlobImportTypeIrInherent {
|
|||
#[help]
|
||||
pub(crate) struct LintPassByHand;
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_non_existent_doc_keyword)]
|
||||
#[help]
|
||||
pub(crate) struct NonExistentDocKeyword {
|
||||
pub keyword: Symbol,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_diag_out_of_impl)]
|
||||
pub(crate) struct DiagOutOfImpl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue