Skip to content

Commit 92ece84

Browse files
committed
Auto merge of rust-lang#78782 - petrochenkov:nodoctok, r=Aaron1011
Do not collect tokens for doc comments Doc comment is a single token and AST has all the information to re-create it precisely. Doc comments are also responsible for majority of calls to `collect_tokens` (with `num_calls == 1` and `num_calls == 0`, cc rust-lang#78736). (I also moved token collection into `fn parse_attribute` to deduplicate code a bit.) r? `@Aaron1011`
2 parents f92f8d0 + 8845f10 commit 92ece84

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ impl EarlyLintPass for EarlyAttributes {
588588

589589
fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
590590
for attr in &item.attrs {
591-
let attr_item = if let AttrKind::Normal(ref attr) = attr.kind {
591+
let attr_item = if let AttrKind::Normal(ref attr, _) = attr.kind {
592592
attr
593593
} else {
594594
return;

clippy_lints/src/utils/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
509509
l.style == r.style
510510
&& match (&l.kind, &r.kind) {
511511
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
512-
(Normal(l), Normal(r)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
512+
(Normal(l, _), Normal(r, _)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
513513
_ => false,
514514
}
515515
}

clippy_lints/src/utils/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn get_attr<'a>(
5757
name: &'static str,
5858
) -> impl Iterator<Item = &'a ast::Attribute> {
5959
attrs.iter().filter(move |attr| {
60-
let attr = if let ast::AttrKind::Normal(ref attr) = attr.kind {
60+
let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
6161
attr
6262
} else {
6363
return false;

clippy_lints/src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ pub fn is_must_use_func_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
13491349

13501350
pub fn is_no_std_crate(krate: &Crate<'_>) -> bool {
13511351
krate.item.attrs.iter().any(|attr| {
1352-
if let ast::AttrKind::Normal(ref attr) = attr.kind {
1352+
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
13531353
attr.path == symbol::sym::no_std
13541354
} else {
13551355
false

0 commit comments

Comments
 (0)