mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Fix projection of sized field in unsized type
This commit is contained in:
parent
aab736a137
commit
ab57af4e6a
@ -196,3 +196,13 @@ fn str_wrapper_get(w: &StrWrapper) -> &str {
|
||||
fn i16_as_i8(a: i16) -> i8 {
|
||||
a as i8
|
||||
}
|
||||
|
||||
struct Unsized(u8, str);
|
||||
|
||||
fn get_sized_field_ref_from_unsized_type(u: &Unsized) -> &u8 {
|
||||
&u.0
|
||||
}
|
||||
|
||||
fn get_unsized_field_ref_from_unsized_type(u: &Unsized) -> &str {
|
||||
&u.1
|
||||
}
|
||||
|
@ -460,6 +460,12 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
|
||||
}
|
||||
CPlace::Addr(base, extra, layout) => {
|
||||
let (field_ptr, field_layout) = codegen_field(fx, base, layout, field);
|
||||
let extra = if field_layout.is_unsized() {
|
||||
assert!(extra.is_some());
|
||||
extra
|
||||
} else {
|
||||
None
|
||||
};
|
||||
CPlace::Addr(field_ptr, extra, field_layout)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user