/// Same ID set as `cnum_map` plus maybe some injected crates like panic runtime.
dependencies: Lock<Vec<CrateNum>>,
/// How to link (or not link) this crate to the currently compiled crate.
- dep_kind: Lock<DepKind>,
+ dep_kind: Lock<CrateDepKind>,
/// Filesystem location of this crate.
source: CrateSource,
/// Whether or not this crate should be consider a private dependency
fn get_variant(
&self,
- tcx: TyCtxt<'tcx>,
kind: &EntryKind,
index: DefIndex,
parent_did: DefId,
let ctor_did = data.ctor.map(|index| self.local_def_id(index));
ty::VariantDef::new(
- tcx,
self.item_ident(index, sess),
variant_did,
ctor_did,
adt_kind,
parent_did,
false,
+ data.is_non_exhaustive,
)
}
.get(self, item_id)
.unwrap_or(Lazy::empty())
.decode(self)
- .map(|index| self.get_variant(tcx, &self.kind(index), index, did, tcx.sess))
+ .map(|index| self.get_variant(&self.kind(index), index, did, tcx.sess))
.collect()
} else {
- std::iter::once(self.get_variant(tcx, &kind, item_id, did, tcx.sess)).collect()
+ std::iter::once(self.get_variant(&kind, item_id, did, tcx.sess)).collect()
};
tcx.alloc_adt_def(did, adt_kind, variants, repr)
.decode((self, tcx))
}
- fn get_unused_generic_params(&self, id: DefIndex) -> FiniteBitSet<u64> {
+ fn get_unused_generic_params(&self, id: DefIndex) -> FiniteBitSet<u32> {
self.root
.tables
.unused_generic_params
fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
// Translate the virtual `/rustc/$hash` prefix back to a real directory
// that should hold actual sources, where possible.
+ //
+ // NOTE: if you update this, you might need to also update bootstrap's code for generating
+ // the `rust-src` component in `Src::run` in `src/bootstrap/dist.rs`.
let virtual_rust_source_base_dir = option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR")
.map(Path::new)
.filter(|_| {
if let rustc_span::RealFileName::Named(one_path) = old_name {
if let Ok(rest) = one_path.strip_prefix(virtual_dir) {
let virtual_name = one_path.clone();
- let new_path = real_dir.join(rest);
+
+ // The std library crates are in
+ // `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
+ // may be in `$sysroot/lib/rustlib/src/rust/` directly. So we
+ // detect crates from the std libs and handle them specially.
+ const STD_LIBS: &[&str] = &[
+ "core",
+ "alloc",
+ "std",
+ "test",
+ "term",
+ "unwind",
+ "proc_macro",
+ "panic_abort",
+ "panic_unwind",
+ "profiler_builtins",
+ "rtstartup",
+ "rustc-std-workspace-core",
+ "rustc-std-workspace-alloc",
+ "rustc-std-workspace-std",
+ "backtrace",
+ ];
+ let is_std_lib = STD_LIBS.iter().any(|l| rest.starts_with(l));
+
+ let new_path = if is_std_lib {
+ real_dir.join("library").join(rest)
+ } else {
+ real_dir.join(rest)
+ };
+
debug!(
"try_to_translate_virtual_to_real: `{}` -> `{}`",
virtual_name.display(),
raw_proc_macros: Option<&'static [ProcMacro]>,
cnum: CrateNum,
cnum_map: CrateNumMap,
- dep_kind: DepKind,
+ dep_kind: CrateDepKind,
source: CrateSource,
private_dep: bool,
host_hash: Option<Svh>,
&self.source
}
- crate fn dep_kind(&self) -> DepKind {
+ crate fn dep_kind(&self) -> CrateDepKind {
*self.dep_kind.lock()
}
- crate fn update_dep_kind(&self, f: impl FnOnce(DepKind) -> DepKind) {
+ crate fn update_dep_kind(&self, f: impl FnOnce(CrateDepKind) -> CrateDepKind) {
self.dep_kind.with_lock(|dep_kind| *dep_kind = f(*dep_kind))
}