From 95f2a9dbfcaaf8b319c2743ea641b785ff4c9d2e Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Sun, 13 Jan 2019 13:55:26 +0100 Subject: [PATCH] Add run-rustfix to mem_replace test --- tests/ui/mem_replace.fixed | 21 +++++++++++++++++++++ tests/ui/mem_replace.rs | 2 ++ tests/ui/mem_replace.stderr | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/ui/mem_replace.fixed diff --git a/tests/ui/mem_replace.fixed b/tests/ui/mem_replace.fixed new file mode 100644 index 00000000000..4e47ac95d82 --- /dev/null +++ b/tests/ui/mem_replace.fixed @@ -0,0 +1,21 @@ +// Copyright 2014-2019 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-rustfix +#![allow(unused_imports)] +#![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)] + +use std::mem; + +fn main() { + let mut an_option = Some(1); + let _ = an_option.take(); + let an_option = &mut Some(1); + let _ = an_option.take(); +} diff --git a/tests/ui/mem_replace.rs b/tests/ui/mem_replace.rs index a0c340bb54b..6824ab18e7f 100644 --- a/tests/ui/mem_replace.rs +++ b/tests/ui/mem_replace.rs @@ -7,6 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// run-rustfix +#![allow(unused_imports)] #![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)] use std::mem; diff --git a/tests/ui/mem_replace.stderr b/tests/ui/mem_replace.stderr index 9092fa2ea14..791c4d71dbf 100644 --- a/tests/ui/mem_replace.stderr +++ b/tests/ui/mem_replace.stderr @@ -1,5 +1,5 @@ error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:16:13 + --> $DIR/mem_replace.rs:18:13 | LL | let _ = mem::replace(&mut an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()` @@ -7,7 +7,7 @@ LL | let _ = mem::replace(&mut an_option, None); = note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings` error: replacing an `Option` with `None` - --> $DIR/mem_replace.rs:18:13 + --> $DIR/mem_replace.rs:20:13 | LL | let _ = mem::replace(an_option, None); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`