Skip to content

Commit 34457fb

Browse files
committed
Auto merge of #4388 - flip1995:rustup, r=phansch
Rustup Supersedes #4387 and #4385 This removes tests with the `try!` macro in them completely. There is no need for Clippy to support the `try!` macro, since it is deprecated now. [`StmtKind`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/enum.StmtKind.html) got a new variant [`Semi`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/enum.StmtKind.html#variant.Semi), which Just Works with the `author` lint. Nice. changelog: none
2 parents d829d9f + 87fa2d9 commit 34457fb

16 files changed

+43
-56
lines changed

clippy_lints/src/enum_clike.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
4343
if cx.tcx.data_layout.pointer_size.bits() != 64 {
4444
return;
4545
}
46-
if let ItemKind::Enum(ref def, _) = item.node {
46+
if let ItemKind::Enum(def, _) = &item.node {
4747
for var in &def.variants {
48-
let variant = &var.node;
49-
if let Some(ref anon_const) = variant.disr_expr {
48+
if let Some(anon_const) = &var.disr_expr {
5049
let param_env = ty::ParamEnv::empty();
5150
let def_id = cx.tcx.hir().body_owner_def_id(anon_const.body);
5251
let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id);

clippy_lints/src/enum_variants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl_lint_pass!(EnumVariantNames => [
123123
]);
124124

125125
fn var2str(var: &Variant) -> LocalInternedString {
126-
var.node.ident.as_str()
126+
var.ident.as_str()
127127
}
128128

129129
/// Returns the number of chars that match from the start

clippy_lints/src/large_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
8585
"large size difference between variants",
8686
|db| {
8787
if variant.fields.len() == 1 {
88-
let span = match def.variants[i].node.data {
88+
let span = match def.variants[i].data {
8989
VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, ..) => {
9090
fields[0].ty.span
9191
},

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
197197
}
198198

199199
fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, v: &'tcx hir::Variant, _: &hir::Generics) {
200-
self.check_missing_docs_attrs(cx, &v.node.attrs, v.span, "a variant");
200+
self.check_missing_docs_attrs(cx, &v.attrs, v.span, "a variant");
201201
}
202202
}

clippy_lints/src/utils/author.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Author {
9191
}
9292

9393
fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant, generics: &hir::Generics) {
94-
if !has_attr(cx.sess(), &var.node.attrs) {
94+
if !has_attr(cx.sess(), &var.attrs) {
9595
return;
9696
}
9797
prelude();

tests/ui/author/blocks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(stmt_expr_attributes)]
2+
#![allow(redundant_semicolon)]
23

34
#[rustfmt::skip]
45
fn main() {

tests/ui/author/blocks.stderr

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
error: statement with no effect
2-
--> $DIR/blocks.rs:14:5
2+
--> $DIR/blocks.rs:8:9
33
|
4-
LL | -x;
5-
| ^^^
4+
LL | ;;;;
5+
| ^^^^
66
|
77
= note: `-D clippy::no-effect` implied by `-D warnings`
88

9-
error: aborting due to previous error
9+
error: statement with no effect
10+
--> $DIR/blocks.rs:15:5
11+
|
12+
LL | -x;
13+
| ^^^
14+
15+
error: aborting due to 2 previous errors
1016

tests/ui/author/blocks.stdout

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
if_chain! {
22
if let ExprKind::Block(ref block) = expr.node;
33
if let Some(trailing_expr) = &block.expr;
4-
if block.stmts.len() == 0;
4+
if block.stmts.len() == 1;
5+
if let StmtKind::Semi(ref e, _) = block.stmts[0].node
6+
if let ExprKind::Tup(ref elements) = e.node;
7+
if elements.len() == 0;
58
then {
69
// report your lint here
710
}

tests/ui/cognitive_complexity.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,14 @@ fn try_() -> Result<i32, &'static str> {
322322

323323
#[clippy::cognitive_complexity = "0"]
324324
fn try_again() -> Result<i32, &'static str> {
325-
let _ = r#try!(Ok(42));
326-
let _ = r#try!(Ok(43));
327-
let _ = r#try!(Ok(44));
328-
let _ = r#try!(Ok(45));
329-
let _ = r#try!(Ok(46));
330-
let _ = r#try!(Ok(47));
331-
let _ = r#try!(Ok(48));
332-
let _ = r#try!(Ok(49));
325+
let _ = Ok(42)?;
326+
let _ = Ok(43)?;
327+
let _ = Ok(44)?;
328+
let _ = Ok(45)?;
329+
let _ = Ok(46)?;
330+
let _ = Ok(47)?;
331+
let _ = Ok(48)?;
332+
let _ = Ok(49)?;
333333
match 5 {
334334
5 => Ok(5),
335335
_ => return Err("bla"),

tests/ui/cognitive_complexity.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ error: the function has a cognitive complexity of 1
230230
--> $DIR/cognitive_complexity.rs:324:1
231231
|
232232
LL | / fn try_again() -> Result<i32, &'static str> {
233-
LL | | let _ = r#try!(Ok(42));
234-
LL | | let _ = r#try!(Ok(43));
235-
LL | | let _ = r#try!(Ok(44));
233+
LL | | let _ = Ok(42)?;
234+
LL | | let _ = Ok(43)?;
235+
LL | | let _ = Ok(44)?;
236236
... |
237237
LL | | }
238238
LL | | }

0 commit comments

Comments
 (0)