Skip to content

Commit 95f2a9d

Browse files
committed
Add run-rustfix to mem_replace test
1 parent 9ff821a commit 95f2a9d

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

tests/ui/mem_replace.fixed

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014-2019 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution.
3+
//
4+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7+
// option. This file may not be copied, modified, or distributed
8+
// except according to those terms.
9+
10+
// run-rustfix
11+
#![allow(unused_imports)]
12+
#![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)]
13+
14+
use std::mem;
15+
16+
fn main() {
17+
let mut an_option = Some(1);
18+
let _ = an_option.take();
19+
let an_option = &mut Some(1);
20+
let _ = an_option.take();
21+
}

tests/ui/mem_replace.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10+
// run-rustfix
11+
#![allow(unused_imports)]
1012
#![warn(clippy::all, clippy::style, clippy::mem_replace_option_with_none)]
1113

1214
use std::mem;

tests/ui/mem_replace.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error: replacing an `Option` with `None`
2-
--> $DIR/mem_replace.rs:16:13
2+
--> $DIR/mem_replace.rs:18:13
33
|
44
LL | let _ = mem::replace(&mut an_option, None);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`
66
|
77
= note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings`
88

99
error: replacing an `Option` with `None`
10-
--> $DIR/mem_replace.rs:18:13
10+
--> $DIR/mem_replace.rs:20:13
1111
|
1212
LL | let _ = mem::replace(an_option, None);
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`

0 commit comments

Comments
 (0)