Fix diagnostic for matching/creating x-crate re-exported tuple structs with private fields.
The more helpful diagnostic already existed but wasn't working if the struct in question was a re-export from a different crate.
This commit is contained in:
parent
377d1a984c
commit
57fda67291
3 changed files with 42 additions and 10 deletions
|
@ -995,7 +995,20 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
// Record some extra data for better diagnostics.
|
||||
let cstore = self.r.cstore();
|
||||
match res {
|
||||
Res::Def(DefKind::Struct | DefKind::Union, def_id) => {
|
||||
Res::Def(DefKind::Struct, def_id) => {
|
||||
let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
|
||||
let ctor = cstore.ctor_def_id_and_kind_untracked(def_id);
|
||||
if let Some((ctor_def_id, ctor_kind)) = ctor {
|
||||
let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Struct, ctor_kind), ctor_def_id);
|
||||
let ctor_vis = cstore.visibility_untracked(ctor_def_id);
|
||||
let field_visibilities = cstore.struct_field_visibilities_untracked(def_id);
|
||||
self.r
|
||||
.struct_constructors
|
||||
.insert(def_id, (ctor_res, ctor_vis, field_visibilities));
|
||||
}
|
||||
self.insert_field_names(def_id, field_names);
|
||||
}
|
||||
Res::Def(DefKind::Union, def_id) => {
|
||||
let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
|
||||
self.insert_field_names(def_id, field_names);
|
||||
}
|
||||
|
@ -1007,12 +1020,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
|
|||
self.r.has_self.insert(def_id);
|
||||
}
|
||||
}
|
||||
Res::Def(DefKind::Ctor(CtorOf::Struct, ..), def_id) => {
|
||||
let parent = cstore.def_key(def_id).parent;
|
||||
if let Some(struct_def_id) = parent.map(|index| DefId { index, ..def_id }) {
|
||||
self.r.struct_constructors.insert(struct_def_id, (res, vis, vec![]));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue