Skip to content

Commit 4d4c3e2

Browse files
committed
cleaned up some tests
1 parent 9a7db56 commit 4d4c3e2

13 files changed

+102
-61
lines changed
Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
1+
//! Check that output slots work correctly for both initializing and non-initializing assignments.
2+
//!
3+
//! Regression test for <https://github.com/rust-lang/rust/issues/24>.
4+
15
//@ run-pass
26

37
#![allow(dead_code)]
48
#![allow(unused_assignments)]
59
#![allow(unknown_lints)]
6-
710
#![allow(dead_assignment)]
811
#![allow(unused_variables)]
912

10-
struct A { a: isize, b: isize }
11-
struct Abox { a: Box<isize>, b: Box<isize> }
13+
struct A {
14+
a: isize,
15+
b: isize,
16+
}
1217

13-
fn ret_int_i() -> isize { 10 }
18+
struct Abox {
19+
a: Box<isize>,
20+
b: Box<isize>,
21+
}
1422

15-
fn ret_ext_i() -> Box<isize> { Box::new(10) }
23+
fn ret_int_i() -> isize {
24+
10
25+
}
1626

17-
fn ret_int_rec() -> A { A {a: 10, b: 10} }
27+
fn ret_ext_i() -> Box<isize> {
28+
Box::new(10)
29+
}
1830

19-
fn ret_ext_rec() -> Box<A> { Box::new(A {a: 10, b: 10}) }
31+
fn ret_int_rec() -> A {
32+
A { a: 10, b: 10 }
33+
}
2034

21-
fn ret_ext_mem() -> Abox { Abox {a: Box::new(10), b: Box::new(10) } }
35+
fn ret_ext_rec() -> Box<A> {
36+
Box::new(A { a: 10, b: 10 })
37+
}
38+
39+
fn ret_ext_mem() -> Abox {
40+
Abox { a: Box::new(10), b: Box::new(10) }
41+
}
2242

23-
fn ret_ext_ext_mem() -> Box<Abox> { Box::new(Abox{a: Box::new(10), b: Box::new(10) }) }
43+
fn ret_ext_ext_mem() -> Box<Abox> {
44+
Box::new(Abox { a: Box::new(10), b: Box::new(10) })
45+
}
2446

2547
pub fn main() {
2648
let mut int_i: isize;
@@ -29,40 +51,28 @@ pub fn main() {
2951
let mut ext_rec: Box<A>;
3052
let mut ext_mem: Abox;
3153
let mut ext_ext_mem: Box<Abox>;
32-
int_i = ret_int_i(); // initializing
3354

55+
int_i = ret_int_i(); // initializing
3456
int_i = ret_int_i(); // non-initializing
35-
3657
int_i = ret_int_i(); // non-initializing
3758

3859
ext_i = ret_ext_i(); // initializing
39-
4060
ext_i = ret_ext_i(); // non-initializing
41-
4261
ext_i = ret_ext_i(); // non-initializing
4362

4463
int_rec = ret_int_rec(); // initializing
45-
4664
int_rec = ret_int_rec(); // non-initializing
47-
4865
int_rec = ret_int_rec(); // non-initializing
4966

5067
ext_rec = ret_ext_rec(); // initializing
51-
5268
ext_rec = ret_ext_rec(); // non-initializing
53-
5469
ext_rec = ret_ext_rec(); // non-initializing
5570

5671
ext_mem = ret_ext_mem(); // initializing
57-
5872
ext_mem = ret_ext_mem(); // non-initializing
59-
6073
ext_mem = ret_ext_mem(); // non-initializing
6174

6275
ext_ext_mem = ret_ext_ext_mem(); // initializing
63-
6476
ext_ext_mem = ret_ext_ext_mem(); // non-initializing
65-
6677
ext_ext_mem = ret_ext_ext_mem(); // non-initializing
67-
6878
}

tests/ui/codegen/remark-flag-functionality.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1+
//! Check that `-Cremark` flag correctly emits LLVM optimization remarks.
2+
//!
3+
//! Regression test for <https://github.com/rust-lang/rust/issues/90924>.
4+
15
//@ build-pass
26
//@ ignore-pass
37
//@ revisions: all inline merge1 merge2
48
//@ compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2
5-
//
9+
610
// Check that remarks can be enabled individually or with "all":
7-
//
811
//@ [all] compile-flags: -Cremark=all
912
//@ [inline] compile-flags: -Cremark=inline
10-
//
13+
1114
// Check that values of -Cremark flag are accumulated:
12-
//
1315
//@ [merge1] compile-flags: -Cremark=all -Cremark=giraffe
1416
//@ [merge2] compile-flags: -Cremark=inline -Cremark=giraffe
17+
1518
//@ dont-check-compiler-stderr
1619
//@ dont-require-annotations: NOTE
1720

1821
#[no_mangle]
1922
#[inline(never)]
20-
pub fn f() {
21-
}
23+
pub fn f() {}
2224

2325
#[no_mangle]
2426
pub fn g() {
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1+
//! Ensure shift operations don't mutate their right operand.
2+
//!
3+
//! This test checks that expressions like `0 << b` don't accidentally
4+
//! modify the variable `b` due to codegen issues with virtual registers.
5+
//!
6+
//! Regression test for <https://github.com/rust-lang/rust/issues/152>.
7+
18
//@ run-pass
29

3-
#![allow(unused_must_use)]
4-
// Regression test for issue #152.
510
pub fn main() {
6-
let mut b: usize = 1_usize;
7-
while b < std::mem::size_of::<usize>() {
8-
0_usize << b;
9-
b <<= 1_usize;
10-
println!("{}", b);
11+
let mut b: usize = 1;
12+
while b < size_of::<usize>() {
13+
// This shift operation should not mutate `b`
14+
let _ = 0_usize << b;
15+
b <<= 1;
16+
std::hint::black_box(b);
1117
}
18+
assert_eq!(size_of::<usize>(), b);
1219
}
20+

tests/ui/codegen/sret-aliasing-rules.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//! Check that functions with sret results don't violate aliasing rules.
2+
//!
3+
//! When `foo = func(&mut foo)` is called, the compiler must avoid creating
4+
//! two mutable references to the same variable simultaneously (one for the
5+
//! parameter and one for the hidden sret out-pointer).
6+
//!
7+
//! Regression test for <https://github.com/rust-lang/rust/pull/18250>.
8+
19
//@ run-pass
210

311
#[derive(Copy, Clone)]
@@ -14,10 +22,7 @@ pub fn foo(f: &mut Foo) -> Foo {
1422
}
1523

1624
pub fn main() {
17-
let mut f = Foo {
18-
f1: 8,
19-
_f2: 9,
20-
};
25+
let mut f = Foo { f1: 8, _f2: 9 };
2126
f = foo(&mut f);
2227
assert_eq!(f.f1, 8);
2328
}

tests/ui/macros/macro-paren-span-diagnostic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
// Be smart about span of parenthesized expression in macro.
1+
//! Check that error spans in parenthesized macro expressions point to the call site.
22
3+
#[rustfmt::skip]
34
macro_rules! paren {
45
($e:expr) => (($e))
56
// ^^^^ do not highlight here
67
}
78

89
mod m {
910
pub struct S {
10-
x: i32
11+
x: i32,
1112
}
13+
1214
pub fn make() -> S {
1315
S { x: 0 }
1416
}

tests/ui/macros/macro-paren-span-diagnostic.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0616]: field `x` of struct `S` is private
2-
--> $DIR/paren-span.rs:19:14
2+
--> $DIR/macro-paren-span-diagnostic.rs:21:14
33
|
44
LL | paren!(s.x);
55
| ^ private field

tests/ui/panics/panic-during-display-formatting.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Check that panics in `Display::fmt` during printing are properly handled.
2+
13
//@ run-pass
24
//@ needs-unwind
35

@@ -18,8 +20,10 @@ impl Display for A {
1820

1921
fn main() {
2022
set_output_capture(Some(Arc::new(Mutex::new(Vec::new()))));
21-
assert!(std::panic::catch_unwind(|| {
22-
eprintln!("{}", A);
23-
})
24-
.is_err());
23+
assert!(
24+
std::panic::catch_unwind(|| {
25+
eprintln!("{}", A);
26+
})
27+
.is_err()
28+
);
2529
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
//@ build-pass (FIXME(62277): could be check-pass?)
1+
//! Check that closures can be used inside `#[panic_handler]` functions.
2+
3+
//@ check-pass
24

35
#![crate_type = "rlib"]
46
#![no_std]
57

68
#[panic_handler]
7-
pub fn panic_fmt(_: &::core::panic::PanicInfo) -> ! {
9+
pub fn panicfmt(_: &::core::panic::PanicInfo) -> ! {
810
|x: u8| x;
911
loop {}
1012
}

tests/ui/parser/ufcs-return-unused-parens.fixed

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
//! Check that UFCS syntax works correctly in return statements
2+
//! without requiring workaround parentheses.
3+
//!
4+
//! Regression test for <https://github.com/rust-lang/rust/issues/37765>.
5+
16
//@ run-pass
27
//@ run-rustfix
38

49
#![allow(dead_code)]
510
#![warn(unused_parens)]
611

7-
// Parser test for #37765
8-
912
fn with_parens<T: ToString>(arg: T) -> String {
10-
return <T as ToString>::to_string(&arg); //~WARN unnecessary parentheses around `return` value
13+
return <T as ToString>::to_string(&arg); //~ WARN unnecessary parentheses around `return` value
1114
}
1215

1316
fn no_parens<T: ToString>(arg: T) -> String {

tests/ui/parser/ufcs-return-unused-parens.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
//! Check that UFCS syntax works correctly in return statements
2+
//! without requiring workaround parentheses.
3+
//!
4+
//! Regression test for <https://github.com/rust-lang/rust/issues/37765>.
5+
16
//@ run-pass
27
//@ run-rustfix
38

49
#![allow(dead_code)]
510
#![warn(unused_parens)]
611

7-
// Parser test for #37765
8-
912
fn with_parens<T: ToString>(arg: T) -> String {
10-
return (<T as ToString>::to_string(&arg)); //~WARN unnecessary parentheses around `return` value
13+
return (<T as ToString>::to_string(&arg)); //~ WARN unnecessary parentheses around `return` value
1114
}
1215

1316
fn no_parens<T: ToString>(arg: T) -> String {

0 commit comments

Comments
 (0)