Skip to content

Commit 115602b

Browse files
Add INVALID_CRATE CrateNum constant.
1 parent 6a5e2a5 commit 115602b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/librustc/hir/def_id.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ pub const LOCAL_CRATE: CrateNum = CrateNum(0);
3636

3737
/// Virtual crate for builtin macros
3838
// FIXME(jseyfried): this is also used for custom derives until proc-macro crates get `CrateNum`s.
39-
pub const BUILTIN_MACROS_CRATE: CrateNum = CrateNum(!0);
39+
pub const BUILTIN_MACROS_CRATE: CrateNum = CrateNum(u32::MAX);
40+
41+
/// A CrateNum value that indicates that something is wrong.
42+
pub const INVALID_CRATE: CrateNum = CrateNum(u32::MAX - 1);
4043

4144
impl CrateNum {
4245
pub fn new(x: usize) -> CrateNum {

src/libsyntax_pos/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,9 @@ impl Decodable for FileMap {
494494
name: name,
495495
name_was_remapped: name_was_remapped,
496496
// `crate_of_origin` has to be set by the importer.
497-
crate_of_origin: 0xEFFF_FFFF,
497+
// This value matches up with rustc::hir::def_id::INVALID_CRATE.
498+
// That constant is not available here unfortunately :(
499+
crate_of_origin: ::std::u32::MAX - 1,
498500
start_pos: start_pos,
499501
end_pos: end_pos,
500502
src: None,

0 commit comments

Comments
 (0)