Skip to content

Commit

Permalink
Remove newtype for qualifs in rustc_metadata
Browse files Browse the repository at this point in the history
We have a proper type for these now, so the wrapper is no longer
necessary.
  • Loading branch information
ecstatic-morse committed Nov 15, 2019
1 parent ea95e94 commit a1135cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ impl<'a, 'tcx> CrateMetadata {
EntryKind::Const(qualif, _) |
EntryKind::AssocConst(AssocContainer::ImplDefault, qualif, _) |
EntryKind::AssocConst(AssocContainer::ImplFinal, qualif, _) => {
qualif.mir
qualif
}
_ => bug!(),
}
Expand Down
17 changes: 9 additions & 8 deletions src/librustc_metadata/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ impl EncodeContext<'tcx> {

EntryKind::AssocConst(
container,
ConstQualif { mir: Default::default() },
Default::default(),
rendered_const,
)
}
Expand Down Expand Up @@ -959,10 +959,11 @@ impl EncodeContext<'tcx> {
record!(self.per_def.kind[def_id] <- match impl_item.kind {
ty::AssocKind::Const => {
if let hir::ImplItemKind::Const(_, body_id) = ast_item.kind {
let mir = self.tcx.at(ast_item.span).mir_const_qualif(def_id);
let qualifs = self.tcx.at(ast_item.span).mir_const_qualif(def_id);

EntryKind::AssocConst(container,
ConstQualif { mir },
EntryKind::AssocConst(
container,
qualifs,
self.encode_rendered_const_for_body(body_id))
} else {
bug!()
Expand Down Expand Up @@ -1093,9 +1094,9 @@ impl EncodeContext<'tcx> {
hir::ItemKind::Static(_, hir::Mutability::Mutable, _) => EntryKind::MutStatic,
hir::ItemKind::Static(_, hir::Mutability::Immutable, _) => EntryKind::ImmStatic,
hir::ItemKind::Const(_, body_id) => {
let mir = self.tcx.at(item.span).mir_const_qualif(def_id);
let qualifs = self.tcx.at(item.span).mir_const_qualif(def_id);
EntryKind::Const(
ConstQualif { mir },
qualifs,
self.encode_rendered_const_for_body(body_id)
)
}
Expand Down Expand Up @@ -1372,9 +1373,9 @@ impl EncodeContext<'tcx> {
let id = self.tcx.hir().as_local_hir_id(def_id).unwrap();
let body_id = self.tcx.hir().body_owned_by(id);
let const_data = self.encode_rendered_const_for_body(body_id);
let mir = self.tcx.mir_const_qualif(def_id);
let qualifs = self.tcx.mir_const_qualif(def_id);

record!(self.per_def.kind[def_id] <- EntryKind::Const(ConstQualif { mir }, const_data));
record!(self.per_def.kind[def_id] <- EntryKind::Const(qualifs, const_data));
record!(self.per_def.visibility[def_id] <- ty::Visibility::Public);
record!(self.per_def.span[def_id] <- self.tcx.def_span(def_id));
self.encode_item_type(def_id);
Expand Down
10 changes: 2 additions & 8 deletions src/librustc_metadata/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ crate struct LazyPerDefTables<'tcx> {

#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
enum EntryKind<'tcx> {
Const(ConstQualif, Lazy<RenderedConst>),
Const(mir::ConstQualifs, Lazy<RenderedConst>),
ImmStatic,
MutStatic,
ForeignImmStatic,
Expand Down Expand Up @@ -288,16 +288,10 @@ enum EntryKind<'tcx> {
Method(Lazy<MethodData>),
AssocType(AssocContainer),
AssocOpaqueTy(AssocContainer),
AssocConst(AssocContainer, ConstQualif, Lazy<RenderedConst>),
AssocConst(AssocContainer, mir::ConstQualifs, Lazy<RenderedConst>),
TraitAlias,
}

/// Additional data for EntryKind::Const and EntryKind::AssocConst
#[derive(Clone, Copy, RustcEncodable, RustcDecodable)]
struct ConstQualif {
mir: mir::ConstQualifs,
}

/// Contains a constant which has been rendered to a String.
/// Used by rustdoc.
#[derive(RustcEncodable, RustcDecodable)]
Expand Down

0 comments on commit a1135cc

Please sign in to comment.