Skip to content

Commit 76342b6

Browse files
committed
Auto merge of #4788 - Manishearth:rustup, r=flip1995
Rustup to rustc 1.40.0-nightly (7a76fe7 2019-11-07) changelog: none r? @phansch @oli-obk
2 parents 43a3796 + 60f8acf commit 76342b6

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

clippy_lints/src/attrs.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc::ty;
1515
use rustc::{declare_lint_pass, declare_tool_lint};
1616
use rustc_errors::Applicability;
1717
use semver::Version;
18-
use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
18+
use syntax::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
1919
use syntax::source_map::Span;
2020
use syntax_pos::symbol::Symbol;
2121

@@ -417,11 +417,14 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
417417
}
418418

419419
for attr in attrs {
420-
if attr.is_sugared_doc {
421-
return;
422-
}
420+
let attr_item = if let AttrKind::Normal(ref attr) = attr.kind {
421+
attr
422+
} else {
423+
continue;
424+
};
425+
423426
if attr.style == AttrStyle::Outer {
424-
if attr.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
427+
if attr_item.tokens.is_empty() || !is_present_in_source(cx, attr.span) {
425428
return;
426429
}
427430

clippy_lints/src/doc.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
66
use rustc::{declare_tool_lint, impl_lint_pass};
77
use rustc_data_structures::fx::FxHashSet;
88
use std::ops::Range;
9-
use syntax::ast::Attribute;
9+
use syntax::ast::{AttrKind, Attribute};
1010
use syntax::source_map::{BytePos, Span};
1111
use syntax_pos::Pos;
1212
use url::Url;
@@ -247,13 +247,11 @@ pub fn check_attrs<'a>(cx: &LateContext<'_, '_>, valid_idents: &FxHashSet<String
247247
let mut spans = vec![];
248248

249249
for attr in attrs {
250-
if attr.is_sugared_doc {
251-
if let Some(ref current) = attr.value_str() {
252-
let current = current.to_string();
253-
let (current, current_spans) = strip_doc_comment_decoration(&current, attr.span);
254-
spans.extend_from_slice(&current_spans);
255-
doc.push_str(&current);
256-
}
250+
if let AttrKind::DocComment(ref current) = attr.kind {
251+
let current = current.to_string();
252+
let (current, current_spans) = strip_doc_comment_decoration(&current, attr.span);
253+
spans.extend_from_slice(&current_spans);
254+
doc.push_str(&current);
257255
} else if attr.check_name(sym!(doc)) {
258256
// ignore mix of sugared and non-sugared doc
259257
return true; // don't trigger the safety check

clippy_lints/src/main_recursion.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc::hir::{Crate, Expr, ExprKind, QPath};
22
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
33
use rustc::{declare_tool_lint, impl_lint_pass};
4+
use syntax::ast::AttrKind;
45
use syntax::symbol::sym;
56

67
use crate::utils::{is_entrypoint_fn, snippet, span_help_and_lint};
@@ -34,7 +35,13 @@ impl_lint_pass!(MainRecursion => [MAIN_RECURSION]);
3435

3536
impl LateLintPass<'_, '_> for MainRecursion {
3637
fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) {
37-
self.has_no_std_attr = krate.attrs.iter().any(|attr| attr.path == sym::no_std);
38+
self.has_no_std_attr = krate.attrs.iter().any(|attr| {
39+
if let AttrKind::Normal(ref attr) = attr.kind {
40+
attr.path == sym::no_std
41+
} else {
42+
false
43+
}
44+
});
3845
}
3946

4047
fn check_expr_post(&mut self, cx: &LateContext<'_, '_>, expr: &Expr) {

clippy_lints/src/utils/attrs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ 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 {
61+
attr
62+
} else {
63+
return false;
64+
};
6065
let attr_segments = &attr.path.segments;
6166
if attr_segments.len() == 2 && attr_segments[0].ident.to_string() == "clippy" {
6267
if let Some(deprecation_status) =

0 commit comments

Comments
 (0)