Skip to content

Commit 259512e

Browse files
committed
cleaned up some tests
1 parent 1fb5e01 commit 259512e

26 files changed

+177
-112
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
//! Checks that `Weak` pointers can be created with an empty enum type parameter.
2+
//! And generic `Weak` handles zero-variant enums without error.
3+
//!
4+
//! Regression test for <https://github.com/rust-lang/rust/issues/48493>
5+
16
//@ run-pass
27

8+
enum Void {}
9+
310
fn main() {
4-
enum Void {}
511
let _ = std::rc::Weak::<Void>::new();
612
let _ = std::sync::Weak::<Void>::new();
713
}

tests/ui/binding/underscore-prefixed-function-argument.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
//@ run-pass
1+
//! Test that argument names starting with `_` are usable.
22
3-
fn good(_a: &isize) {
4-
}
3+
//@ run-pass
54

6-
// unnamed argument &isize is now parse x: &isize
5+
fn good(_a: &isize) {}
76

8-
fn called<F>(_f: F) where F: FnOnce(&isize) {
7+
fn called<F>(_f: F)
8+
where
9+
F: FnOnce(&isize),
10+
{
911
}
1012

1113
pub fn main() {
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
struct Mine{
1+
//! Checks borrow after move error when using `self` consuming method with struct update syntax.
2+
3+
struct Mine {
24
test: String,
3-
other_val: isize
5+
other_val: isize,
46
}
57

6-
impl Mine{
7-
fn make_string_bar(mut self) -> Mine{
8+
impl Mine {
9+
fn make_string_bar(mut self) -> Mine {
810
self.test = "Bar".to_string();
911
self
1012
}
1113
}
1214

13-
fn main(){
14-
let start = Mine{test:"Foo".to_string(), other_val:0};
15-
let end = Mine{other_val:1, ..start.make_string_bar()};
15+
fn main() {
16+
let start = Mine { test: "Foo".to_string(), other_val: 0 };
17+
let end = Mine { other_val: 1, ..start.make_string_bar() };
1618
println!("{}", start.test); //~ ERROR borrow of moved value: `start`
1719
}

tests/ui/borrowck/ownership-struct-update-moved-error.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0382]: borrow of moved value: `start`
2-
--> $DIR/walk-struct-literal-with.rs:16:20
2+
--> $DIR/ownership-struct-update-moved-error.rs:18:20
33
|
4-
LL | let start = Mine{test:"Foo".to_string(), other_val:0};
4+
LL | let start = Mine { test: "Foo".to_string(), other_val: 0 };
55
| ----- move occurs because `start` has type `Mine`, which does not implement the `Copy` trait
6-
LL | let end = Mine{other_val:1, ..start.make_string_bar()};
7-
| ----------------- `start` moved due to this method call
6+
LL | let end = Mine { other_val: 1, ..start.make_string_bar() };
7+
| ----------------- `start` moved due to this method call
88
LL | println!("{}", start.test);
99
| ^^^^^^^^^^ value borrowed here after move
1010
|
1111
note: `Mine::make_string_bar` takes ownership of the receiver `self`, which moves `start`
12-
--> $DIR/walk-struct-literal-with.rs:7:28
12+
--> $DIR/ownership-struct-update-moved-error.rs:9:28
1313
|
14-
LL | fn make_string_bar(mut self) -> Mine{
14+
LL | fn make_string_bar(mut self) -> Mine {
1515
| ^^^^
1616
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
1717

tests/ui/closures/no-capture-closure-call.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Sanity check for no capture closures
2+
13
//@ run-pass
24

35
pub fn main() {
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//@ run-pass
2-
// Issue #3878
3-
// Issue Name: Unused move causes a crash
4-
// Abstract: zero-fill to block after drop
5-
1+
//! Regression test for a crash caused by an "unsused move"
2+
//! (specifically, a variable bound to a `Box` used as a statement)
3+
//! leading to incorrect memory zero-filling after drop.
4+
//!
5+
//! Regression test for <https://github.com/rust-lang/rust/issues/3878>.
66
7-
#![allow(path_statements)]
7+
//@ run-pass
88

99
pub fn main() {
1010
let y: Box<_> = Box::new(1);
11-
y;
11+
drop(y);
1212
}

tests/ui/hashmap/hashset-enum-variant.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
//! Check for correct initialization of `HashSet` with enums. This is a regression test for a
2+
//! codegen bug that caused the `HashSet` to appear as if it contained one of each enum variant.
3+
//!
4+
//! Regression test for <https://github.com/rust-lang/rust/issues/42918>
5+
16
//@ run-pass
2-
//
3-
#![allow(dead_code)]
47
//@ compile-flags: -O
58

9+
#![allow(dead_code)]
10+
611
use std::collections::HashSet;
712

813
#[derive(PartialEq, Debug, Hash, Eq, Clone, PartialOrd, Ord)]
914
enum MyEnum {
1015
E0,
11-
1216
E1,
13-
1417
E2,
1518
E3,
1619
E4,
17-
1820
E5,
1921
E6,
2022
E7,
2123
}
2224

23-
2425
fn main() {
2526
use MyEnum::*;
2627
let s: HashSet<_> = [E4, E1].iter().cloned().collect();

tests/ui/io-checks/write-macro-error.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Tests that errors from both the writer (`Write::write`) and formatter (`Display::fmt`)
2+
//! are correctly propagated: writer errors return `Err`, formatter errors cause panics.
3+
14
//@ run-pass
25
//@ needs-unwind
36

@@ -24,7 +27,9 @@ impl Write for ErrorWriter {
2427
Err(Error::new(WRITER_ERROR, "not connected"))
2528
}
2629

27-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
30+
fn flush(&mut self) -> io::Result<()> {
31+
Ok(())
32+
}
2833
}
2934

3035
fn main() {
@@ -37,7 +42,8 @@ fn main() {
3742
let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap();
3843
assert!(
3944
err.contains("formatting trait implementation returned an error"),
40-
"unexpected panic: {}", err
45+
"unexpected panic: {}",
46+
err
4147
);
4248

4349
// Writer error when there's some string before the first `{}`
@@ -50,6 +56,7 @@ fn main() {
5056
let err = res.expect_err("formatter error did not lead to panic").downcast::<&str>().unwrap();
5157
assert!(
5258
err.contains("formatting trait implementation returned an error"),
53-
"unexpected panic: {}", err
59+
"unexpected panic: {}",
60+
err
5461
);
5562
}

tests/ui/lang-items/lang-item-unknown-definition-error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
//! Checks that compiler prevernt attempting to define an unrecognized or unknown lang item
2+
13
#![allow(unused)]
24
#![feature(lang_items)]
35

46
#[lang = "foo"]
57
fn bar() -> ! {
6-
//~^^ ERROR definition of an unknown lang item: `foo`
8+
//~^^ ERROR definition of an unknown lang item: `foo`
79
loop {}
810
}
911

tests/ui/lang-items/lang-item-unknown-definition-error.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0522]: definition of an unknown lang item: `foo`
2-
--> $DIR/unknown-language-item.rs:4:1
2+
--> $DIR/lang-item-unknown-definition-error.rs:6:1
33
|
44
LL | #[lang = "foo"]
55
| ^^^^^^^^^^^^^^^ definition of unknown lang item `foo`

0 commit comments

Comments
 (0)