Skip to content

Commit aad1a86

Browse files
committed
fixed structs/struct-coerce-vec-to-slice.rs
1 parent bdd2eaa commit aad1a86

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

Diff for: tests/ui/structs/struct-coerce-vec-to-slice.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
//! Regression test that a vector can be coerced to a slice
2-
//!
3-
//! Note that the purpose of this test has diverged from the original issue, which was testing a ICE
4-
//! for legacy syntax.
5-
//! Issue: https://github.com/rust-lang/rust/issues/9382
6-
//! Commit: https://github.com/rust-lang/rust/commit/920ca61871b681a278e8a3519952a4769c071034
1+
//! Regression test that ensures struct field literals can be coerced into slice and `Box` types
72
83
//@ check-pass
94

10-
struct Foo<'a> {
11-
bar: &'a [isize],
5+
struct Thing1<'a> {
6+
baz: &'a [Box<isize>],
7+
bar: Box<u64>,
8+
}
9+
10+
struct Thing2<'a> {
11+
baz: &'a [Box<isize>],
12+
bar: u64,
1213
}
1314

1415
pub fn main() {
15-
let _a = Foo { bar: &[] };
16-
let _b = Foo { bar: &Vec::new() };
16+
let _a = Thing1 { baz: &[], bar: Box::new(32) };
17+
let _b = Thing1 { baz: &Vec::new(), bar: Box::new(32) };
18+
let _c = Thing2 { baz: &[], bar: 32 };
19+
let _d = Thing2 { baz: &Vec::new(), bar: 32 };
1720
}

0 commit comments

Comments
 (0)