mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
Add run-rustfix to mem_replace test
This commit is contained in:
parent
9ff821a7e8
commit
95f2a9dbfc
21
tests/ui/mem_replace.fixed
Normal file
21
tests/ui/mem_replace.fixed
Normal 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();
|
||||
}
|
@ -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;
|
||||
|
@ -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()`
|
||||
|
Loading…
Reference in New Issue
Block a user