Skip to content

Commit 19b0c00

Browse files
authored
Rollup merge of rust-lang#68554 - cjgillot:lang_items, r=Zoxc
Split lang_items to crates `rustc_hir` and `rustc_passes`. As discussed in comment rust-lang#67688 (comment)
2 parents 344f8d9 + fc73e19 commit 19b0c00

File tree

26 files changed

+688
-628
lines changed

26 files changed

+688
-628
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3630,6 +3630,7 @@ version = "0.0.0"
36303630
name = "rustc_hir"
36313631
version = "0.0.0"
36323632
dependencies = [
3633+
"lazy_static 1.4.0",
36333634
"rustc_ast_pretty",
36343635
"rustc_data_structures",
36353636
"rustc_errors",

src/librustc/hir/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/hir.html
44
5-
pub mod check_attr;
65
pub mod exports;
76
pub mod map;
87

src/librustc/ich/impls_hir.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,6 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::def_id::DefIndex {
251251
}
252252
}
253253

254-
impl<'a> HashStable<StableHashingContext<'a>> for crate::middle::lang_items::LangItem {
255-
fn hash_stable(&self, _: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
256-
::std::hash::Hash::hash(self, hasher);
257-
}
258-
}
259-
260254
impl<'a> HashStable<StableHashingContext<'a>> for hir::TraitCandidate {
261255
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
262256
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {

src/librustc/macros.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,3 @@
1-
macro_rules! enum_from_u32 {
2-
($(#[$attr:meta])* pub enum $name:ident {
3-
$($variant:ident = $e:expr,)*
4-
}) => {
5-
$(#[$attr])*
6-
pub enum $name {
7-
$($variant = $e),*
8-
}
9-
10-
impl $name {
11-
pub fn from_u32(u: u32) -> Option<$name> {
12-
$(if u == $name::$variant as u32 {
13-
return Some($name::$variant)
14-
})*
15-
None
16-
}
17-
}
18-
};
19-
($(#[$attr:meta])* pub enum $name:ident {
20-
$($variant:ident,)*
21-
}) => {
22-
$(#[$attr])*
23-
pub enum $name {
24-
$($variant,)*
25-
}
26-
27-
impl $name {
28-
pub fn from_u32(u: u32) -> Option<$name> {
29-
$(if u == $name::$variant as u32 {
30-
return Some($name::$variant)
31-
})*
32-
None
33-
}
34-
}
35-
}
36-
}
37-
381
#[macro_export]
392
macro_rules! bug {
403
() => ( bug!("impossible case reached") );

src/librustc/middle/lang_items.rs

Lines changed: 35 additions & 390 deletions
Large diffs are not rendered by default.

src/librustc/middle/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ pub mod recursion_limit;
3333
pub mod region;
3434
pub mod resolve_lifetime;
3535
pub mod stability;
36-
pub mod weak_lang_items;

src/librustc/middle/weak_lang_items.rs

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

src/librustc/traits/select.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16341634
obligation: &TraitObligation<'tcx>,
16351635
candidates: &mut SelectionCandidateSet<'tcx>,
16361636
) -> Result<(), SelectionError<'tcx>> {
1637-
let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()) {
1637+
let kind = match self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()) {
16381638
Some(k) => k,
16391639
None => {
16401640
return Ok(());
@@ -1677,7 +1677,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
16771677
candidates: &mut SelectionCandidateSet<'tcx>,
16781678
) -> Result<(), SelectionError<'tcx>> {
16791679
// We provide impl of all fn traits for fn pointers.
1680-
if self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()).is_none() {
1680+
if self.tcx().fn_trait_kind_from_lang_item(obligation.predicate.def_id()).is_none() {
16811681
return Ok(());
16821682
}
16831683

@@ -2889,8 +2889,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
28892889

28902890
let kind = self
28912891
.tcx()
2892-
.lang_items()
2893-
.fn_trait_kind(obligation.predicate.def_id())
2892+
.fn_trait_kind_from_lang_item(obligation.predicate.def_id())
28942893
.unwrap_or_else(|| bug!("closure candidate for non-fn trait {:?}", obligation));
28952894

28962895
// Okay to skip binder because the substs on closure types never

src/librustc/ty/context.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,10 +2716,6 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
27162716
assert_eq!(id, LOCAL_CRATE);
27172717
tcx.crate_name
27182718
};
2719-
providers.get_lang_items = |tcx, id| {
2720-
assert_eq!(id, LOCAL_CRATE);
2721-
tcx.arena.alloc(middle::lang_items::collect(tcx))
2722-
};
27232719
providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id);
27242720
providers.maybe_unused_extern_crates = |tcx, cnum| {
27252721
assert_eq!(cnum, LOCAL_CRATE);

src/librustc/ty/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ fn resolve_associated_item<'tcx>(
450450
substs: generator_data.substs,
451451
}),
452452
traits::VtableClosure(closure_data) => {
453-
let trait_closure_kind = tcx.lang_items().fn_trait_kind(trait_id).unwrap();
453+
let trait_closure_kind = tcx.fn_trait_kind_from_lang_item(trait_id).unwrap();
454454
Some(Instance::resolve_closure(
455455
tcx,
456456
closure_data.closure_def_id,

0 commit comments

Comments
 (0)