Skip to content

Commit 8cb5a84

Browse files
committed
Switch to in-tree rustc dependencies with a cfg flag
1 parent 12e28c3 commit 8cb5a84

File tree

17 files changed

+89
-29
lines changed

17 files changed

+89
-29
lines changed

Cargo.lock

Lines changed: 14 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ toolchain = { path = "./crates/toolchain", version = "0.0.0" }
7979
tt = { path = "./crates/tt", version = "0.0.0" }
8080
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8181
vfs = { path = "./crates/vfs", version = "0.0.0" }
82+
rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
8283

8384
# local crates that aren't published to crates.io. These should not have versions.
8485
proc-macro-test = { path = "./crates/proc-macro-test" }
@@ -90,9 +91,9 @@ lsp-server = { version = "0.7.4" }
9091

9192
# non-local crates
9293
smallvec = { version = "1.10.0", features = [
93-
"const_new",
94-
"union",
95-
"const_generics",
94+
"const_new",
95+
"union",
96+
"const_generics",
9697
] }
9798
smol_str = "0.2.0"
9899
nohash-hasher = "0.2.0"
@@ -101,11 +102,6 @@ serde = { version = "1.0.156", features = ["derive"] }
101102
serde_json = "1.0.96"
102103
triomphe = { version = "0.1.8", default-features = false, features = ["std"] }
103104
# can't upgrade due to dashmap depending on 0.12.3 currently
104-
hashbrown = { version = "0.12.3", features = ["inline-more"], default-features = false }
105-
106-
rustc_lexer = { version = "0.10.0", package = "ra-ap-rustc_lexer" }
107-
rustc_parse_format = { version = "0.10.0", package = "ra-ap-rustc_parse_format", default-features = false }
108-
109-
# Upstream broke this for us so we can't update it
110-
rustc_abi = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_abi", default-features = false }
111-
rustc_index = { version = "0.0.20221221", package = "hkalbasi-rustc-ap-rustc_index", default-features = false }
105+
hashbrown = { version = "0.12.3", features = [
106+
"inline-more",
107+
], default-features = false }

crates/hir-def/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ smallvec.workspace = true
3131
hashbrown.workspace = true
3232
triomphe.workspace = true
3333

34-
rustc_abi.workspace = true
35-
rustc_index.workspace = true
36-
rustc_parse_format.workspace = true
37-
34+
rustc-dependencies.workspace = true
3835

3936
# local deps
4037
stdx.workspace = true

crates/hir-def/src/data/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hir_expand::{
1111
};
1212
use intern::Interned;
1313
use la_arena::{Arena, ArenaMap};
14-
use rustc_abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
14+
use rustc_dependencies::abi::{Align, Integer, IntegerType, ReprFlags, ReprOptions};
1515
use syntax::ast::{self, HasName, HasVisibility};
1616
use triomphe::Arc;
1717

crates/hir-def/src/hir/format_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::mem;
33

44
use hir_expand::name::Name;
5-
use rustc_parse_format as parse;
5+
use rustc_dependencies::parse_format as parse;
66
use syntax::{
77
ast::{self, IsString},
88
AstToken, SmolStr, TextRange,

crates/hir-def/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! actually true.
99
1010
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
11+
#![cfg_attr(IN_RUSTC_REPOSITORY, feature(rustc_private))]
1112

1213
#[allow(unused)]
1314
macro_rules! eprintln {
@@ -48,7 +49,7 @@ pub mod visibility;
4849
pub mod find_path;
4950
pub mod import_map;
5051

51-
pub use rustc_abi as layout;
52+
pub use rustc_dependencies::abi as layout;
5253
use triomphe::Arc;
5354

5455
#[cfg(test)]

crates/hir-ty/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ triomphe.workspace = true
3333
nohash-hasher.workspace = true
3434
typed-arena = "2.0.1"
3535

36-
rustc_index.workspace = true
36+
rustc-dependencies.workspace = true
3737

3838
# local deps
3939
stdx.workspace = true

crates/hir-ty/src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod target;
3434
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3535
pub struct RustcEnumVariantIdx(pub LocalEnumVariantId);
3636

37-
impl rustc_index::vec::Idx for RustcEnumVariantIdx {
37+
impl rustc_dependencies::index::vec::Idx for RustcEnumVariantIdx {
3838
fn new(idx: usize) -> Self {
3939
RustcEnumVariantIdx(Idx::from_raw(RawIdx::from(idx as u32)))
4040
}

crates/parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ doctest = false
1313

1414
[dependencies]
1515
drop_bomb = "0.1.5"
16-
rustc_lexer.workspace = true
16+
rustc-dependencies.workspace = true
1717

1818
limit.workspace = true
1919

crates/parser/src/lexed_str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//! Note that these tokens, unlike the tokens we feed into the parser, do
99
//! include info about comments and whitespace.
1010
11+
use rustc_dependencies::lexer as rustc_lexer;
1112
use std::ops;
1213

1314
use crate::{

crates/parser/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
2121
#![allow(rustdoc::private_intra_doc_links)]
22+
#![cfg_attr(IN_RUSTC_REPOSITORY, feature(rustc_private))]
2223

2324
mod lexed_str;
2425
mod token_set;

crates/rustc-dependencies/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "rustc-dependencies"
3+
version = "0.0.0"
4+
rust-version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[dependencies]
12+
ra-ap-rustc_lexer = { version = "0.10.0" }
13+
ra-ap-rustc_parse_format = { version = "0.10.0", default-features = false }
14+
15+
# Upstream broke this for us so we can't update it
16+
hkalbasi-rustc-ap-rustc_abi = { version = "0.0.20221221", default-features = false }
17+
hkalbasi-rustc-ap-rustc_index = { version = "0.0.20221221", default-features = false }

crates/rustc-dependencies/src/lib.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#![cfg_attr(IN_RUSTC_REPOSITORY, feature(rustc_private))]
2+
3+
#[cfg(IN_RUSTC_REPOSITORY)]
4+
extern crate rustc_lexer;
5+
6+
#[cfg(IN_RUSTC_REPOSITORY)]
7+
pub mod lexer {
8+
pub use ::rustc_lexer::*;
9+
}
10+
11+
#[cfg(not(IN_RUSTC_REPOSITORY))]
12+
pub mod lexer {
13+
pub use ::ra_ap_rustc_lexer::*;
14+
}
15+
16+
#[cfg(IN_RUSTC_REPOSITORY)]
17+
extern crate rustc_parse_format;
18+
19+
#[cfg(IN_RUSTC_REPOSITORY)]
20+
pub mod parse_format {
21+
pub use ::rustc_parse_format::*;
22+
}
23+
24+
#[cfg(not(IN_RUSTC_REPOSITORY))]
25+
pub mod parse_format {
26+
pub use ::ra_ap_rustc_parse_format::*;
27+
}
28+
29+
// Upstream broke this for us so we can't update it
30+
pub mod abi {
31+
pub use ::hkalbasi_rustc_ap_rustc_abi::*;
32+
}
33+
34+
pub mod index {
35+
pub use ::hkalbasi_rustc_ap_rustc_index::*;
36+
}

crates/syntax/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ indexmap = "2.0.0"
2323
smol_str.workspace = true
2424
triomphe.workspace = true
2525

26-
rustc_lexer.workspace = true
26+
rustc-dependencies.workspace = true
2727

2828
parser.workspace = true
2929
profile.workspace = true

crates/syntax/src/ast/token_ext.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
33
use std::borrow::Cow;
44

5+
use rustc_dependencies::lexer as rustc_lexer;
6+
57
use rustc_lexer::unescape::{
68
unescape_byte, unescape_c_string, unescape_char, unescape_literal, CStrUnit, Mode,
79
};

crates/syntax/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//! [RFC]: <https://github.com/rust-lang/rfcs/pull/2256>
2020
//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md>
2121
22+
#![cfg_attr(IN_RUSTC_REPOSITORY, feature(rustc_private))]
2223
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
2324

2425
#[allow(unused)]

crates/syntax/src/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
mod block;
66

77
use rowan::Direction;
8-
use rustc_lexer::unescape::{self, unescape_literal, Mode};
8+
use rustc_dependencies::lexer::unescape::{self, unescape_literal, Mode};
99

1010
use crate::{
1111
algo,

0 commit comments

Comments
 (0)