Skip to content

Commit 98803c1

Browse files
committed
Auto merge of #70211 - Centril:rollup-fusltgc, r=Centril
Rollup of 8 pull requests Successful merges: - #67888 (Prefetch some queries used by the metadata encoder) - #69934 (Update the mir inline costs) - #69965 (Refactorings to get rid of rustc_codegen_utils) - #70054 (Build dist-android with --enable-profiler) - #70089 (rustc_infer: remove InferCtxt::closure_sig as the FnSig is always shallowly known.) - #70092 (hir: replace "items" terminology with "nodes" where appropriate.) - #70138 (do not 'return' in 'throw_' macros) - #70151 (Update stdarch submodule) Failed merges: - #70074 (Expand: nix all fatal errors) r? @ghost
2 parents 5f13820 + 744bcc6 commit 98803c1

File tree

97 files changed

+876
-804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+876
-804
lines changed

Cargo.lock

+20-22
Original file line numberDiff line numberDiff line change
@@ -3567,7 +3567,6 @@ dependencies = [
35673567
"rustc_ast",
35683568
"rustc_attr",
35693569
"rustc_codegen_ssa",
3570-
"rustc_codegen_utils",
35713570
"rustc_data_structures",
35723571
"rustc_errors",
35733572
"rustc_feature",
@@ -3598,37 +3597,21 @@ dependencies = [
35983597
"rustc_apfloat",
35993598
"rustc_ast",
36003599
"rustc_attr",
3601-
"rustc_codegen_utils",
36023600
"rustc_data_structures",
36033601
"rustc_errors",
36043602
"rustc_fs_util",
36053603
"rustc_hir",
36063604
"rustc_incremental",
36073605
"rustc_index",
3606+
"rustc_metadata",
36083607
"rustc_session",
36093608
"rustc_span",
3609+
"rustc_symbol_mangling",
36103610
"rustc_target",
36113611
"serialize",
36123612
"tempfile",
36133613
]
36143614

3615-
[[package]]
3616-
name = "rustc_codegen_utils"
3617-
version = "0.0.0"
3618-
dependencies = [
3619-
"log",
3620-
"punycode",
3621-
"rustc",
3622-
"rustc-demangle",
3623-
"rustc_ast",
3624-
"rustc_data_structures",
3625-
"rustc_hir",
3626-
"rustc_metadata",
3627-
"rustc_session",
3628-
"rustc_span",
3629-
"rustc_target",
3630-
]
3631-
36323615
[[package]]
36333616
name = "rustc_data_structures"
36343617
version = "0.0.0"
@@ -3665,7 +3648,6 @@ dependencies = [
36653648
"rustc_ast",
36663649
"rustc_ast_pretty",
36673650
"rustc_codegen_ssa",
3668-
"rustc_codegen_utils",
36693651
"rustc_data_structures",
36703652
"rustc_error_codes",
36713653
"rustc_errors",
@@ -3814,7 +3796,6 @@ dependencies = [
38143796
"rustc_builtin_macros",
38153797
"rustc_codegen_llvm",
38163798
"rustc_codegen_ssa",
3817-
"rustc_codegen_utils",
38183799
"rustc_data_structures",
38193800
"rustc_errors",
38203801
"rustc_expand",
@@ -3832,6 +3813,7 @@ dependencies = [
38323813
"rustc_resolve",
38333814
"rustc_session",
38343815
"rustc_span",
3816+
"rustc_symbol_mangling",
38353817
"rustc_target",
38363818
"rustc_trait_selection",
38373819
"rustc_traits",
@@ -4071,7 +4053,6 @@ dependencies = [
40714053
"rustc",
40724054
"rustc_ast",
40734055
"rustc_ast_pretty",
4074-
"rustc_codegen_utils",
40754056
"rustc_data_structures",
40764057
"rustc_hir",
40774058
"rustc_parse",
@@ -4112,6 +4093,23 @@ dependencies = [
41124093
"unicode-width",
41134094
]
41144095

4096+
[[package]]
4097+
name = "rustc_symbol_mangling"
4098+
version = "0.0.0"
4099+
dependencies = [
4100+
"log",
4101+
"punycode",
4102+
"rustc",
4103+
"rustc-demangle",
4104+
"rustc_ast",
4105+
"rustc_data_structures",
4106+
"rustc_hir",
4107+
"rustc_metadata",
4108+
"rustc_session",
4109+
"rustc_span",
4110+
"rustc_target",
4111+
]
4112+
41154113
[[package]]
41164114
name = "rustc_target"
41174115
version = "0.0.0"

src/ci/docker/dist-android/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ENV TARGETS=$TARGETS,x86_64-linux-android
2323

2424
ENV RUST_CONFIGURE_ARGS \
2525
--enable-extended \
26+
--enable-profiler \
2627
--arm-linux-androideabi-ndk=/android/ndk/arm-14 \
2728
--armv7-linux-androideabi-ndk=/android/ndk/arm-14 \
2829
--thumbv7neon-linux-androideabi-ndk=/android/ndk/arm-14 \

src/libprofiler_builtins/build.rs

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ fn main() {
4141
cfg.flag("-fno-builtin");
4242
cfg.flag("-fvisibility=hidden");
4343
cfg.flag("-fomit-frame-pointer");
44-
cfg.flag("-ffreestanding");
4544
cfg.define("VISIBILITY_HIDDEN", None);
4645
if !target.contains("windows") {
4746
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));

src/librustc/arena.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ macro_rules! arena_types {
165165
// HIR query types
166166
[few] indexed_hir: rustc::hir::map::IndexedHir<$tcx>,
167167
[few] hir_definitions: rustc::hir::map::definitions::Definitions,
168-
[] hir_owner: rustc::hir::HirOwner<$tcx>,
169-
[] hir_owner_items: rustc::hir::HirOwnerItems<$tcx>,
168+
[] hir_owner: rustc::hir::Owner<$tcx>,
169+
[] hir_owner_nodes: rustc::hir::OwnerNodes<$tcx>,
170170
], $tcx);
171171
)
172172
}

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl DepGraph {
659659
// bug that must be fixed before removing this.
660660
match dep_dep_node.kind {
661661
DepKind::hir_owner
662-
| DepKind::hir_owner_items
662+
| DepKind::hir_owner_nodes
663663
| DepKind::CrateMetadata => {
664664
if let Some(def_id) = dep_dep_node.extract_def_id(tcx) {
665665
if def_id_corresponds_to_hir_dep_node(tcx, def_id) {

src/librustc/hir/map/collector.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::arena::Arena;
22
use crate::hir::map::definitions::{self, DefPathHash};
33
use crate::hir::map::{Entry, HirOwnerData, Map};
4-
use crate::hir::{HirItem, HirOwner, HirOwnerItems};
4+
use crate::hir::{Owner, OwnerNodes, ParentedNode};
55
use crate::ich::StableHashingContext;
66
use crate::middle::cstore::CrateStore;
77
use rustc_data_structures::fingerprint::Fingerprint;
@@ -203,30 +203,30 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
203203
let data = &mut self.map[id.owner];
204204

205205
if data.with_bodies.is_none() {
206-
data.with_bodies = Some(arena.alloc(HirOwnerItems {
206+
data.with_bodies = Some(arena.alloc(OwnerNodes {
207207
hash,
208-
items: IndexVec::new(),
208+
nodes: IndexVec::new(),
209209
bodies: FxHashMap::default(),
210210
}));
211211
}
212212

213-
let items = data.with_bodies.as_mut().unwrap();
213+
let nodes = data.with_bodies.as_mut().unwrap();
214214

215215
if i == 0 {
216216
// Overwrite the dummy hash with the real HIR owner hash.
217-
items.hash = hash;
217+
nodes.hash = hash;
218218

219219
// FIXME: feature(impl_trait_in_bindings) broken and trigger this assert
220220
//assert!(data.signature.is_none());
221221

222222
data.signature =
223-
Some(self.arena.alloc(HirOwner { parent: entry.parent, node: entry.node }));
223+
Some(self.arena.alloc(Owner { parent: entry.parent, node: entry.node }));
224224
} else {
225225
assert_eq!(entry.parent.owner, id.owner);
226226
insert_vec_map(
227-
&mut items.items,
227+
&mut nodes.nodes,
228228
id.local_id,
229-
HirItem { parent: entry.parent.local_id, node: entry.node },
229+
ParentedNode { parent: entry.parent.local_id, node: entry.node },
230230
);
231231
}
232232
}

src/librustc/hir/map/mod.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub use self::definitions::{
33
DefKey, DefPath, DefPathData, DefPathHash, Definitions, DisambiguatedDefPathData,
44
};
55

6-
use crate::hir::{HirOwner, HirOwnerItems};
6+
use crate::hir::{Owner, OwnerNodes};
77
use crate::ty::query::Providers;
88
use crate::ty::TyCtxt;
99
use rustc_ast::ast::{self, Name, NodeId};
@@ -130,8 +130,8 @@ fn is_body_owner<'hir>(node: Node<'hir>, hir_id: HirId) -> bool {
130130
}
131131

132132
pub(super) struct HirOwnerData<'hir> {
133-
pub(super) signature: Option<&'hir HirOwner<'hir>>,
134-
pub(super) with_bodies: Option<&'hir mut HirOwnerItems<'hir>>,
133+
pub(super) signature: Option<&'hir Owner<'hir>>,
134+
pub(super) with_bodies: Option<&'hir mut OwnerNodes<'hir>>,
135135
}
136136

137137
pub struct IndexedHir<'hir> {
@@ -345,9 +345,12 @@ impl<'hir> Map<'hir> {
345345
let owner = self.tcx.hir_owner(id.owner);
346346
Entry { parent: owner.parent, node: owner.node }
347347
} else {
348-
let owner = self.tcx.hir_owner_items(id.owner);
349-
let item = owner.items[id.local_id].as_ref().unwrap();
350-
Entry { parent: HirId { owner: id.owner, local_id: item.parent }, node: item.node }
348+
let owner = self.tcx.hir_owner_nodes(id.owner);
349+
let node = owner.nodes[id.local_id].as_ref().unwrap();
350+
// FIXME(eddyb) use a single generic type insted of having both
351+
// `Entry` and `ParentedNode`, which are effectively the same.
352+
// Alternatively, rewrite code using `Entry` to use `ParentedNode`.
353+
Entry { parent: HirId { owner: id.owner, local_id: node.parent }, node: node.node }
351354
}
352355
}
353356

@@ -373,7 +376,7 @@ impl<'hir> Map<'hir> {
373376
}
374377

375378
pub fn body(&self, id: BodyId) -> &'hir Body<'hir> {
376-
self.tcx.hir_owner_items(id.hir_id.owner).bodies.get(&id.hir_id.local_id).unwrap()
379+
self.tcx.hir_owner_nodes(id.hir_id.owner).bodies.get(&id.hir_id.local_id).unwrap()
377380
}
378381

379382
pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {

src/librustc/hir/mod.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ use rustc_hir::ItemLocalId;
1818
use rustc_hir::Node;
1919
use rustc_index::vec::IndexVec;
2020

21-
pub struct HirOwner<'tcx> {
21+
pub struct Owner<'tcx> {
2222
parent: HirId,
2323
node: Node<'tcx>,
2424
}
2525

26-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwner<'tcx> {
26+
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
2727
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
28-
let HirOwner { parent, node } = self;
28+
let Owner { parent, node } = self;
2929
hcx.while_hashing_hir_bodies(false, |hcx| {
3030
parent.hash_stable(hcx, hasher);
3131
node.hash_stable(hcx, hasher);
@@ -34,22 +34,22 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwner<'tcx> {
3434
}
3535

3636
#[derive(Clone)]
37-
pub struct HirItem<'tcx> {
37+
pub struct ParentedNode<'tcx> {
3838
parent: ItemLocalId,
3939
node: Node<'tcx>,
4040
}
4141

42-
pub struct HirOwnerItems<'tcx> {
42+
pub struct OwnerNodes<'tcx> {
4343
hash: Fingerprint,
44-
items: IndexVec<ItemLocalId, Option<HirItem<'tcx>>>,
44+
nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>,
4545
bodies: FxHashMap<ItemLocalId, &'tcx Body<'tcx>>,
4646
}
4747

48-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwnerItems<'tcx> {
48+
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OwnerNodes<'tcx> {
4949
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
50-
// We ignore the `items` and `bodies` fields since these refer to information included in
50+
// We ignore the `nodes` and `bodies` fields since these refer to information included in
5151
// `hash` which is hashed in the collector and used for the crate hash.
52-
let HirOwnerItems { hash, items: _, bodies: _ } = *self;
52+
let OwnerNodes { hash, nodes: _, bodies: _ } = *self;
5353
hash.hash_stable(hcx, hasher);
5454
}
5555
}
@@ -79,8 +79,8 @@ pub fn provide(providers: &mut Providers<'_>) {
7979
&tcx.untracked_crate.modules[&module]
8080
};
8181
providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature.unwrap();
82-
providers.hir_owner_items = |tcx, id| {
83-
tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|items| &**items).unwrap()
82+
providers.hir_owner_nodes = |tcx, id| {
83+
tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|nodes| &**nodes).unwrap()
8484
};
8585
map::provide(providers);
8686
}

src/librustc/mir/interpret/mod.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ macro_rules! err_exhaust {
4646
};
4747
}
4848

49+
// In the `throw_*` macros, avoid `return` to make them work with `try {}`.
4950
#[macro_export]
5051
macro_rules! throw_unsup {
51-
($($tt:tt)*) => { return Err(err_unsup!($($tt)*).into()) };
52+
($($tt:tt)*) => { Err::<!, _>(err_unsup!($($tt)*))? };
5253
}
5354

5455
#[macro_export]
@@ -58,12 +59,12 @@ macro_rules! throw_unsup_format {
5859

5960
#[macro_export]
6061
macro_rules! throw_inval {
61-
($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
62+
($($tt:tt)*) => { Err::<!, _>(err_inval!($($tt)*))? };
6263
}
6364

6465
#[macro_export]
6566
macro_rules! throw_ub {
66-
($($tt:tt)*) => { return Err(err_ub!($($tt)*).into()) };
67+
($($tt:tt)*) => { Err::<!, _>(err_ub!($($tt)*))? };
6768
}
6869

6970
#[macro_export]
@@ -73,13 +74,13 @@ macro_rules! throw_ub_format {
7374

7475
#[macro_export]
7576
macro_rules! throw_exhaust {
76-
($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
77+
($($tt:tt)*) => { Err::<!, _>(err_exhaust!($($tt)*))? };
7778
}
7879

7980
#[macro_export]
8081
macro_rules! throw_machine_stop {
8182
($($tt:tt)*) => {
82-
return Err($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)).into())
83+
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
8384
};
8485
}
8586

src/librustc/query/mod.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,28 @@ rustc_queries! {
6464
}
6565

6666
// The items in a module.
67+
//
6768
// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
6869
// Avoid calling this query directly.
6970
query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems {
7071
eval_always
7172
desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) }
7273
}
7374

74-
// An HIR item with a `LocalDefId` that can own other HIR items which do
75-
// not themselves have a `LocalDefId`.
75+
// Gives access to the HIR node for the HIR owner `key`.
76+
//
7677
// This can be conveniently accessed by methods on `tcx.hir()`.
7778
// Avoid calling this query directly.
78-
query hir_owner(key: LocalDefId) -> &'tcx HirOwner<'tcx> {
79+
query hir_owner(key: LocalDefId) -> &'tcx crate::hir::Owner<'tcx> {
7980
eval_always
8081
desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) }
8182
}
8283

83-
// The HIR items which do not themselves have a `LocalDefId` and are
84-
// owned by another HIR item with a `LocalDefId`.
84+
// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
85+
//
8586
// This can be conveniently accessed by methods on `tcx.hir()`.
8687
// Avoid calling this query directly.
87-
query hir_owner_items(key: LocalDefId) -> &'tcx HirOwnerItems<'tcx> {
88+
query hir_owner_nodes(key: LocalDefId) -> &'tcx crate::hir::OwnerNodes<'tcx> {
8889
eval_always
8990
desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
9091
}

src/librustc/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ impl<'tcx> TyCtxt<'tcx> {
13231323
}
13241324

13251325
pub fn encode_metadata(self) -> EncodedMetadata {
1326-
let _prof_timer = self.prof.generic_activity("generate_crate_metadata");
1326+
let _prof_timer = self.prof.verbose_generic_activity("generate_crate_metadata");
13271327
self.cstore.encode_metadata(self)
13281328
}
13291329

src/librustc/ty/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3148,6 +3148,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
31483148
context::provide(providers);
31493149
erase_regions::provide(providers);
31503150
layout::provide(providers);
3151+
super::util::bug::provide(providers);
31513152
*providers = ty::query::Providers {
31523153
trait_impls_of: trait_def::trait_impls_of_provider,
31533154
all_local_trait_impls: trait_def::all_local_trait_impls,

src/librustc/ty/print/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,9 @@ pub trait PrettyPrinter<'tcx>:
681681

682682
if self.tcx().sess.verbose() {
683683
p!(write(
684-
" closure_kind_ty={:?} closure_sig_ty={:?}",
684+
" closure_kind_ty={:?} closure_sig_as_fn_ptr_ty={:?}",
685685
substs.as_closure().kind_ty(did, self.tcx()),
686-
substs.as_closure().sig_ty(did, self.tcx())
686+
substs.as_closure().sig_as_fn_ptr_ty(did, self.tcx())
687687
));
688688
}
689689

0 commit comments

Comments
 (0)