Skip to content

Commit b333645

Browse files
committed
Add test with unsafe block to check rust-lang#9503 is fixed too
s
1 parent cda7547 commit b333645

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

tests/ui/needless_return.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,14 @@ fn issue9192() -> i32 {
260260
}
261261
}
262262

263+
fn issue9503(x: usize) -> isize {
264+
unsafe {
265+
if x > 12 {
266+
*(x as *const isize)
267+
} else {
268+
!*(x as *const isize)
269+
}
270+
}
271+
}
272+
263273
fn main() {}

tests/ui/needless_return.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,14 @@ fn issue9192() -> i32 {
260260
};
261261
}
262262

263+
fn issue9503(x: usize) -> isize {
264+
unsafe {
265+
if x > 12 {
266+
return *(x as *const isize);
267+
} else {
268+
return !*(x as *const isize);
269+
};
270+
};
271+
}
272+
263273
fn main() {}

tests/ui/needless_return.stderr

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,21 @@ LL | return 0;
335335
|
336336
= help: remove `return`
337337

338-
error: aborting due to 42 previous errors
338+
error: unneeded `return` statement
339+
--> $DIR/needless_return.rs:266:13
340+
|
341+
LL | return *(x as *const isize);
342+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
343+
|
344+
= help: remove `return`
345+
346+
error: unneeded `return` statement
347+
--> $DIR/needless_return.rs:268:13
348+
|
349+
LL | return !*(x as *const isize);
350+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
351+
|
352+
= help: remove `return`
353+
354+
error: aborting due to 44 previous errors
339355

0 commit comments

Comments
 (0)