Skip to content

Commit

Permalink
Auto merge of #70211 - Centril:rollup-fusltgc, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Mar 21, 2020
2 parents 5f13820 + 744bcc6 commit 98803c1
Show file tree
Hide file tree
Showing 97 changed files with 876 additions and 804 deletions.
42 changes: 20 additions & 22 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3567,7 +3567,6 @@ dependencies = [
"rustc_ast",
"rustc_attr",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
Expand Down Expand Up @@ -3598,37 +3597,21 @@ dependencies = [
"rustc_apfloat",
"rustc_ast",
"rustc_attr",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_fs_util",
"rustc_hir",
"rustc_incremental",
"rustc_index",
"rustc_metadata",
"rustc_session",
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
"serialize",
"tempfile",
]

[[package]]
name = "rustc_codegen_utils"
version = "0.0.0"
dependencies = [
"log",
"punycode",
"rustc",
"rustc-demangle",
"rustc_ast",
"rustc_data_structures",
"rustc_hir",
"rustc_metadata",
"rustc_session",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_data_structures"
version = "0.0.0"
Expand Down Expand Up @@ -3665,7 +3648,6 @@ dependencies = [
"rustc_ast",
"rustc_ast_pretty",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
Expand Down Expand Up @@ -3814,7 +3796,6 @@ dependencies = [
"rustc_builtin_macros",
"rustc_codegen_llvm",
"rustc_codegen_ssa",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
Expand All @@ -3832,6 +3813,7 @@ dependencies = [
"rustc_resolve",
"rustc_session",
"rustc_span",
"rustc_symbol_mangling",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
Expand Down Expand Up @@ -4071,7 +4053,6 @@ dependencies = [
"rustc",
"rustc_ast",
"rustc_ast_pretty",
"rustc_codegen_utils",
"rustc_data_structures",
"rustc_hir",
"rustc_parse",
Expand Down Expand Up @@ -4112,6 +4093,23 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "rustc_symbol_mangling"
version = "0.0.0"
dependencies = [
"log",
"punycode",
"rustc",
"rustc-demangle",
"rustc_ast",
"rustc_data_structures",
"rustc_hir",
"rustc_metadata",
"rustc_session",
"rustc_span",
"rustc_target",
]

[[package]]
name = "rustc_target"
version = "0.0.0"
Expand Down
1 change: 1 addition & 0 deletions src/ci/docker/dist-android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ENV TARGETS=$TARGETS,x86_64-linux-android

ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-profiler \
--arm-linux-androideabi-ndk=/android/ndk/arm-14 \
--armv7-linux-androideabi-ndk=/android/ndk/arm-14 \
--thumbv7neon-linux-androideabi-ndk=/android/ndk/arm-14 \
Expand Down
1 change: 0 additions & 1 deletion src/libprofiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ fn main() {
cfg.flag("-fno-builtin");
cfg.flag("-fvisibility=hidden");
cfg.flag("-fomit-frame-pointer");
cfg.flag("-ffreestanding");
cfg.define("VISIBILITY_HIDDEN", None);
if !target.contains("windows") {
cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ macro_rules! arena_types {
// HIR query types
[few] indexed_hir: rustc::hir::map::IndexedHir<$tcx>,
[few] hir_definitions: rustc::hir::map::definitions::Definitions,
[] hir_owner: rustc::hir::HirOwner<$tcx>,
[] hir_owner_items: rustc::hir::HirOwnerItems<$tcx>,
[] hir_owner: rustc::hir::Owner<$tcx>,
[] hir_owner_nodes: rustc::hir::OwnerNodes<$tcx>,
], $tcx);
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl DepGraph {
// bug that must be fixed before removing this.
match dep_dep_node.kind {
DepKind::hir_owner
| DepKind::hir_owner_items
| DepKind::hir_owner_nodes
| DepKind::CrateMetadata => {
if let Some(def_id) = dep_dep_node.extract_def_id(tcx) {
if def_id_corresponds_to_hir_dep_node(tcx, def_id) {
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::arena::Arena;
use crate::hir::map::definitions::{self, DefPathHash};
use crate::hir::map::{Entry, HirOwnerData, Map};
use crate::hir::{HirItem, HirOwner, HirOwnerItems};
use crate::hir::{Owner, OwnerNodes, ParentedNode};
use crate::ich::StableHashingContext;
use crate::middle::cstore::CrateStore;
use rustc_data_structures::fingerprint::Fingerprint;
Expand Down Expand Up @@ -203,30 +203,30 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
let data = &mut self.map[id.owner];

if data.with_bodies.is_none() {
data.with_bodies = Some(arena.alloc(HirOwnerItems {
data.with_bodies = Some(arena.alloc(OwnerNodes {
hash,
items: IndexVec::new(),
nodes: IndexVec::new(),
bodies: FxHashMap::default(),
}));
}

let items = data.with_bodies.as_mut().unwrap();
let nodes = data.with_bodies.as_mut().unwrap();

if i == 0 {
// Overwrite the dummy hash with the real HIR owner hash.
items.hash = hash;
nodes.hash = hash;

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

data.signature =
Some(self.arena.alloc(HirOwner { parent: entry.parent, node: entry.node }));
Some(self.arena.alloc(Owner { parent: entry.parent, node: entry.node }));
} else {
assert_eq!(entry.parent.owner, id.owner);
insert_vec_map(
&mut items.items,
&mut nodes.nodes,
id.local_id,
HirItem { parent: entry.parent.local_id, node: entry.node },
ParentedNode { parent: entry.parent.local_id, node: entry.node },
);
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub use self::definitions::{
DefKey, DefPath, DefPathData, DefPathHash, Definitions, DisambiguatedDefPathData,
};

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

pub(super) struct HirOwnerData<'hir> {
pub(super) signature: Option<&'hir HirOwner<'hir>>,
pub(super) with_bodies: Option<&'hir mut HirOwnerItems<'hir>>,
pub(super) signature: Option<&'hir Owner<'hir>>,
pub(super) with_bodies: Option<&'hir mut OwnerNodes<'hir>>,
}

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

Expand All @@ -373,7 +376,7 @@ impl<'hir> Map<'hir> {
}

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

pub fn fn_decl_by_hir_id(&self, hir_id: HirId) -> Option<&'hir FnDecl<'hir>> {
Expand Down
22 changes: 11 additions & 11 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use rustc_hir::ItemLocalId;
use rustc_hir::Node;
use rustc_index::vec::IndexVec;

pub struct HirOwner<'tcx> {
pub struct Owner<'tcx> {
parent: HirId,
node: Node<'tcx>,
}

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwner<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Owner<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let HirOwner { parent, node } = self;
let Owner { parent, node } = self;
hcx.while_hashing_hir_bodies(false, |hcx| {
parent.hash_stable(hcx, hasher);
node.hash_stable(hcx, hasher);
Expand All @@ -34,22 +34,22 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwner<'tcx> {
}

#[derive(Clone)]
pub struct HirItem<'tcx> {
pub struct ParentedNode<'tcx> {
parent: ItemLocalId,
node: Node<'tcx>,
}

pub struct HirOwnerItems<'tcx> {
pub struct OwnerNodes<'tcx> {
hash: Fingerprint,
items: IndexVec<ItemLocalId, Option<HirItem<'tcx>>>,
nodes: IndexVec<ItemLocalId, Option<ParentedNode<'tcx>>>,
bodies: FxHashMap<ItemLocalId, &'tcx Body<'tcx>>,
}

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for HirOwnerItems<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for OwnerNodes<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
// We ignore the `items` and `bodies` fields since these refer to information included in
// We ignore the `nodes` and `bodies` fields since these refer to information included in
// `hash` which is hashed in the collector and used for the crate hash.
let HirOwnerItems { hash, items: _, bodies: _ } = *self;
let OwnerNodes { hash, nodes: _, bodies: _ } = *self;
hash.hash_stable(hcx, hasher);
}
}
Expand Down Expand Up @@ -79,8 +79,8 @@ pub fn provide(providers: &mut Providers<'_>) {
&tcx.untracked_crate.modules[&module]
};
providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature.unwrap();
providers.hir_owner_items = |tcx, id| {
tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|items| &**items).unwrap()
providers.hir_owner_nodes = |tcx, id| {
tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|nodes| &**nodes).unwrap()
};
map::provide(providers);
}
11 changes: 6 additions & 5 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ macro_rules! err_exhaust {
};
}

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

#[macro_export]
Expand All @@ -58,12 +59,12 @@ macro_rules! throw_unsup_format {

#[macro_export]
macro_rules! throw_inval {
($($tt:tt)*) => { return Err(err_inval!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_inval!($($tt)*))? };
}

#[macro_export]
macro_rules! throw_ub {
($($tt:tt)*) => { return Err(err_ub!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_ub!($($tt)*))? };
}

#[macro_export]
Expand All @@ -73,13 +74,13 @@ macro_rules! throw_ub_format {

#[macro_export]
macro_rules! throw_exhaust {
($($tt:tt)*) => { return Err(err_exhaust!($($tt)*).into()) };
($($tt:tt)*) => { Err::<!, _>(err_exhaust!($($tt)*))? };
}

#[macro_export]
macro_rules! throw_machine_stop {
($($tt:tt)*) => {
return Err($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)).into())
Err::<!, _>($crate::mir::interpret::InterpError::MachineStop(Box::new($($tt)*)))?
};
}

Expand Down
13 changes: 7 additions & 6 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,28 @@ rustc_queries! {
}

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

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

// The HIR items which do not themselves have a `LocalDefId` and are
// owned by another HIR item with a `LocalDefId`.
// Gives access to the HIR nodes and bodies inside the HIR owner `key`.
//
// This can be conveniently accessed by methods on `tcx.hir()`.
// Avoid calling this query directly.
query hir_owner_items(key: LocalDefId) -> &'tcx HirOwnerItems<'tcx> {
query hir_owner_nodes(key: LocalDefId) -> &'tcx crate::hir::OwnerNodes<'tcx> {
eval_always
desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn encode_metadata(self) -> EncodedMetadata {
let _prof_timer = self.prof.generic_activity("generate_crate_metadata");
let _prof_timer = self.prof.verbose_generic_activity("generate_crate_metadata");
self.cstore.encode_metadata(self)
}

Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3148,6 +3148,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
context::provide(providers);
erase_regions::provide(providers);
layout::provide(providers);
super::util::bug::provide(providers);
*providers = ty::query::Providers {
trait_impls_of: trait_def::trait_impls_of_provider,
all_local_trait_impls: trait_def::all_local_trait_impls,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,9 @@ pub trait PrettyPrinter<'tcx>:

if self.tcx().sess.verbose() {
p!(write(
" closure_kind_ty={:?} closure_sig_ty={:?}",
" closure_kind_ty={:?} closure_sig_as_fn_ptr_ty={:?}",
substs.as_closure().kind_ty(did, self.tcx()),
substs.as_closure().sig_ty(did, self.tcx())
substs.as_closure().sig_as_fn_ptr_ty(did, self.tcx())
));
}

Expand Down
Loading

0 comments on commit 98803c1

Please sign in to comment.