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
|
@ -16,7 +16,6 @@ rustc_feature = { path = "../rustc_feature" }
|
|||
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_lexer = { path = "../rustc_lexer" }
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_privacy = { path = "../rustc_privacy" }
|
||||
|
|
|
@ -211,8 +211,9 @@ passes_doc_invalid =
|
|||
passes_doc_keyword_empty_mod =
|
||||
`#[doc(keyword = "...")]` should be used on empty modules
|
||||
|
||||
passes_doc_keyword_invalid_ident =
|
||||
`{$doc_keyword}` is not a valid identifier
|
||||
passes_doc_keyword_not_keyword =
|
||||
nonexistent keyword `{$keyword}` used in `#[doc(keyword = "...")]`
|
||||
.help = only existing keywords are allowed in core/std
|
||||
|
||||
passes_doc_keyword_not_mod =
|
||||
`#[doc(keyword = "...")]` should be used on modules
|
||||
|
|
|
@ -912,6 +912,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
}
|
||||
|
||||
fn check_doc_keyword(&self, meta: &MetaItemInner, hir_id: HirId) {
|
||||
fn is_doc_keyword(s: Symbol) -> bool {
|
||||
// FIXME: Once rustdoc can handle URL conflicts on case insensitive file systems, we
|
||||
// can remove the `SelfTy` case here, remove `sym::SelfTy`, and update the
|
||||
// `#[doc(keyword = "SelfTy")` attribute in `library/std/src/keyword_docs.rs`.
|
||||
s <= kw::Union || s == sym::SelfTy
|
||||
}
|
||||
|
||||
let doc_keyword = meta.value_str().unwrap_or(kw::Empty);
|
||||
if doc_keyword == kw::Empty {
|
||||
self.doc_attr_str_error(meta, "keyword");
|
||||
|
@ -933,10 +940,10 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if !rustc_lexer::is_ident(doc_keyword.as_str()) {
|
||||
self.dcx().emit_err(errors::DocKeywordInvalidIdent {
|
||||
if !is_doc_keyword(doc_keyword) {
|
||||
self.dcx().emit_err(errors::DocKeywordNotKeyword {
|
||||
span: meta.name_value_literal_span().unwrap_or_else(|| meta.span()),
|
||||
doc_keyword,
|
||||
keyword: doc_keyword,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,6 +215,15 @@ pub(crate) struct DocKeywordEmptyMod {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_doc_keyword_not_keyword)]
|
||||
#[help]
|
||||
pub(crate) struct DocKeywordNotKeyword {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub keyword: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_doc_keyword_not_mod)]
|
||||
pub(crate) struct DocKeywordNotMod {
|
||||
|
@ -222,14 +231,6 @@ pub(crate) struct DocKeywordNotMod {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_doc_keyword_invalid_ident)]
|
||||
pub(crate) struct DocKeywordInvalidIdent {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub doc_keyword: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_doc_fake_variadic_not_valid)]
|
||||
pub(crate) struct DocFakeVariadicNotValid {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue