Skip to content

Commit 3bb0171

Browse files
committed
Auto merge of #118319 - GuillaumeGomez:rollup-vte50yq, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #118296 (rustdoc: replace `elemIsInParent` with `Node.contains`) - #118302 (Clean dead codes) - #118311 (merge `DefKind::Coroutine` into `Defkind::Closure`) - #118318 (Remove myself from users on vacation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3dbb4da + cb04603 commit 3bb0171

File tree

40 files changed

+99
-376
lines changed

40 files changed

+99
-376
lines changed

compiler/rustc_ast_lowering/src/index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
8989
}
9090
}
9191

92-
self.nodes.insert(hir_id.local_id, ParentedNode { parent: self.parent_node, node: node });
92+
self.nodes.insert(hir_id.local_id, ParentedNode { parent: self.parent_node, node });
9393
}
9494

9595
fn with_parent<F: FnOnce(&mut Self)>(&mut self, parent_node_id: HirId, f: F) {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -2072,8 +2072,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20722072
.map(|name| format!("function `{name}`"))
20732073
.unwrap_or_else(|| {
20742074
match &self.infcx.tcx.def_kind(self.mir_def_id()) {
2075+
DefKind::Closure
2076+
if self
2077+
.infcx
2078+
.tcx
2079+
.is_coroutine(self.mir_def_id().to_def_id()) =>
2080+
{
2081+
"enclosing coroutine"
2082+
}
20752083
DefKind::Closure => "enclosing closure",
2076-
DefKind::Coroutine => "enclosing coroutine",
20772084
kind => bug!("expected closure or coroutine, found {:?}", kind),
20782085
}
20792086
.to_string()

compiler/rustc_borrowck/src/type_check/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2678,8 +2678,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
26782678
let typeck_root_args = ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id);
26792679

26802680
let parent_args = match tcx.def_kind(def_id) {
2681+
DefKind::Closure if tcx.is_coroutine(def_id.to_def_id()) => {
2682+
args.as_coroutine().parent_args()
2683+
}
26812684
DefKind::Closure => args.as_closure().parent_args(),
2682-
DefKind::Coroutine => args.as_coroutine().parent_args(),
26832685
DefKind::InlineConst => args.as_inline_const().parent_args(),
26842686
other => bug!("unexpected item {:?}", other),
26852687
};

compiler/rustc_borrowck/src/universal_regions.rs

-60
Original file line numberDiff line numberDiff line change
@@ -737,18 +737,6 @@ trait InferCtxtExt<'tcx> {
737737
) -> T
738738
where
739739
T: TypeFoldable<TyCtxt<'tcx>>;
740-
741-
fn instantiate_bound_regions_with_nll_infer_vars_in_recursive_scope(
742-
&self,
743-
mir_def_id: LocalDefId,
744-
indices: &mut UniversalRegionIndices<'tcx>,
745-
);
746-
747-
fn instantiate_bound_regions_with_nll_infer_vars_in_item(
748-
&self,
749-
mir_def_id: LocalDefId,
750-
indices: &mut UniversalRegionIndices<'tcx>,
751-
);
752740
}
753741

754742
impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
@@ -799,54 +787,6 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
799787
});
800788
value
801789
}
802-
803-
/// Finds late-bound regions that do not appear in the parameter listing and adds them to the
804-
/// indices vector. Typically, we identify late-bound regions as we process the inputs and
805-
/// outputs of the closure/function. However, sometimes there are late-bound regions which do
806-
/// not appear in the fn parameters but which are nonetheless in scope. The simplest case of
807-
/// this are unused functions, like fn foo<'a>() { } (see e.g., #51351). Despite not being used,
808-
/// users can still reference these regions (e.g., let x: &'a u32 = &22;), so we need to create
809-
/// entries for them and store them in the indices map. This code iterates over the complete
810-
/// set of late-bound regions and checks for any that we have not yet seen, adding them to the
811-
/// inputs vector.
812-
#[instrument(skip(self, indices))]
813-
fn instantiate_bound_regions_with_nll_infer_vars_in_recursive_scope(
814-
&self,
815-
mir_def_id: LocalDefId,
816-
indices: &mut UniversalRegionIndices<'tcx>,
817-
) {
818-
for_each_late_bound_region_in_recursive_scope(self.tcx, mir_def_id, |r| {
819-
debug!(?r);
820-
if !indices.indices.contains_key(&r) {
821-
let region_vid = {
822-
let name = r.get_name_or_anon();
823-
self.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
824-
};
825-
826-
debug!(?region_vid);
827-
indices.insert_late_bound_region(r, region_vid.as_var());
828-
}
829-
});
830-
}
831-
832-
#[instrument(skip(self, indices))]
833-
fn instantiate_bound_regions_with_nll_infer_vars_in_item(
834-
&self,
835-
mir_def_id: LocalDefId,
836-
indices: &mut UniversalRegionIndices<'tcx>,
837-
) {
838-
for_each_late_bound_region_in_item(self.tcx, mir_def_id, |r| {
839-
debug!(?r);
840-
if !indices.indices.contains_key(&r) {
841-
let region_vid = {
842-
let name = r.get_name_or_anon();
843-
self.next_nll_region_var(FR, || RegionCtxt::LateBound(name))
844-
};
845-
846-
indices.insert_late_bound_region(r, region_vid.as_var());
847-
}
848-
});
849-
}
850790
}
851791

852792
impl<'tcx> UniversalRegionIndices<'tcx> {

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,7 @@ fn add_unused_functions(cx: &CodegenCx<'_, '_>) {
373373
// just "functions", like consts, statics, etc. Filter those out.
374374
// If `ignore_unused_generics` was specified, filter out any
375375
// generic functions from consideration as well.
376-
if !matches!(
377-
kind,
378-
DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine
379-
) {
376+
if !matches!(kind, DefKind::Fn | DefKind::AssocFn | DefKind::Closure) {
380377
return None;
381378
}
382379
if ignore_unused_generics && tcx.generics_of(def_id).requires_monomorphization(tcx) {

compiler/rustc_codegen_llvm/src/type_of.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::{self, Ty, TypeVisitableExt};
99
use rustc_target::abi::HasDataLayout;
1010
use rustc_target::abi::{Abi, Align, FieldsShape};
1111
use rustc_target::abi::{Int, Pointer, F32, F64};
12-
use rustc_target::abi::{PointeeInfo, Scalar, Size, TyAbiInterface, Variants};
12+
use rustc_target::abi::{Scalar, Size, Variants};
1313
use smallvec::{smallvec, SmallVec};
1414

1515
use std::fmt::Write;
@@ -184,7 +184,6 @@ pub trait LayoutLlvmExt<'tcx> {
184184
immediate: bool,
185185
) -> &'a Type;
186186
fn llvm_field_index<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize) -> u64;
187-
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo>;
188187
fn scalar_copy_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> Option<&'a Type>;
189188
}
190189

@@ -356,20 +355,6 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
356355
}
357356
}
358357

359-
// FIXME(eddyb) this having the same name as `TyAndLayout::pointee_info_at`
360-
// (the inherent method, which is lacking this caching logic) can result in
361-
// the uncached version being called - not wrong, but potentially inefficient.
362-
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo> {
363-
if let Some(&pointee) = cx.pointee_infos.borrow().get(&(self.ty, offset)) {
364-
return pointee;
365-
}
366-
367-
let result = Ty::ty_and_layout_pointee_info_at(*self, cx, offset);
368-
369-
cx.pointee_infos.borrow_mut().insert((self.ty, offset), result);
370-
result
371-
}
372-
373358
fn scalar_copy_llvm_type<'a>(&self, cx: &CodegenCx<'a, 'tcx>) -> Option<&'a Type> {
374359
debug_assert!(self.is_sized());
375360

compiler/rustc_hir/src/def.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ pub enum DefKind {
114114
of_trait: bool,
115115
},
116116
Closure,
117-
Coroutine,
118117
}
119118

120119
impl DefKind {
@@ -157,7 +156,6 @@ impl DefKind {
157156
DefKind::Field => "field",
158157
DefKind::Impl { .. } => "implementation",
159158
DefKind::Closure => "closure",
160-
DefKind::Coroutine => "coroutine",
161159
DefKind::ExternCrate => "extern crate",
162160
DefKind::GlobalAsm => "global assembly block",
163161
}
@@ -216,7 +214,6 @@ impl DefKind {
216214
| DefKind::LifetimeParam
217215
| DefKind::ExternCrate
218216
| DefKind::Closure
219-
| DefKind::Coroutine
220217
| DefKind::Use
221218
| DefKind::ForeignMod
222219
| DefKind::GlobalAsm
@@ -226,7 +223,7 @@ impl DefKind {
226223

227224
#[inline]
228225
pub fn is_fn_like(self) -> bool {
229-
matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure | DefKind::Coroutine)
226+
matches!(self, DefKind::Fn | DefKind::AssocFn | DefKind::Closure)
230227
}
231228

232229
/// Whether `query get_codegen_attrs` should be used with this definition.
@@ -236,7 +233,6 @@ impl DefKind {
236233
| DefKind::AssocFn
237234
| DefKind::Ctor(..)
238235
| DefKind::Closure
239-
| DefKind::Coroutine
240236
| DefKind::Static(_) => true,
241237
DefKind::Mod
242238
| DefKind::Struct

compiler/rustc_hir_analysis/src/check/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ fn opaque_type_cycle_error(
14491449
label_match(capture.place.ty(), capture.get_path_span(tcx));
14501450
}
14511451
// Label any coroutine locals that capture the opaque
1452-
if let DefKind::Coroutine = tcx.def_kind(closure_def_id)
1452+
if tcx.is_coroutine(closure_def_id)
14531453
&& let Some(coroutine_layout) = tcx.mir_coroutine_witnesses(closure_def_id)
14541454
{
14551455
for interior_ty in &coroutine_layout.field_tys {
@@ -1470,7 +1470,7 @@ pub(super) fn check_coroutine_obligations(
14701470
tcx: TyCtxt<'_>,
14711471
def_id: LocalDefId,
14721472
) -> Result<(), ErrorGuaranteed> {
1473-
debug_assert!(matches!(tcx.def_kind(def_id), DefKind::Coroutine));
1473+
debug_assert!(tcx.is_coroutine(def_id.to_def_id()));
14741474

14751475
let typeck = tcx.typeck(def_id);
14761476
let param_env = tcx.param_env(def_id);

compiler/rustc_hir_typeck/src/mem_categorization.rs

-7
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,18 @@ use rustc_trait_selection::infer::InferCtxtExt;
6666

6767
pub(crate) trait HirNode {
6868
fn hir_id(&self) -> hir::HirId;
69-
fn span(&self) -> Span;
7069
}
7170

7271
impl HirNode for hir::Expr<'_> {
7372
fn hir_id(&self) -> hir::HirId {
7473
self.hir_id
7574
}
76-
fn span(&self) -> Span {
77-
self.span
78-
}
7975
}
8076

8177
impl HirNode for hir::Pat<'_> {
8278
fn hir_id(&self) -> hir::HirId {
8379
self.hir_id
8480
}
85-
fn span(&self) -> Span {
86-
self.span
87-
}
8881
}
8982

9083
#[derive(Clone)]

compiler/rustc_infer/src/infer/nll_relate/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ pub trait TypeRelatingDelegate<'tcx> {
113113
fn forbid_inference_vars() -> bool;
114114
}
115115

116-
#[derive(Copy, Clone)]
117-
struct UniversallyQuantified(bool);
118-
119116
impl<'me, 'tcx, D> TypeRelating<'me, 'tcx, D>
120117
where
121118
D: TypeRelatingDelegate<'tcx>,

compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
756756
});
757757

758758
tcx.hir().par_body_owners(|def_id| {
759-
if let rustc_hir::def::DefKind::Coroutine = tcx.def_kind(def_id) {
759+
if tcx.is_coroutine(def_id.to_def_id()) {
760760
tcx.ensure().mir_coroutine_witnesses(def_id);
761761
tcx.ensure().check_coroutine_obligations(def_id);
762762
}

0 commit comments

Comments
 (0)