Skip to content

Commit a4b7da1

Browse files
committed
start using parsed doc attributes everywhere
1 parent fcd0eca commit a4b7da1

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,6 @@ impl AttributeExt for Attribute {
13461346
fn doc_str(&self) -> Option<Symbol> {
13471347
match &self {
13481348
Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1349-
Attribute::Unparsed(_) if self.has_name(sym::doc) => self.value_str(),
13501349
_ => None,
13511350
}
13521351
}
@@ -1361,9 +1360,6 @@ impl AttributeExt for Attribute {
13611360
Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
13621361
Some((*comment, *kind))
13631362
}
1364-
Attribute::Unparsed(_) if self.has_name(sym::doc) => {
1365-
self.value_str().map(|s| (s, CommentKind::Line))
1366-
}
13671363
_ => None,
13681364
}
13691365
}

compiler/rustc_lint/src/builtin.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_attr_parsing::AttributeParser;
2525
use rustc_errors::{Applicability, LintDiagnostic};
2626
use rustc_feature::GateIssue;
2727
use rustc_hir as hir;
28-
use rustc_hir::attrs::AttributeKind;
28+
use rustc_hir::attrs::{AttributeKind, DocAttribute};
2929
use rustc_hir::def::{DefKind, Res};
3030
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
3131
use rustc_hir::intravisit::FnKind as HirFnKind;
@@ -391,26 +391,16 @@ pub struct MissingDoc;
391391
impl_lint_pass!(MissingDoc => [MISSING_DOCS]);
392392

393393
fn has_doc(attr: &hir::Attribute) -> bool {
394-
if attr.is_doc_comment() {
394+
if matches!(attr, hir::Attribute::Parsed(AttributeKind::DocComment { .. })) {
395395
return true;
396396
}
397397

398-
if !attr.has_name(sym::doc) {
399-
return false;
400-
}
401-
402-
if attr.value_str().is_some() {
398+
if let hir::Attribute::Parsed(AttributeKind::Doc(d)) = attr
399+
&& matches!(d.as_ref(), DocAttribute { hidden: Some(..), .. })
400+
{
403401
return true;
404402
}
405403

406-
if let Some(list) = attr.meta_item_list() {
407-
for meta in list {
408-
if meta.has_name(sym::hidden) {
409-
return true;
410-
}
411-
}
412-
}
413-
414404
false
415405
}
416406

0 commit comments

Comments
 (0)