Skip to content

Commit 941a17a

Browse files
committed
Relocate 5 tests from tests/ui/issues
Relocate issues/issue-51154.rs to closures/box-generic-closure.rs Relocate issues/issue-51515.rs to borrowck/assignment-to-immutable-ref.rs Relocate issues/issue-53348.rs to mismatched_types/deref-string-assign.rs Relocate issues/issue-52717.rs to pattern/match-enum-struct-variant-field-missing.rs Relocate issues/issue-53300.rs to type/cannot-find-wrapper-with-impl-trait.rs
1 parent 6840234 commit 941a17a

13 files changed

+56
-39
lines changed

tests/ui/issues/issue-51515.rs renamed to tests/ui/borrowck/assignment-to-immutable-ref.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Regression test for issue <https://github.com/rust-lang/rust/issues/51515>
2+
//! Test that assigning through an immutable reference (`&`) correctly yields
3+
//! an assignment error (E0594) and suggests using a mutable reference.
4+
15
fn main() {
26
let foo = &16;
37
//~^ HELP consider changing this to be a mutable reference

tests/ui/issues/issue-51515.stderr renamed to tests/ui/borrowck/assignment-to-immutable-ref.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
2-
--> $DIR/issue-51515.rs:4:5
2+
--> $DIR/assignment-to-immutable-ref.rs:8:5
33
|
44
LL | *foo = 32;
55
| ^^^^^^^^^ `foo` is a `&` reference, so it cannot be written to
@@ -10,7 +10,7 @@ LL | let foo = &mut 16;
1010
| +++
1111

1212
error[E0594]: cannot assign to `*bar`, which is behind a `&` reference
13-
--> $DIR/issue-51515.rs:8:5
13+
--> $DIR/assignment-to-immutable-ref.rs:12:5
1414
|
1515
LL | *bar = 64;
1616
| ^^^^^^^^^ `bar` is a `&` reference, so it cannot be written to
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Regression test for issue <https://github.com/rust-lang/rust/issues/51154>
2+
//! Test that anonymous closure types cannot be coerced to a generic type
3+
//! parameter (F: FnMut()) when trying to box them.
4+
5+
fn foo<F: FnMut()>() {
6+
let _: Box<F> = Box::new(|| ());
7+
//~^ ERROR mismatched types
8+
}
9+
10+
fn main() {}

tests/ui/issues/issue-51154.stderr renamed to tests/ui/closures/box-generic-closure.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-51154.rs:2:30
2+
--> $DIR/box-generic-closure.rs:6:30
33
|
44
LL | fn foo<F: FnMut()>() {
55
| - expected this type parameter
@@ -9,7 +9,7 @@ LL | let _: Box<F> = Box::new(|| ());
99
| arguments to this function are incorrect
1010
|
1111
= note: expected type parameter `F`
12-
found closure `{closure@$DIR/issue-51154.rs:2:30: 2:32}`
12+
found closure `{closure@$DIR/box-generic-closure.rs:6:30: 6:32}`
1313
= help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F`
1414
note: associated function defined here
1515
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL

tests/ui/issues/issue-51154.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/issues/issue-52717.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ui/issues/issue-52717.stderr

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/ui/issues/issue-53348.rs renamed to tests/ui/mismatched_types/assign-deref-string-to-string.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
//! Regression test for issue https://github.com/rust-lang/rust/issues/53348
2+
//! Test that attempting to assign a dereferenced `String` (which is `str`)
3+
//! to a `String` variable correctly results in a mismatched types error (E0308).
4+
15
fn main() {
26
let mut v = vec!["hello", "this", "is", "a", "test"];
37

48
let v2 = Vec::new();
59

6-
v.into_iter().map(|s|s.to_owned()).collect::<Vec<_>>();
10+
v.into_iter().map(|s| s.to_owned()).collect::<Vec<_>>();
711

812
let mut a = String::new(); //~ NOTE expected due to this value
913
for i in v {

tests/ui/issues/issue-53348.stderr renamed to tests/ui/mismatched_types/assign-deref-string-to-string.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-53348.rs:10:13
2+
--> $DIR/assign-deref-string-to-string.rs:14:13
33
|
44
LL | let mut a = String::new();
55
| ------------- expected due to this value
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Regression test for issue <https://github.com/rust-lang/rust/issues/52717>
2+
//! Test that matching an enum struct variant with a missing or incorrect field name
3+
//! correctly yields a "does not have a field named" error.
4+
5+
enum A {
6+
A { foo: usize },
7+
}
8+
9+
fn main() {
10+
let x = A::A { foo: 3 };
11+
match x {
12+
A::A { fob } => {
13+
//~^ ERROR does not have a field named `fob`
14+
println!("{fob}");
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)