Skip to content

Commit 66138d1

Browse files
committed
Rustup to rustc 1.40.0-nightly (7a76fe7 2019-11-07)
1 parent 865f5c7 commit 66138d1

File tree

7 files changed

+55
-41
lines changed

7 files changed

+55
-41
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) =

tests/ui/functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::all)]
2-
#![allow(dead_code)]
2+
#![allow(dead_code, improper_ctypes)]
33
#![allow(unused_unsafe, clippy::missing_safety_doc)]
44

55
// TOO_MANY_ARGUMENTS

tests/ui/needless_pass_by_value.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(clippy::needless_pass_by_value)]
22
#![allow(
33
dead_code,
4+
improper_ctypes,
45
clippy::single_match,
56
clippy::redundant_pattern_matching,
67
clippy::many_single_char_names,

tests/ui/needless_pass_by_value.stderr

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
error: this argument is passed by value, but not consumed in the function body
2-
--> $DIR/needless_pass_by_value.rs:17:23
2+
--> $DIR/needless_pass_by_value.rs:18:23
33
|
44
LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
55
| ^^^^^^ help: consider changing the type to: `&[T]`
66
|
77
= note: `-D clippy::needless-pass-by-value` implied by `-D warnings`
88

99
error: this argument is passed by value, but not consumed in the function body
10-
--> $DIR/needless_pass_by_value.rs:31:11
10+
--> $DIR/needless_pass_by_value.rs:32:11
1111
|
1212
LL | fn bar(x: String, y: Wrapper) {
1313
| ^^^^^^ help: consider changing the type to: `&str`
1414

1515
error: this argument is passed by value, but not consumed in the function body
16-
--> $DIR/needless_pass_by_value.rs:31:22
16+
--> $DIR/needless_pass_by_value.rs:32:22
1717
|
1818
LL | fn bar(x: String, y: Wrapper) {
1919
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
2020

2121
error: this argument is passed by value, but not consumed in the function body
22-
--> $DIR/needless_pass_by_value.rs:37:71
22+
--> $DIR/needless_pass_by_value.rs:38:71
2323
|
2424
LL | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, V>(t: T, u: U, v: V) {
2525
| ^ help: consider taking a reference instead: `&V`
2626

2727
error: this argument is passed by value, but not consumed in the function body
28-
--> $DIR/needless_pass_by_value.rs:49:18
28+
--> $DIR/needless_pass_by_value.rs:50:18
2929
|
3030
LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) {
3131
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option<Option<String>>`
3232

3333
error: this argument is passed by value, but not consumed in the function body
34-
--> $DIR/needless_pass_by_value.rs:62:24
34+
--> $DIR/needless_pass_by_value.rs:63:24
3535
|
3636
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
3737
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
3838

3939
error: this argument is passed by value, but not consumed in the function body
40-
--> $DIR/needless_pass_by_value.rs:62:36
40+
--> $DIR/needless_pass_by_value.rs:63:36
4141
|
4242
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
4343
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
4444

4545
error: this argument is passed by value, but not consumed in the function body
46-
--> $DIR/needless_pass_by_value.rs:78:49
46+
--> $DIR/needless_pass_by_value.rs:79:49
4747
|
4848
LL | fn test_blanket_ref<T: Foo, S: Serialize>(_foo: T, _serializable: S) {}
4949
| ^ help: consider taking a reference instead: `&T`
5050

5151
error: this argument is passed by value, but not consumed in the function body
52-
--> $DIR/needless_pass_by_value.rs:80:18
52+
--> $DIR/needless_pass_by_value.rs:81:18
5353
|
5454
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
5555
| ^^^^^^ help: consider taking a reference instead: `&String`
5656

5757
error: this argument is passed by value, but not consumed in the function body
58-
--> $DIR/needless_pass_by_value.rs:80:29
58+
--> $DIR/needless_pass_by_value.rs:81:29
5959
|
6060
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
6161
| ^^^^^^
@@ -70,13 +70,13 @@ LL | let _ = t.to_string();
7070
| ^^^^^^^^^^^^^
7171

7272
error: this argument is passed by value, but not consumed in the function body
73-
--> $DIR/needless_pass_by_value.rs:80:40
73+
--> $DIR/needless_pass_by_value.rs:81:40
7474
|
7575
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
7676
| ^^^^^^^^ help: consider taking a reference instead: `&Vec<i32>`
7777

7878
error: this argument is passed by value, but not consumed in the function body
79-
--> $DIR/needless_pass_by_value.rs:80:53
79+
--> $DIR/needless_pass_by_value.rs:81:53
8080
|
8181
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
8282
| ^^^^^^^^
@@ -91,85 +91,85 @@ LL | let _ = v.to_owned();
9191
| ^^^^^^^^^^^^
9292

9393
error: this argument is passed by value, but not consumed in the function body
94-
--> $DIR/needless_pass_by_value.rs:93:12
94+
--> $DIR/needless_pass_by_value.rs:94:12
9595
|
9696
LL | s: String,
9797
| ^^^^^^ help: consider changing the type to: `&str`
9898

9999
error: this argument is passed by value, but not consumed in the function body
100-
--> $DIR/needless_pass_by_value.rs:94:12
100+
--> $DIR/needless_pass_by_value.rs:95:12
101101
|
102102
LL | t: String,
103103
| ^^^^^^ help: consider taking a reference instead: `&String`
104104

105105
error: this argument is passed by value, but not consumed in the function body
106-
--> $DIR/needless_pass_by_value.rs:103:23
106+
--> $DIR/needless_pass_by_value.rs:104:23
107107
|
108108
LL | fn baz(&self, _u: U, _s: Self) {}
109109
| ^ help: consider taking a reference instead: `&U`
110110

111111
error: this argument is passed by value, but not consumed in the function body
112-
--> $DIR/needless_pass_by_value.rs:103:30
112+
--> $DIR/needless_pass_by_value.rs:104:30
113113
|
114114
LL | fn baz(&self, _u: U, _s: Self) {}
115115
| ^^^^ help: consider taking a reference instead: `&Self`
116116

117117
error: this argument is passed by value, but not consumed in the function body
118-
--> $DIR/needless_pass_by_value.rs:125:24
118+
--> $DIR/needless_pass_by_value.rs:126:24
119119
|
120120
LL | fn bar_copy(x: u32, y: CopyWrapper) {
121121
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
122122
|
123123
help: consider marking this type as Copy
124-
--> $DIR/needless_pass_by_value.rs:123:1
124+
--> $DIR/needless_pass_by_value.rs:124:1
125125
|
126126
LL | struct CopyWrapper(u32);
127127
| ^^^^^^^^^^^^^^^^^^^^^^^^
128128

129129
error: this argument is passed by value, but not consumed in the function body
130-
--> $DIR/needless_pass_by_value.rs:131:29
130+
--> $DIR/needless_pass_by_value.rs:132:29
131131
|
132132
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
133133
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
134134
|
135135
help: consider marking this type as Copy
136-
--> $DIR/needless_pass_by_value.rs:123:1
136+
--> $DIR/needless_pass_by_value.rs:124:1
137137
|
138138
LL | struct CopyWrapper(u32);
139139
| ^^^^^^^^^^^^^^^^^^^^^^^^
140140

141141
error: this argument is passed by value, but not consumed in the function body
142-
--> $DIR/needless_pass_by_value.rs:131:45
142+
--> $DIR/needless_pass_by_value.rs:132:45
143143
|
144144
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
145145
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
146146
|
147147
help: consider marking this type as Copy
148-
--> $DIR/needless_pass_by_value.rs:123:1
148+
--> $DIR/needless_pass_by_value.rs:124:1
149149
|
150150
LL | struct CopyWrapper(u32);
151151
| ^^^^^^^^^^^^^^^^^^^^^^^^
152152

153153
error: this argument is passed by value, but not consumed in the function body
154-
--> $DIR/needless_pass_by_value.rs:131:61
154+
--> $DIR/needless_pass_by_value.rs:132:61
155155
|
156156
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
157157
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
158158
|
159159
help: consider marking this type as Copy
160-
--> $DIR/needless_pass_by_value.rs:123:1
160+
--> $DIR/needless_pass_by_value.rs:124:1
161161
|
162162
LL | struct CopyWrapper(u32);
163163
| ^^^^^^^^^^^^^^^^^^^^^^^^
164164

165165
error: this argument is passed by value, but not consumed in the function body
166-
--> $DIR/needless_pass_by_value.rs:143:40
166+
--> $DIR/needless_pass_by_value.rs:144:40
167167
|
168168
LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
169169
| ^ help: consider taking a reference instead: `&S`
170170

171171
error: this argument is passed by value, but not consumed in the function body
172-
--> $DIR/needless_pass_by_value.rs:148:20
172+
--> $DIR/needless_pass_by_value.rs:149:20
173173
|
174174
LL | fn more_fun(_item: impl Club<'static, i32>) {}
175175
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>`

0 commit comments

Comments
 (0)