Skip to content

Commit

Permalink
Rollup merge of rust-lang#106067 - Nilstrieb:meta-cleanup, r=petroche…
Browse files Browse the repository at this point in the history
…nkov

A few metadata nits

Found while reading through the code. The `NOTE` is outdated now after rust-lang#97376.
  • Loading branch information
Noratrieb authored Dec 23, 2022
2 parents de99a87 + d846cf0 commit 659c218
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
8 changes: 2 additions & 6 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,11 +1011,7 @@ impl CrateError {
sess.emit_err(SymbolConflictsOthers { span, crate_name: root_name });
}
CrateError::StableCrateIdCollision(crate_name0, crate_name1) => {
sess.emit_err(StableCrateIdCollision {
span,
crate_name0: crate_name0,
crate_name1: crate_name1,
});
sess.emit_err(StableCrateIdCollision { span, crate_name0, crate_name1 });
}
CrateError::DlOpen(s) | CrateError::DlSym(s) => {
sess.emit_err(DlError { span, err: s });
Expand Down Expand Up @@ -1074,7 +1070,7 @@ impl CrateError {
}
sess.emit_err(NoCrateWithTriple {
span,
crate_name: crate_name,
crate_name,
locator_triple: locator.triple.triple(),
add_info,
found_crates,
Expand Down
24 changes: 9 additions & 15 deletions compiler/rustc_metadata/src/rmeta/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ pub(crate) struct CrateMetadata {
blob: MetadataBlob,

// --- Some data pre-decoded from the metadata blob, usually for performance ---
/// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
/// lifetime is only used behind `LazyValue`, `LazyArray`, or `LazyTable`, and therefore acts like a
/// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
/// is being used to decode those values.
root: CrateRoot,
/// Trait impl data.
/// FIXME: Used only from queries and can use query cache,
Expand Down Expand Up @@ -688,10 +684,10 @@ impl MetadataBlob {
pub(crate) fn get_root(&self) -> CrateRoot {
let slice = &self.blob()[..];
let offset = METADATA_HEADER.len();
let pos = (((slice[offset + 0] as u32) << 24)
| ((slice[offset + 1] as u32) << 16)
| ((slice[offset + 2] as u32) << 8)
| ((slice[offset + 3] as u32) << 0)) as usize;

let pos_bytes = slice[offset..][..4].try_into().unwrap();
let pos = u32::from_be_bytes(pos_bytes) as usize;

LazyValue::<CrateRoot>::from_position(NonZeroUsize::new(pos).unwrap()).decode(self)
}

Expand All @@ -702,16 +698,14 @@ impl MetadataBlob {
writeln!(out, "hash {} stable_crate_id {:?}", root.hash, root.stable_crate_id)?;
writeln!(out, "proc_macro {:?}", root.proc_macro_data.is_some())?;
writeln!(out, "=External Dependencies=")?;

for (i, dep) in root.crate_deps.decode(self).enumerate() {
let CrateDep { name, extra_filename, hash, host_hash, kind } = dep;
let number = i + 1;

writeln!(
out,
"{} {}{} hash {} host_hash {:?} kind {:?}",
i + 1,
dep.name,
dep.extra_filename,
dep.hash,
dep.host_hash,
dep.kind
"{number} {name}{extra_filename} hash {hash} host_hash {host_hash:?} kind {kind:?}"
)?;
}
write!(out, "\n")?;
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_metadata/src/rmeta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,6 @@ struct VariantData {
is_non_exhaustive: bool,
}

#[derive(TyEncodable, TyDecodable)]
struct GeneratorData<'tcx> {
layout: mir::GeneratorLayout<'tcx>,
}

// Tags used for encoding Spans:
const TAG_VALID_SPAN_LOCAL: u8 = 0;
const TAG_VALID_SPAN_FOREIGN: u8 = 1;
Expand Down

0 comments on commit 659c218

Please sign in to comment.