Add run-rustfix to mem_replace test

This commit is contained in:
Wilco Kusee 2019-01-13 13:55:26 +01:00
parent 9ff821a7e8
commit 95f2a9dbfc
3 changed files with 25 additions and 2 deletions

View file

@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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();
}

View file

@ -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;

View file

@ -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()`