summaryrefslogtreecommitdiffstats
path: root/src/test/ui/structs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/structs')
-rw-r--r--src/test/ui/structs/struct-record-suggestion.fixed24
-rw-r--r--src/test/ui/structs/struct-record-suggestion.rs24
-rw-r--r--src/test/ui/structs/struct-record-suggestion.stderr23
3 files changed, 60 insertions, 11 deletions
diff --git a/src/test/ui/structs/struct-record-suggestion.fixed b/src/test/ui/structs/struct-record-suggestion.fixed
index 48144cd1c..49e38b196 100644
--- a/src/test/ui/structs/struct-record-suggestion.fixed
+++ b/src/test/ui/structs/struct-record-suggestion.fixed
@@ -6,11 +6,29 @@ struct A {
d: usize,
}
-fn main() {
- let q = A { c: 5, .. Default::default() };
+fn a() {
+ let q = A { c: 5,..Default::default() };
//~^ ERROR mismatched types
//~| ERROR missing fields
//~| HELP separate the last named field with a comma
- let r = A { c: 5, .. Default::default() };
+ let r = A { c: 5, ..Default::default() };
assert_eq!(q, r);
}
+
+#[derive(Debug, Default, Eq, PartialEq)]
+struct B {
+ b: u32,
+}
+
+fn b() {
+ let q = B { b: 1,..Default::default() };
+ //~^ ERROR mismatched types
+ //~| HELP separate the last named field with a comma
+ let r = B { b: 1 };
+ assert_eq!(q, r);
+}
+
+fn main() {
+ a();
+ b();
+}
diff --git a/src/test/ui/structs/struct-record-suggestion.rs b/src/test/ui/structs/struct-record-suggestion.rs
index 6d169d5c6..901f310c8 100644
--- a/src/test/ui/structs/struct-record-suggestion.rs
+++ b/src/test/ui/structs/struct-record-suggestion.rs
@@ -6,11 +6,29 @@ struct A {
d: usize,
}
-fn main() {
- let q = A { c: 5 .. Default::default() };
+fn a() {
+ let q = A { c: 5..Default::default() };
//~^ ERROR mismatched types
//~| ERROR missing fields
//~| HELP separate the last named field with a comma
- let r = A { c: 5, .. Default::default() };
+ let r = A { c: 5, ..Default::default() };
assert_eq!(q, r);
}
+
+#[derive(Debug, Default, Eq, PartialEq)]
+struct B {
+ b: u32,
+}
+
+fn b() {
+ let q = B { b: 1..Default::default() };
+ //~^ ERROR mismatched types
+ //~| HELP separate the last named field with a comma
+ let r = B { b: 1 };
+ assert_eq!(q, r);
+}
+
+fn main() {
+ a();
+ b();
+}
diff --git a/src/test/ui/structs/struct-record-suggestion.stderr b/src/test/ui/structs/struct-record-suggestion.stderr
index e5bd03117..66e9f021e 100644
--- a/src/test/ui/structs/struct-record-suggestion.stderr
+++ b/src/test/ui/structs/struct-record-suggestion.stderr
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/struct-record-suggestion.rs:10:20
|
-LL | let q = A { c: 5 .. Default::default() };
- | ^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `std::ops::Range`
+LL | let q = A { c: 5..Default::default() };
+ | ^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found struct `std::ops::Range`
|
= note: expected type `u64`
found struct `std::ops::Range<{integer}>`
@@ -10,15 +10,28 @@ LL | let q = A { c: 5 .. Default::default() };
error[E0063]: missing fields `b` and `d` in initializer of `A`
--> $DIR/struct-record-suggestion.rs:10:13
|
-LL | let q = A { c: 5 .. Default::default() };
+LL | let q = A { c: 5..Default::default() };
| ^ missing `b` and `d`
|
help: to set the remaining fields from `Default::default()`, separate the last named field with a comma
|
-LL | let q = A { c: 5, .. Default::default() };
+LL | let q = A { c: 5,..Default::default() };
| +
-error: aborting due to 2 previous errors
+error[E0308]: mismatched types
+ --> $DIR/struct-record-suggestion.rs:24:20
+ |
+LL | let q = B { b: 1..Default::default() };
+ | ^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found struct `std::ops::Range`
+ |
+ = note: expected type `u32`
+ found struct `std::ops::Range<{integer}>`
+help: to set the remaining fields from `Default::default()`, separate the last named field with a comma
+ |
+LL | let q = B { b: 1,..Default::default() };
+ | +
+
+error: aborting due to 3 previous errors
Some errors have detailed explanations: E0063, E0308.
For more information about an error, try `rustc --explain E0063`.