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
This commit is contained in:
parent
6840234806
commit
941a17a15a
13 changed files with 56 additions and 39 deletions
|
|
@ -1,3 +1,7 @@
|
|||
//! Regression test for issue <https://github.com/rust-lang/rust/issues/51515>
|
||||
//! Test that assigning through an immutable reference (`&`) correctly yields
|
||||
//! an assignment error (E0594) and suggests using a mutable reference.
|
||||
|
||||
fn main() {
|
||||
let foo = &16;
|
||||
//~^ HELP consider changing this to be a mutable reference
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
|
||||
--> $DIR/issue-51515.rs:4:5
|
||||
--> $DIR/assignment-to-immutable-ref.rs:8:5
|
||||
|
|
||||
LL | *foo = 32;
|
||||
| ^^^^^^^^^ `foo` is a `&` reference, so it cannot be written to
|
||||
|
|
@ -10,7 +10,7 @@ LL | let foo = &mut 16;
|
|||
| +++
|
||||
|
||||
error[E0594]: cannot assign to `*bar`, which is behind a `&` reference
|
||||
--> $DIR/issue-51515.rs:8:5
|
||||
--> $DIR/assignment-to-immutable-ref.rs:12:5
|
||||
|
|
||||
LL | *bar = 64;
|
||||
| ^^^^^^^^^ `bar` is a `&` reference, so it cannot be written to
|
||||
10
tests/ui/closures/box-generic-closure.rs
Normal file
10
tests/ui/closures/box-generic-closure.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//! Regression test for issue <https://github.com/rust-lang/rust/issues/51154>
|
||||
//! Test that anonymous closure types cannot be coerced to a generic type
|
||||
//! parameter (F: FnMut()) when trying to box them.
|
||||
|
||||
fn foo<F: FnMut()>() {
|
||||
let _: Box<F> = Box::new(|| ());
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-51154.rs:2:30
|
||||
--> $DIR/box-generic-closure.rs:6:30
|
||||
|
|
||||
LL | fn foo<F: FnMut()>() {
|
||||
| - expected this type parameter
|
||||
|
|
@ -9,7 +9,7 @@ LL | let _: Box<F> = Box::new(|| ());
|
|||
| arguments to this function are incorrect
|
||||
|
|
||||
= note: expected type parameter `F`
|
||||
found closure `{closure@$DIR/issue-51154.rs:2:30: 2:32}`
|
||||
found closure `{closure@$DIR/box-generic-closure.rs:6:30: 6:32}`
|
||||
= help: every closure has a distinct type and so could not always match the caller-chosen type of parameter `F`
|
||||
note: associated function defined here
|
||||
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
fn foo<F: FnMut()>() {
|
||||
let _: Box<F> = Box::new(|| ());
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
enum A {
|
||||
A {
|
||||
foo: usize,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = A::A { foo: 3 };
|
||||
match x {
|
||||
A::A { fob } => { println!("{}", fob); }
|
||||
//~^ ERROR does not have a field named `fob`
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
error[E0026]: variant `A::A` does not have a field named `fob`
|
||||
--> $DIR/issue-52717.rs:10:12
|
||||
|
|
||||
LL | A::A { fob } => { println!("{}", fob); }
|
||||
| ^^^
|
||||
| |
|
||||
| variant `A::A` does not have this field
|
||||
| help: a field with a similar name exists: `foo`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0026`.
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
//! Regression test for issue https://github.com/rust-lang/rust/issues/53348
|
||||
//! Test that attempting to assign a dereferenced `String` (which is `str`)
|
||||
//! to a `String` variable correctly results in a mismatched types error (E0308).
|
||||
|
||||
fn main() {
|
||||
let mut v = vec!["hello", "this", "is", "a", "test"];
|
||||
|
||||
let v2 = Vec::new();
|
||||
|
||||
v.into_iter().map(|s|s.to_owned()).collect::<Vec<_>>();
|
||||
v.into_iter().map(|s| s.to_owned()).collect::<Vec<_>>();
|
||||
|
||||
let mut a = String::new(); //~ NOTE expected due to this value
|
||||
for i in v {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-53348.rs:10:13
|
||||
--> $DIR/assign-deref-string-to-string.rs:14:13
|
||||
|
|
||||
LL | let mut a = String::new();
|
||||
| ------------- expected due to this value
|
||||
17
tests/ui/pattern/match-enum-struct-variant-field-missing.rs
Normal file
17
tests/ui/pattern/match-enum-struct-variant-field-missing.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//! Regression test for issue <https://github.com/rust-lang/rust/issues/52717>
|
||||
//! Test that matching an enum struct variant with a missing or incorrect field name
|
||||
//! correctly yields a "does not have a field named" error.
|
||||
|
||||
enum A {
|
||||
A { foo: usize },
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = A::A { foo: 3 };
|
||||
match x {
|
||||
A::A { fob } => {
|
||||
//~^ ERROR does not have a field named `fob`
|
||||
println!("{fob}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0026]: variant `A::A` does not have a field named `fob`
|
||||
--> $DIR/match-enum-struct-variant-field-missing.rs:12:16
|
||||
|
|
||||
LL | A::A { fob } => {
|
||||
| ^^^
|
||||
| |
|
||||
| variant `A::A` does not have this field
|
||||
| help: a field with a similar name exists: `foo`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0026`.
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
// issue 53300
|
||||
//! Regression test for issue <https://github.com/rust-lang/rust/issues/53300>
|
||||
//! Tests that an undefined type (Wrapper) used with impl Trait correctly gives E0412.
|
||||
|
||||
pub trait A {
|
||||
fn add(&self, b: i32) -> i32;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0412]: cannot find type `Wrapper` in this scope
|
||||
--> $DIR/issue-53300.rs:7:18
|
||||
--> $DIR/cannot-find-wrapper-with-impl-trait.rs:8:18
|
||||
|
|
||||
LL | fn addition() -> Wrapper<impl A> {}
|
||||
| ^^^^^^^ not found in this scope
|
||||
Loading…
Add table
Add a link
Reference in a new issue