Skip to content

Commit 22b18b9

Browse files
committed
Auto merge of #15616 - HKalbasi:rustc-deps, r=HKalbasi
Switch to in-tree rustc dependencies with a cfg flag We can use this flag to detect and prevent breakages in rustc CI. (see #14846 and #15569) ~The `IN_RUSTC_REPOSITORY` is just a placeholder. Is there any existing cfg flag that rustc CI sets?~
2 parents cdaadb6 + f4704bc commit 22b18b9

File tree

18 files changed

+118
-31
lines changed

18 files changed

+118
-31
lines changed

Cargo.lock

+16-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+7-11
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

+4-4
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
@@ -53,3 +50,6 @@ expect-test = "1.4.0"
5350

5451
# local deps
5552
test-utils.workspace = true
53+
54+
[features]
55+
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

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

+1-1
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

+1-1
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

+2-1
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(feature = "in-rust-tree", 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

+4-1
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
@@ -56,3 +56,6 @@ project-model = { path = "../project-model" }
5656

5757
# local deps
5858
test-utils.workspace = true
59+
60+
[features]
61+
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

crates/hir-ty/src/layout.rs

+1-1
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

+4-1
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

@@ -22,3 +22,6 @@ expect-test = "1.4.0"
2222

2323
stdx.workspace = true
2424
sourcegen.workspace = true
25+
26+
[features]
27+
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

crates/parser/src/lexed_str.rs

+1
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

+1
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(feature = "in-rust-tree", feature(rustc_private))]
2223

2324
mod lexed_str;
2425
mod token_set;

crates/rust-analyzer/Cargo.toml

+11-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ flycheck.workspace = true
5757
hir-def.workspace = true
5858
hir-ty.workspace = true
5959
hir.workspace = true
60+
rustc-dependencies.workspace = true
6061
ide-db.workspace = true
6162
# This should only be used in CLI
6263
ide-ssr.workspace = true
@@ -67,6 +68,7 @@ profile.workspace = true
6768
project-model.workspace = true
6869
stdx.workspace = true
6970
syntax.workspace = true
71+
parser.workspace = true
7072
toolchain.workspace = true
7173
vfs-notify.workspace = true
7274
vfs.workspace = true
@@ -89,4 +91,12 @@ mbe.workspace = true
8991
jemalloc = ["jemallocator", "profile/jemalloc"]
9092
force-always-assert = ["always-assert/force"]
9193
sysroot-abi = []
92-
in-rust-tree = ["sysroot-abi", "ide/in-rust-tree", "syntax/in-rust-tree"]
94+
in-rust-tree = [
95+
"sysroot-abi",
96+
"ide/in-rust-tree",
97+
"syntax/in-rust-tree",
98+
"parser/in-rust-tree",
99+
"rustc-dependencies/in-rust-tree",
100+
"hir-def/in-rust-tree",
101+
"hir-ty/in-rust-tree",
102+
]

crates/rustc-dependencies/Cargo.toml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 }
18+
19+
[features]
20+
in-rust-tree = []

crates/rustc-dependencies/src/lib.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//! A wrapper around rustc internal crates, which enables switching between compiler provided
2+
//! ones and stable ones published in crates.io
3+
4+
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
5+
6+
#[cfg(feature = "in-rust-tree")]
7+
extern crate rustc_lexer;
8+
9+
#[cfg(feature = "in-rust-tree")]
10+
pub mod lexer {
11+
pub use ::rustc_lexer::*;
12+
}
13+
14+
#[cfg(not(feature = "in-rust-tree"))]
15+
pub mod lexer {
16+
pub use ::ra_ap_rustc_lexer::*;
17+
}
18+
19+
#[cfg(feature = "in-rust-tree")]
20+
extern crate rustc_parse_format;
21+
22+
#[cfg(feature = "in-rust-tree")]
23+
pub mod parse_format {
24+
pub use ::rustc_parse_format::*;
25+
}
26+
27+
#[cfg(not(feature = "in-rust-tree"))]
28+
pub mod parse_format {
29+
pub use ::ra_ap_rustc_parse_format::*;
30+
}
31+
32+
// Upstream broke this for us so we can't update it
33+
pub mod abi {
34+
pub use ::hkalbasi_rustc_ap_rustc_abi::*;
35+
}
36+
37+
pub mod index {
38+
pub use ::hkalbasi_rustc_ap_rustc_index::*;
39+
}

crates/syntax/Cargo.toml

+2-2
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
@@ -41,4 +41,4 @@ test-utils.workspace = true
4141
sourcegen.workspace = true
4242

4343
[features]
44-
in-rust-tree = []
44+
in-rust-tree = ["rustc-dependencies/in-rust-tree"]

crates/syntax/src/ast/token_ext.rs

+2
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

+1
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(feature = "in-rust-tree", feature(rustc_private))]
2223
#![warn(rust_2018_idioms, unused_lifetimes, semicolon_in_expressions_from_macros)]
2324

2425
#[allow(unused)]

crates/syntax/src/validation.rs

+1-1
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)