Skip to content

Commit 4652b14

Browse files
committed
Adjust artificial-block.rs
- Document `artificial-block.rs` - Move `artificial-block.rs` under `tests/ui/reachable`
1 parent d734d22 commit 4652b14

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

Diff for: tests/ui/artificial-block.rs

-5
This file was deleted.

Diff for: tests/ui/reachable/artificial-block.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Check that we don't get compile errors on unreachable code after the `{ return 3; }` artificial
2+
//! block below. This test is run-pass to also exercise the codegen, but it might be possible to
3+
//! reduce to build-pass or even check-pass.
4+
//!
5+
//! This test was introduced as part of commit `a833f152baa17460e8414355e832d30d5161f8e8` which
6+
//! removes an "artificial block". See also commit `3d738e9e0634a4cd6239d1317bd7dad53be68dc8` for
7+
//! more elaboration, reproduced below (this is outdated for *today*'s rustc as of 2024-12-10, but
8+
//! is helpful to understand the original intention):
9+
//!
10+
//! > Return a fresh, unreachable context after ret, break, and cont
11+
//! >
12+
//! > This ensures we don't get compile errors on unreachable code (see
13+
//! > test/run-pass/artificial-block.rs for an example of sane code that wasn't compiling). In the
14+
//! > future, we might want to warn about non-trivial code appearing in an unreachable context,
15+
//! > and/or avoid generating unreachable code altogether (though I'm sure LLVM will weed it out as
16+
//! > well).
17+
//!
18+
//! Since then, `ret` became `return`, `int` became `isize` and `assert` became a macro.
19+
20+
//@ run-pass
21+
22+
fn f() -> isize {
23+
{
24+
return 3;
25+
}
26+
}
27+
28+
fn main() {
29+
assert_eq!(f(), 3);
30+
}

0 commit comments

Comments
 (0)