Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/closures/box-generic-closure.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions tests/ui/issues/issue-51154.rs

This file was deleted.

13 changes: 0 additions & 13 deletions tests/ui/issues/issue-52717.rs

This file was deleted.

12 changes: 0 additions & 12 deletions tests/ui/issues/issue-52717.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/pattern/match-enum-struct-variant-field-missing.rs
Original file line number Diff line number Diff line change
@@ -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}");
}
}
}
12 changes: 12 additions & 0 deletions tests/ui/pattern/match-enum-struct-variant-field-missing.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading