Skip to content

Commit cfca36d

Browse files
committed
WIP: test: separate file for separate case
1 parent 92fe3a9 commit cfca36d

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

tests/ui/needless_path_ne2.fixed

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![warn(clippy::needless_path_new)]
2+
3+
use std::fs;
4+
use std::path::Path;
5+
6+
// fn foo() -> Option<&'static Path> {
7+
// // Some(...) is `ExprKind::Call`, but we don't consider it
8+
// Some(Path::new("foo.txt"))
9+
// }
10+
//
11+
fn main() {
12+
// let _: Option<&Path> = Some(Path::new("foo"));
13+
fn foo() -> Option<impl AsRef<Path>> {
14+
Some("bar.txt") //~ needless_path_new
15+
}
16+
}

tests/ui/needless_path_ne2.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![warn(clippy::needless_path_new)]
2+
3+
use std::fs;
4+
use std::path::Path;
5+
6+
fn foo() -> Option<&'static Path> {
7+
// Some(...) is `ExprKind::Call`, but we don't consider it
8+
Some(Path::new("foo.txt"))
9+
}
10+
11+
fn main() {
12+
let _: Option<&Path> = Some(Path::new("foo"));
13+
fn foo() -> Option<impl AsRef<Path>> {
14+
Some(Path::new("bar.txt")) //~ needless_path_new
15+
}
16+
}

tests/ui/needless_path_ne2.stderr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: the expression enclosed in `Path::new` implements `AsRef<Path>`
2+
--> tests/ui/needless_path_new_some.rs:14:14
3+
|
4+
LL | Some(Path::new("bar.txt"))
5+
| ^^^^^^^^^^^^^^^^^^^^ help: remove the enclosing `Path::new`: `"bar.txt"`
6+
|
7+
= note: `-D clippy::needless-path-new` implied by `-D warnings`
8+
= help: to override `-D warnings` add `#[allow(clippy::needless_path_new)]`
9+
10+
error: aborting due to 1 previous error
11+

0 commit comments

Comments
 (0)