Skip to content

Commit 5347a51

Browse files
committed
Remove enum_from_u32.
It's a macro that just creates an enum with a `from_u32` method. It has two arms. One is unused and the other has a single use. This commit inlines that single use and removes the whole macro. This increases readability because we don't have two different macros interacting (`enum_from_u32` and `language_item_table`).
1 parent 347bfcd commit 5347a51

File tree

3 files changed

+15
-48
lines changed

3 files changed

+15
-48
lines changed

compiler/rustc_data_structures/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pub mod fx;
6262
pub mod graph;
6363
pub mod intern;
6464
pub mod jobserver;
65-
pub mod macros;
6665
pub mod marker;
6766
pub mod memmap;
6867
pub mod obligation_forest;

compiler/rustc_data_structures/src/macros.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

compiler/rustc_hir/src/lang_items.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,22 @@ macro_rules! language_item_table {
5555
(
5656
$( $(#[$attr:meta])* $variant:ident, $module:ident :: $name:ident, $method:ident, $target:expr, $generics:expr; )*
5757
) => {
58+
/// A representation of all the valid lang items in Rust.
59+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
60+
pub enum LangItem {
61+
$(
62+
#[doc = concat!("The `", stringify!($name), "` lang item.")]
63+
$(#[$attr])*
64+
$variant,
65+
)*
66+
}
5867

59-
rustc_data_structures::enum_from_u32! {
60-
/// A representation of all the valid lang items in Rust.
61-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
62-
pub enum LangItem {
63-
$(
64-
#[doc = concat!("The `", stringify!($name), "` lang item.")]
65-
///
66-
$(#[$attr])*
67-
$variant,
68-
)*
68+
impl LangItem {
69+
pub fn from_u32(u: u32) -> Option<LangItem> {
70+
$(if u == LangItem::$variant as u32 {
71+
return Some(LangItem::$variant)
72+
})*
73+
None
6974
}
7075
}
7176

0 commit comments

Comments
 (0)