Skip to content

Commit

Permalink
Add INVALID_CRATE CrateNum constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed May 9, 2017
1 parent 6a5e2a5 commit 115602b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/librustc/hir/def_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ pub const LOCAL_CRATE: CrateNum = CrateNum(0);

/// Virtual crate for builtin macros
// FIXME(jseyfried): this is also used for custom derives until proc-macro crates get `CrateNum`s.
pub const BUILTIN_MACROS_CRATE: CrateNum = CrateNum(!0);
pub const BUILTIN_MACROS_CRATE: CrateNum = CrateNum(u32::MAX);

/// A CrateNum value that indicates that something is wrong.
pub const INVALID_CRATE: CrateNum = CrateNum(u32::MAX - 1);

impl CrateNum {
pub fn new(x: usize) -> CrateNum {
Expand Down
4 changes: 3 additions & 1 deletion src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,9 @@ impl Decodable for FileMap {
name: name,
name_was_remapped: name_was_remapped,
// `crate_of_origin` has to be set by the importer.
crate_of_origin: 0xEFFF_FFFF,
// This value matches up with rustc::hir::def_id::INVALID_CRATE.
// That constant is not available here unfortunately :(
crate_of_origin: ::std::u32::MAX - 1,
start_pos: start_pos,
end_pos: end_pos,
src: None,
Expand Down

0 comments on commit 115602b

Please sign in to comment.