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

Make decoding non-optional LazyArray panic if not set #129829

Merged
merged 1 commit into from
Sep 3, 2024
Merged
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
23 changes: 18 additions & 5 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl<'a, 'tcx, T: Copy + Decodable<DecodeContext<'a, 'tcx>>> ProcessQueryValue<'
for Option<DecodeIterator<'a, 'tcx, T>>
{
#[inline(always)]
fn process_decoded(self, tcx: TyCtxt<'tcx>, _err: impl Fn() -> !) -> &'tcx [T] {
if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { &[] }
fn process_decoded(self, tcx: TyCtxt<'tcx>, err: impl Fn() -> !) -> &'tcx [T] {
if let Some(iter) = self { tcx.arena.alloc_from_iter(iter) } else { err() }
}
}

Expand All @@ -84,12 +84,12 @@ impl<'a, 'tcx, T: Copy + Decodable<DecodeContext<'a, 'tcx>>>
fn process_decoded(
self,
tcx: TyCtxt<'tcx>,
_err: impl Fn() -> !,
err: impl Fn() -> !,
) -> ty::EarlyBinder<'tcx, &'tcx [T]> {
ty::EarlyBinder::bind(if let Some(iter) = self {
tcx.arena.alloc_from_iter(iter)
} else {
&[]
err()
})
}
}
Expand Down Expand Up @@ -301,7 +301,20 @@ provide! { tcx, def_id, other, cdata,
.unwrap_or_else(|| panic!("{def_id:?} does not have eval_static_initializer")))
}
trait_def => { table }
deduced_param_attrs => { table }
deduced_param_attrs => {
// FIXME: `deduced_param_attrs` has some sketchy encoding settings,
// where we don't encode unless we're optimizing, doing codegen,
// and not incremental (see `encoder.rs`). I don't think this is right!
cdata
.root
.tables
.deduced_param_attrs
.get(cdata, def_id.index)
.map(|lazy| {
&*tcx.arena.alloc_from_iter(lazy.decode((cdata, tcx)))
})
.unwrap_or_default()
}
is_type_alias_impl_trait => {
debug_assert_eq!(tcx.def_kind(def_id), DefKind::OpaqueTy);
cdata.root.tables.is_type_alias_impl_trait.get(cdata, def_id.index)
Expand Down
Loading