Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0e9d227

Browse files
committed
Add test cases
1 parent 0335b8d commit 0e9d227

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

tests/ui/unnecessary_wrap.fixed

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,30 @@ fn func4() -> Option<i32> {
4242
Some(1)
4343
}
4444

45+
// should not be linted
46+
fn func5() -> Option<i32> {
47+
None
48+
}
49+
4550
// should be linted
46-
fn func5() -> Result<i32, ()> {
51+
fn func6() -> Result<i32, ()> {
4752
Ok(1)
4853
}
4954

5055
// should not be linted
51-
fn func6(a: bool) -> Result<i32, ()> {
56+
fn func7(a: bool) -> Result<i32, ()> {
5257
if a {
5358
Ok(1)
5459
} else {
5560
Err(())
5661
}
5762
}
5863

64+
// should not be linted
65+
fn func8(a: bool) -> Result<i32, ()> {
66+
Err(())
67+
}
68+
5969
fn main() {
6070
// method calls are not linted
6171
func1(true, true);

tests/ui/unnecessary_wrap.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,30 @@ fn func4() -> Option<i32> {
4242
Some(1)
4343
}
4444

45+
// should not be linted
46+
fn func5() -> Option<i32> {
47+
None
48+
}
49+
4550
// should be linted
46-
fn func5() -> Result<i32, ()> {
51+
fn func6() -> Result<i32, ()> {
4752
Ok(1)
4853
}
4954

5055
// should not be linted
51-
fn func6(a: bool) -> Result<i32, ()> {
56+
fn func7(a: bool) -> Result<i32, ()> {
5257
if a {
5358
Ok(1)
5459
} else {
5560
Err(())
5661
}
5762
}
5863

64+
// should not be linted
65+
fn func8(a: bool) -> Result<i32, ()> {
66+
Err(())
67+
}
68+
5969
fn main() {
6070
// method calls are not linted
6171
func1(true, true);

tests/ui/unnecessary_wrap.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ LL | 1
3636
|
3737

3838
error: this function returns unnecessarily wrapping data
39-
--> $DIR/unnecessary_wrap.rs:46:1
39+
--> $DIR/unnecessary_wrap.rs:51:1
4040
|
41-
LL | / fn func5() -> Result<i32, ()> {
41+
LL | / fn func6() -> Result<i32, ()> {
4242
LL | | Ok(1)
4343
LL | | }
4444
| |_^
4545
|
4646
help: factor this out to
4747
|
48-
LL | fn func5() -> i32 {
48+
LL | fn func6() -> i32 {
4949
LL | 1
5050
|
5151

0 commit comments

Comments
 (0)