-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Decouple CrateNum
of CrateInfo
from the compilation session
#67516
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ use rustc::ty::query::Providers; | |
use rustc_data_structures::fx::{FxHashMap, FxHashSet}; | ||
use rustc_data_structures::svh::Svh; | ||
use rustc_data_structures::sync::Lrc; | ||
use rustc_hir::def_id::CrateNum; | ||
use rustc_hir::def_id; | ||
use rustc_span::symbol::Symbol; | ||
use std::path::{Path, PathBuf}; | ||
|
||
|
@@ -116,6 +116,24 @@ bitflags::bitflags! { | |
} | ||
} | ||
|
||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
0dvictor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pub struct CrateNum(pub u32); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name can be confused with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I chose to keep the name |
||
impl CrateNum { | ||
pub fn as_usize(self) -> usize { | ||
self.0 as usize | ||
} | ||
} | ||
impl From<def_id::CrateNum> for CrateNum { | ||
fn from(crate_num: def_id::CrateNum) -> Self { | ||
CrateNum(crate_num.as_u32()) | ||
} | ||
} | ||
impl ::std::fmt::Debug for CrateNum { | ||
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { | ||
write!(fmt, "crate{}", self.0) | ||
} | ||
} | ||
|
||
/// Misc info we load from metadata to persist beyond the tcx. | ||
#[derive(Debug)] | ||
pub struct CrateInfo { | ||
|
Uh oh!
There was an error while loading. Please reload this page.