Skip to content

Commit cd529a4

Browse files
authored
Merge pull request #20645 from ChayimFriedman2/update-rustc
internal: Upgrade rustc crates
2 parents 8b2671e + d03fd87 commit cd529a4

File tree

20 files changed

+468
-330
lines changed

20 files changed

+468
-330
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8989
vfs = { path = "./crates/vfs", version = "0.0.0" }
9090
edition = { path = "./crates/edition", version = "0.0.0" }
9191

92-
ra-ap-rustc_lexer = { version = "0.126", default-features = false }
93-
ra-ap-rustc_parse_format = { version = "0.126", default-features = false }
94-
ra-ap-rustc_index = { version = "0.126", default-features = false }
95-
ra-ap-rustc_abi = { version = "0.126", default-features = false }
96-
ra-ap-rustc_pattern_analysis = { version = "0.126", default-features = false }
97-
ra-ap-rustc_ast_ir = { version = "0.126", default-features = false }
98-
ra-ap-rustc_type_ir = { version = "0.126", default-features = false }
99-
ra-ap-rustc_next_trait_solver = { version = "0.126", default-features = false }
92+
ra-ap-rustc_lexer = { version = "0.128", default-features = false }
93+
ra-ap-rustc_parse_format = { version = "0.128", default-features = false }
94+
ra-ap-rustc_index = { version = "0.128", default-features = false }
95+
ra-ap-rustc_abi = { version = "0.128", default-features = false }
96+
ra-ap-rustc_pattern_analysis = { version = "0.128", default-features = false }
97+
ra-ap-rustc_ast_ir = { version = "0.128", default-features = false }
98+
ra-ap-rustc_type_ir = { version = "0.128", default-features = false }
99+
ra-ap-rustc_next_trait_solver = { version = "0.128", default-features = false }
100100

101101
# local crates that aren't published to crates.io. These should not have versions.
102102

crates/hir-def/src/lang_item.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ impl LangItemTarget {
8484
_ => None,
8585
}
8686
}
87+
88+
pub fn as_adt(self) -> Option<AdtId> {
89+
match self {
90+
LangItemTarget::Union(it) => Some(it.into()),
91+
LangItemTarget::EnumId(it) => Some(it.into()),
92+
LangItemTarget::Struct(it) => Some(it.into()),
93+
_ => None,
94+
}
95+
}
8796
}
8897

8998
/// Salsa query. This will look for lang items in a specific crate.
@@ -289,6 +298,10 @@ impl LangItem {
289298
lang_item(db, start_crate, self).and_then(|t| t.as_trait())
290299
}
291300

301+
pub fn resolve_adt(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<AdtId> {
302+
lang_item(db, start_crate, self).and_then(|t| t.as_adt())
303+
}
304+
292305
pub fn resolve_enum(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<EnumId> {
293306
lang_item(db, start_crate, self).and_then(|t| t.as_enum())
294307
}

crates/hir-ty/src/display.rs

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ use crate::{
5959
lt_from_placeholder_idx,
6060
mir::pad16,
6161
next_solver::{
62-
BoundExistentialPredicate, Ctor, DbInterner, GenericArgs, SolverDefId,
62+
BoundExistentialPredicate, DbInterner, GenericArgs, SolverDefId,
6363
mapping::{
6464
ChalkToNextSolver, convert_args_for_result, convert_const_for_result,
6565
convert_region_for_result, convert_ty_for_result,
@@ -911,14 +911,13 @@ fn render_const_scalar_inner(
911911
f.write_str("&")?;
912912
render_const_scalar_ns(f, bytes, memory_map, t)
913913
}
914-
TyKind::Adt(adt, _) if b.len() == 2 * size_of::<usize>() => match adt.def_id() {
915-
SolverDefId::AdtId(hir_def::AdtId::StructId(s)) => {
914+
TyKind::Adt(adt, _) if b.len() == 2 * size_of::<usize>() => match adt.def_id().0 {
915+
hir_def::AdtId::StructId(s) => {
916916
let data = f.db.struct_signature(s);
917917
write!(f, "&{}", data.name.display(f.db, f.edition()))?;
918918
Ok(())
919919
}
920-
SolverDefId::AdtId(_) => f.write_str("<unsized-enum-or-union>"),
921-
_ => unreachable!(),
920+
_ => f.write_str("<unsized-enum-or-union>"),
922921
},
923922
_ => {
924923
let addr = usize::from_le_bytes(match b.try_into() {
@@ -966,10 +965,7 @@ fn render_const_scalar_inner(
966965
f.write_str(")")
967966
}
968967
TyKind::Adt(def, args) => {
969-
let def = match def.def_id() {
970-
SolverDefId::AdtId(def) => def,
971-
_ => unreachable!(),
972-
};
968+
let def = def.def_id().0;
973969
let Ok(layout) = f.db.layout_of_adt(def, args, trait_env.clone()) else {
974970
return f.write_str("<layout-error>");
975971
};
@@ -1300,12 +1296,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
13001296
sig.hir_fmt(f)?;
13011297
}
13021298
TyKind::FnDef(def, args) => {
1303-
let def = match def {
1304-
SolverDefId::FunctionId(id) => CallableDefId::FunctionId(id),
1305-
SolverDefId::Ctor(Ctor::Enum(e)) => CallableDefId::EnumVariantId(e),
1306-
SolverDefId::Ctor(Ctor::Struct(s)) => CallableDefId::StructId(s),
1307-
_ => unreachable!(),
1308-
};
1299+
let def = def.0;
13091300
let sig = db
13101301
.callable_item_signature(def)
13111302
.substitute(Interner, &convert_args_for_result(interner, args.as_slice()));
@@ -1406,10 +1397,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
14061397
}
14071398
}
14081399
TyKind::Adt(def, parameters) => {
1409-
let def_id = match def.def_id() {
1410-
SolverDefId::AdtId(id) => id,
1411-
_ => unreachable!(),
1412-
};
1400+
let def_id = def.def_id().0;
14131401
f.start_location_link(def_id.into());
14141402
match f.display_kind {
14151403
DisplayKind::Diagnostics | DisplayKind::Test => {
@@ -1448,7 +1436,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
14481436
hir_fmt_generics(
14491437
f,
14501438
convert_args_for_result(interner, parameters.as_slice()).as_slice(Interner),
1451-
def.def_id().try_into().ok(),
1439+
Some(def.def_id().0.into()),
14521440
None,
14531441
)?;
14541442
}
@@ -1466,13 +1454,9 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
14661454

14671455
projection_ty.hir_fmt(f)?;
14681456
}
1469-
TyKind::Foreign(type_alias) => {
1470-
let alias = match type_alias {
1471-
SolverDefId::TypeAliasId(id) => id,
1472-
_ => unreachable!(),
1473-
};
1474-
let type_alias = db.type_alias_signature(alias);
1475-
f.start_location_link(alias.into());
1457+
TyKind::Foreign(alias) => {
1458+
let type_alias = db.type_alias_signature(alias.0);
1459+
f.start_location_link(alias.0.into());
14761460
write!(f, "{}", type_alias.name.display(f.db, f.edition()))?;
14771461
f.end_location_link();
14781462
}
@@ -1549,10 +1533,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
15491533
}
15501534
}
15511535
TyKind::Closure(id, substs) => {
1552-
let id = match id {
1553-
SolverDefId::InternedClosureId(id) => id,
1554-
_ => unreachable!(),
1555-
};
1536+
let id = id.0;
15561537
let substs = convert_args_for_result(interner, substs.as_slice());
15571538
if f.display_kind.is_source_code() {
15581539
if !f.display_kind.allows_opaque() {

crates/hir-ty/src/layout.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
consteval_nextsolver::try_const_usize,
2626
db::HirDatabase,
2727
next_solver::{
28-
DbInterner, GenericArgs, ParamEnv, SolverDefId, Ty, TyKind, TypingMode,
28+
DbInterner, GenericArgs, ParamEnv, Ty, TyKind, TypingMode,
2929
infer::{DbInternerInferExt, traits::ObligationCause},
3030
mapping::{ChalkToNextSolver, convert_args_for_result},
3131
project::solve_normalize::deeply_normalize,
@@ -323,14 +323,10 @@ pub fn layout_of_ty_query<'db>(
323323
ptr.valid_range_mut().start = 1;
324324
Layout::scalar(dl, ptr)
325325
}
326-
TyKind::Closure(c, args) => {
327-
let id = match c {
328-
SolverDefId::InternedClosureId(id) => id,
329-
_ => unreachable!(),
330-
};
331-
let def = db.lookup_intern_closure(id);
326+
TyKind::Closure(id, args) => {
327+
let def = db.lookup_intern_closure(id.0);
332328
let infer = db.infer(def.0);
333-
let (captures, _) = infer.closure_info(&id.into());
329+
let (captures, _) = infer.closure_info(&id.0.into());
334330
let fields = captures
335331
.iter()
336332
.map(|it| {

crates/hir-ty/src/method_resolution.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ impl TyFingerprint {
163163
rustc_ast_ir::Mutability::Mut => TyFingerprint::RawPtr(Mutability::Mut),
164164
rustc_ast_ir::Mutability::Not => TyFingerprint::RawPtr(Mutability::Not),
165165
},
166-
TyKind::Foreign(def) => {
167-
let SolverDefId::TypeAliasId(def) = def else { unreachable!() };
168-
TyFingerprint::ForeignType(crate::to_foreign_def_id(def))
169-
}
166+
TyKind::Foreign(def) => TyFingerprint::ForeignType(crate::to_foreign_def_id(def.0)),
170167
TyKind::Dynamic(bounds, _, _) => {
171168
let trait_ref = bounds
172169
.as_slice()

0 commit comments

Comments
 (0)