Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wfcheck: resolve the type-vars in AdtField types #62240

Merged
merged 1 commit into from
Jul 4, 2019
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
2 changes: 2 additions & 0 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id_from_hir_id(field.hir_id));
let field_ty = self.normalize_associated_types_in(field.span,
&field_ty);
let field_ty = self.resolve_vars_if_possible(&field_ty);
debug!("non_enum_variant: type of field {:?} is {:?}", field, field_ty);
AdtField { ty: field_ty, span: field.span }
})
.collect();
Expand Down
21 changes: 21 additions & 0 deletions src/test/run-pass/packed/packed-with-inference-vars-issue-61402.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// If a struct is packed and its last field has drop glue, then that
// field needs to be Sized (to allow it to be destroyed out-of-place).
//
// This is checked by the compiler during wfcheck. That check used
// to have problems with associated types in the last field - test
// that this doesn't ICE.

#![allow(unused_imports, dead_code)]

pub struct S;

pub trait Trait<R> { type Assoc; }

impl<X> Trait<X> for S { type Assoc = X; }

#[repr(C, packed)]
struct PackedAssocSized {
pos: Box<<S as Trait<usize>>::Assoc>,
}

fn main() { println!("Hello, world!"); }