Skip to content

Commit 671616a

Browse files
authored
Rollup merge of rust-lang#143303 - Kivooeo:tf28, r=tgross35
`tests/ui`: A New Order [28/28] FINAL PART > [!NOTE] > > Intermediate commits are intended to help review, but will be squashed prior to merge. Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang#133895. r? `@tgross35`
2 parents ea6c761 + 259512e commit 671616a

39 files changed

+262
-197
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
6+
//@ run-pass
7+
8+
enum Void {}
9+
10+
fn main() {
11+
let _ = std::rc::Weak::<Void>::new();
12+
let _ = std::sync::Weak::<Void>::new();
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! Test that argument names starting with `_` are usable.
2+
3+
//@ run-pass
4+
5+
fn good(_a: &isize) {}
6+
7+
fn called<F>(_f: F)
8+
where
9+
F: FnOnce(&isize),
10+
{
11+
}
12+
13+
pub fn main() {
14+
called(good);
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Checks borrow after move error when using `self` consuming method with struct update syntax.
2+
3+
struct Mine {
4+
test: String,
5+
other_val: isize,
6+
}
7+
8+
impl Mine {
9+
fn make_string_bar(mut self) -> Mine {
10+
self.test = "Bar".to_string();
11+
self
12+
}
13+
}
14+
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() };
18+
println!("{}", start.test); //~ ERROR borrow of moved value: `start`
19+
}

tests/ui/walk-struct-literal-with.stderr renamed to 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/unused-move-capture.rs renamed to 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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>.
6+
7+
//@ run-pass
8+
9+
pub fn main() {
10+
let y: Box<_> = Box::new(1);
11+
drop(y);
12+
}

tests/ui/wrong-hashset-issue-42918.rs renamed to 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();

0 commit comments

Comments
 (0)