diff options
| author | Caio <c410.f3r@gmail.com> | 2021-01-31 19:46:46 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2021-01-31 19:46:46 -0300 |
| commit | 2bb4a694d1e71644f9fb770d2a0b33f80dd213f4 (patch) | |
| tree | 0b7d9fbd772bb6b303ab262c1a1f2de885e02b23 /src/test/ui/for-loop-while | |
| parent | 0e63af5da3400ace48a0345117980473fd21ad73 (diff) | |
| download | rust-2bb4a694d1e71644f9fb770d2a0b33f80dd213f4.tar.gz rust-2bb4a694d1e71644f9fb770d2a0b33f80dd213f4.zip | |
Move some tests to more reasonable directories
Diffstat (limited to 'src/test/ui/for-loop-while')
| -rw-r--r-- | src/test/ui/for-loop-while/issue-2216.rs | 24 | ||||
| -rw-r--r-- | src/test/ui/for-loop-while/issue-69841.rs | 31 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/test/ui/for-loop-while/issue-2216.rs b/src/test/ui/for-loop-while/issue-2216.rs new file mode 100644 index 00000000000..ad54107423d --- /dev/null +++ b/src/test/ui/for-loop-while/issue-2216.rs @@ -0,0 +1,24 @@ +// run-pass +#![allow(unreachable_code)] +pub fn main() { + let mut x = 0; + + 'foo: loop { + 'bar: loop { + loop { + if 1 == 2 { + break 'foo; + } + else { + break 'bar; + } + } + continue 'foo; + } + x = 42; + break; + } + + println!("{}", x); + assert_eq!(x, 42); +} diff --git a/src/test/ui/for-loop-while/issue-69841.rs b/src/test/ui/for-loop-while/issue-69841.rs new file mode 100644 index 00000000000..1aca16ca804 --- /dev/null +++ b/src/test/ui/for-loop-while/issue-69841.rs @@ -0,0 +1,31 @@ +// This is a regression test for issue rust-lang/rust#69841, which exposed an +// LLVM bug which needed a fix to be backported. + +// run-pass +// no-system-llvm + +fn main() { + let buffer = [49u8, 10]; + let mut a : u64 = 0; + 'read: loop { + for c in &buffer { + match c { + 48..=57 => { + a*= 10; + a+= *c as u64 - 48; + } + 10 => { + break 'read; + } + _ => { + unsafe { std::hint::unreachable_unchecked() }; + } + } + } + } + if a == 1 { + println!("What did you expect?"); + } else { + panic!("this should be unreachable."); + } +} |
