Skip to content

Commit 8006369

Browse files
Begin to abstract rustc_type_ir for rust-analyzer
1 parent cc705b8 commit 8006369

File tree

13 files changed

+138
-386
lines changed

13 files changed

+138
-386
lines changed

Diff for: Cargo.lock

+11
Original file line numberDiff line numberDiff line change
@@ -3967,11 +3967,22 @@ name = "rustc_index"
39673967
version = "0.0.0"
39683968
dependencies = [
39693969
"arrayvec",
3970+
"rustc_index_macros",
39703971
"rustc_macros",
39713972
"rustc_serialize",
39723973
"smallvec",
39733974
]
39743975

3976+
[[package]]
3977+
name = "rustc_index_macros"
3978+
version = "0.0.0"
3979+
dependencies = [
3980+
"proc-macro2",
3981+
"quote",
3982+
"syn 2.0.29",
3983+
"synstructure 0.13.0",
3984+
]
3985+
39753986
[[package]]
39763987
name = "rustc_infer"
39773988
version = "0.0.0"

Diff for: compiler/rustc_index/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ edition = "2021"
88
[dependencies]
99
arrayvec = { version = "0.7", default-features = false }
1010
rustc_serialize = { path = "../rustc_serialize", optional = true }
11+
rustc_index_macros = { path = "../rustc_index_macros" }
1112
rustc_macros = { path = "../rustc_macros", optional = true }
1213
smallvec = "1.8.1"
1314

1415
[features]
1516
default = ["nightly"]
16-
nightly = ["rustc_serialize", "rustc_macros"]
17+
nightly = ["rustc_serialize", "rustc_macros", "rustc_index_macros/nightly"]

Diff for: compiler/rustc_index/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ mod vec;
2525

2626
pub use {idx::Idx, slice::IndexSlice, vec::IndexVec};
2727

28-
#[cfg(feature = "rustc_macros")]
29-
pub use rustc_macros::newtype_index;
28+
pub use rustc_index_macros::newtype_index;
3029

3130
/// Type size assertion. The first argument is a type and the second argument is its expected size.
3231
///

Diff for: compiler/rustc_macros/src/lib.rs

-22
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use proc_macro::TokenStream;
1717
mod diagnostics;
1818
mod hash_stable;
1919
mod lift;
20-
mod newtype;
2120
mod query;
2221
mod serialize;
2322
mod symbols;
@@ -34,27 +33,6 @@ pub fn symbols(input: TokenStream) -> TokenStream {
3433
symbols::symbols(input.into()).into()
3534
}
3635

37-
/// Creates a struct type `S` that can be used as an index with
38-
/// `IndexVec` and so on.
39-
///
40-
/// There are two ways of interacting with these indices:
41-
///
42-
/// - The `From` impls are the preferred way. So you can do
43-
/// `S::from(v)` with a `usize` or `u32`. And you can convert back
44-
/// to an integer with `u32::from(s)`.
45-
///
46-
/// - Alternatively, you can use the methods `S::new(v)` and `s.index()`
47-
/// to create/return a value.
48-
///
49-
/// Internally, the index uses a u32, so the index must not exceed
50-
/// `u32::MAX`. You can also customize things like the `Debug` impl,
51-
/// what traits are derived, and so forth via the macro.
52-
#[proc_macro]
53-
#[allow_internal_unstable(step_trait, rustc_attrs, trusted_step, spec_option_partial_eq)]
54-
pub fn newtype_index(input: TokenStream) -> TokenStream {
55-
newtype::newtype(input)
56-
}
57-
5836
decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive);
5937
decl_derive!(
6038
[HashStable_Generic, attributes(stable_hasher)] =>

Diff for: compiler/rustc_macros/src/newtype.rs

-312
This file was deleted.

0 commit comments

Comments
 (0)