Skip to content

Commit e161368

Browse files
committed
Auto merge of #154466 - fmease:rollup-RqOocPd, r=fmease
Rollup of 10 pull requests Successful merges: - #154070 (Unstable book options parser) - #154371 (Use LocalDefId for more tcx method calls) - #154405 (Improve doc comment unicode guidance) - #154431 (Avoid ICE in explicit reference cast suggestion for unrelated leaf pr…) - #153528 (Fix LegacyKeyValueFormat report from docker build: mips) - #154246 (Add test for issue #101532: dead code warnings in const _) - #154421 (Rustdoc rejects html emits with json output) - #154428 (bootstrap: `-Zjson-target-spec` for synthetic targets) - #154437 (bootstrap.example.toml: Hint how to allow `build.warnings`) - #154454 (fix: [rustfmt] prevent panic when rewritng associated item delegations) Failed merges: - #154450 (Use the normal arg-parsing machinery for `-Zassert-incr-state`)
2 parents fda6d37 + 59d8609 commit e161368

File tree

55 files changed

+1163
-692
lines changed

Some content is hidden

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

55 files changed

+1163
-692
lines changed

‎Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6088,6 +6088,8 @@ name = "unstable-book-gen"
60886088
version = "0.1.0"
60896089
dependencies = [
60906090
"num-traits",
6091+
"proc-macro2",
6092+
"syn 2.0.110",
60916093
"tidy",
60926094
]
60936095

‎bootstrap.example.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,8 @@
826826
# in the sysroot. It is required for running nvptx tests.
827827
#rust.llvm-bitcode-linker = false
828828

829-
# Whether to deny warnings in crates
829+
# Whether to deny warnings in crates. Set to `false` to avoid
830+
# error: warnings are denied by `build.warnings` configuration
830831
#rust.deny-warnings = true
831832

832833
# Print backtrace on internal compiler errors during bootstrap

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,10 +1569,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
15691569
let tcx = self.infcx.tcx;
15701570
let generics = tcx.generics_of(self.mir_def_id());
15711571

1572-
let Some(hir_generics) = tcx
1573-
.typeck_root_def_id(self.mir_def_id().to_def_id())
1574-
.as_local()
1575-
.and_then(|def_id| tcx.hir_get_generics(def_id))
1572+
let Some(hir_generics) =
1573+
tcx.hir_get_generics(tcx.typeck_root_def_id_local(self.mir_def_id()))
15761574
else {
15771575
return;
15781576
};

‎compiler/rustc_borrowck/src/diagnostics/mod.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,12 +1274,9 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
12741274
if let ty::Param(param_ty) = *self_ty.kind()
12751275
&& let generics = self.infcx.tcx.generics_of(self.mir_def_id())
12761276
&& let param = generics.type_param(param_ty, self.infcx.tcx)
1277-
&& let Some(hir_generics) = self
1278-
.infcx
1279-
.tcx
1280-
.typeck_root_def_id(self.mir_def_id().to_def_id())
1281-
.as_local()
1282-
.and_then(|def_id| self.infcx.tcx.hir_get_generics(def_id))
1277+
&& let Some(hir_generics) = self.infcx.tcx.hir_get_generics(
1278+
self.infcx.tcx.typeck_root_def_id_local(self.mir_def_id()),
1279+
)
12831280
&& let spans = hir_generics
12841281
.predicates
12851282
.iter()

‎compiler/rustc_borrowck/src/universal_regions.rs‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,10 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
476476
let mut indices = self.compute_indices(fr_static, defining_ty);
477477
debug!("build: indices={:?}", indices);
478478

479-
let typeck_root_def_id = self.infcx.tcx.typeck_root_def_id(self.mir_def.to_def_id());
480-
481479
// If this is a 'root' body (not a closure/coroutine/inline const), then
482480
// there are no extern regions, so the local regions start at the same
483481
// position as the (empty) sub-list of extern regions
484-
let first_local_index = if self.mir_def.to_def_id() == typeck_root_def_id {
482+
let first_local_index = if !self.infcx.tcx.is_typeck_child(self.mir_def.to_def_id()) {
485483
first_extern_index
486484
} else {
487485
// If this is a closure, coroutine, or inline-const, then the late-bound regions from the enclosing
@@ -583,7 +581,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
583581
/// see `DefiningTy` for details.
584582
fn defining_ty(&self) -> DefiningTy<'tcx> {
585583
let tcx = self.infcx.tcx;
586-
let typeck_root_def_id = tcx.typeck_root_def_id(self.mir_def.to_def_id());
584+
let typeck_root_def_id = tcx.typeck_root_def_id_local(self.mir_def);
587585

588586
match tcx.hir_body_owner_kind(self.mir_def) {
589587
BodyOwnerKind::Closure | BodyOwnerKind::Fn => {
@@ -614,7 +612,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
614612

615613
BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(..) => {
616614
let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
617-
if self.mir_def.to_def_id() == typeck_root_def_id {
615+
if self.mir_def == typeck_root_def_id {
618616
let args = self.infcx.replace_free_regions_with_nll_infer_vars(
619617
NllRegionVariableOrigin::FreeRegion,
620618
identity_args,
@@ -660,7 +658,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
660658
defining_ty: DefiningTy<'tcx>,
661659
) -> UniversalRegionIndices<'tcx> {
662660
let tcx = self.infcx.tcx;
663-
let typeck_root_def_id = tcx.typeck_root_def_id(self.mir_def.to_def_id());
661+
let typeck_root_def_id = tcx.typeck_root_def_id_local(self.mir_def);
664662
let identity_args = GenericArgs::identity_for_item(tcx, typeck_root_def_id);
665663
let renumbered_args = defining_ty.args();
666664

@@ -948,16 +946,14 @@ fn for_each_late_bound_region_in_recursive_scope<'tcx>(
948946
mut mir_def_id: LocalDefId,
949947
mut f: impl FnMut(ty::Region<'tcx>),
950948
) {
951-
let typeck_root_def_id = tcx.typeck_root_def_id(mir_def_id.to_def_id());
952-
953949
// Walk up the tree, collecting late-bound regions until we hit the typeck root
954950
loop {
955951
for_each_late_bound_region_in_item(tcx, mir_def_id, &mut f);
956952

957-
if mir_def_id.to_def_id() == typeck_root_def_id {
958-
break;
959-
} else {
953+
if tcx.is_typeck_child(mir_def_id.to_def_id()) {
960954
mir_def_id = tcx.local_parent(mir_def_id);
955+
} else {
956+
break;
961957
}
962958
}
963959
}

‎compiler/rustc_hir_analysis/src/check/region.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::mem;
1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_hir as hir;
1313
use rustc_hir::def::{CtorKind, DefKind, Res};
14-
use rustc_hir::def_id::DefId;
14+
use rustc_hir::def_id::LocalDefId;
1515
use rustc_hir::intravisit::{self, Visitor};
1616
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
1717
use rustc_index::Idx;
@@ -849,13 +849,13 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
849849
/// re-use in incremental scenarios. We may sometimes need to rerun the
850850
/// type checker even when the HIR hasn't changed, and in those cases
851851
/// we can avoid reconstructing the region scope tree.
852-
pub(crate) fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
853-
let typeck_root_def_id = tcx.typeck_root_def_id(def_id);
852+
pub(crate) fn region_scope_tree(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &ScopeTree {
853+
let typeck_root_def_id = tcx.typeck_root_def_id_local(def_id);
854854
if typeck_root_def_id != def_id {
855855
return tcx.region_scope_tree(typeck_root_def_id);
856856
}
857857

858-
let scope_tree = if let Some(body) = tcx.hir_maybe_body_owned_by(def_id.expect_local()) {
858+
let scope_tree = if let Some(body) = tcx.hir_maybe_body_owned_by(def_id) {
859859
let mut visitor = ScopeResolutionVisitor {
860860
tcx,
861861
scope_tree: ScopeTree::default(),

‎compiler/rustc_hir_analysis/src/collect/generics_of.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
7676
| Node::Ctor(..)
7777
| Node::Field(_) => {
7878
let parent_id = tcx.hir_get_parent_item(hir_id);
79-
Some(parent_id.to_def_id())
79+
Some(parent_id.def_id)
8080
}
8181
// FIXME(#43408) always enable this once `lazy_normalization` is
8282
// stable enough and does not need a feature gate anymore.
8383
Node::AnonConst(_) => {
84-
let parent_did = tcx.parent(def_id.to_def_id());
84+
let parent_did = tcx.local_parent(def_id);
8585
debug!(?parent_did);
8686

8787
let mut in_param_ty = false;
@@ -175,7 +175,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
175175
}
176176
Node::ConstBlock(_)
177177
| Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure { .. }, .. }) => {
178-
Some(tcx.typeck_root_def_id(def_id.to_def_id()))
178+
Some(tcx.typeck_root_def_id_local(def_id))
179179
}
180180
Node::OpaqueTy(&hir::OpaqueTy {
181181
origin:
@@ -188,7 +188,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
188188
} else {
189189
assert_matches!(tcx.def_kind(fn_def_id), DefKind::AssocFn | DefKind::Fn);
190190
}
191-
Some(fn_def_id.to_def_id())
191+
Some(fn_def_id)
192192
}
193193
Node::OpaqueTy(&hir::OpaqueTy {
194194
origin: hir::OpaqueTyOrigin::TyAlias { parent, in_assoc_ty },
@@ -202,7 +202,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
202202
debug!("generics_of: parent of opaque ty {:?} is {:?}", def_id, parent);
203203
// Opaque types are always nested within another item, and
204204
// inherit the generics of the item.
205-
Some(parent.to_def_id())
205+
Some(parent)
206206
}
207207

208208
// All of these nodes have no parent from which to inherit generics.
@@ -380,7 +380,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
380380
own_params.iter().map(|param| (param.def_id, param.index)).collect();
381381

382382
ty::Generics {
383-
parent: parent_def_id,
383+
parent: parent_def_id.map(LocalDefId::to_def_id),
384384
parent_count,
385385
own_params,
386386
param_def_id_to_index,

‎compiler/rustc_hir_analysis/src/collect/predicates_of.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
107107
);
108108

109109
return ty::GenericPredicates {
110-
parent: Some(tcx.parent(def_id.to_def_id())),
110+
parent: Some(tcx.local_parent(def_id).to_def_id()),
111111
predicates: tcx.arena.alloc_from_iter(predicates),
112112
};
113113
}

‎compiler/rustc_hir_typeck/src/closure.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7272
debug!(?bound_sig, ?liberated_sig);
7373

7474
let parent_args =
75-
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id(expr_def_id.to_def_id()));
75+
GenericArgs::identity_for_item(tcx, tcx.typeck_root_def_id_local(expr_def_id));
7676

7777
let tupled_upvars_ty = self.next_ty_var(expr_span);
7878

‎compiler/rustc_hir_typeck/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ fn typeck_with_inspect<'tcx>(
106106
) -> &'tcx ty::TypeckResults<'tcx> {
107107
// Closures' typeck results come from their outermost function,
108108
// as they are part of the same "inference environment".
109-
let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id()).expect_local();
109+
let typeck_root_def_id = tcx.typeck_root_def_id_local(def_id);
110110
if typeck_root_def_id != def_id {
111111
return tcx.typeck(typeck_root_def_id);
112112
}

0 commit comments

Comments
 (0)