Skip to content

Commit 2d99b5a

Browse files
authored
Unrolled build for #142637
Rollup merge of #142637 - compiler-errors:less-globs, r=lcnr Remove some glob imports from the type system Namely, remove the glob imports for `BoundRegionConversionTime`, `RegionVariableOrigin`, `SubregionOrigin`, `TyOrConstInferVar`, `RegionResolutionError`, `SelectionError`, `ProjectionCandidate`, `ProjectionCandidateSet`, and some more specific scoped globs (like `Inserted` in the impl overlap graph construction. These glob imports are IMO very low value, since they're not used nearly as often as other globs (like `TyKind`).
2 parents 513999b + c995070 commit 2d99b5a

File tree

40 files changed

+259
-208
lines changed

40 files changed

+259
-208
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir::def::Res::Def;
1010
use rustc_hir::def_id::DefId;
1111
use rustc_hir::intravisit::VisitorExt;
1212
use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate};
13-
use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound};
13+
use rustc_infer::infer::{NllRegionVariableOrigin, SubregionOrigin};
1414
use rustc_middle::bug;
1515
use rustc_middle::hir::place::PlaceBase;
1616
use rustc_middle::mir::{AnnotationSource, ConstraintCategory, ReturnConstraint};
@@ -329,7 +329,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
329329
self.infcx.tcx,
330330
type_test.generic_kind.to_ty(self.infcx.tcx),
331331
);
332-
let origin = RelateParamBound(type_test_span, generic_ty, None);
332+
let origin =
333+
SubregionOrigin::RelateParamBound(type_test_span, generic_ty, None);
333334
self.buffer_error(self.infcx.err_ctxt().construct_generic_bound_failure(
334335
self.body.source.def_id().expect_local(),
335336
type_test_span,

compiler/rustc_borrowck/src/type_check/constraint_conversion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
33
use rustc_infer::infer::outlives::env::RegionBoundPairs;
44
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
55
use rustc_infer::infer::region_constraints::{GenericKind, VerifyBound};
6-
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin};
6+
use rustc_infer::infer::{InferCtxt, SubregionOrigin};
77
use rustc_infer::traits::query::type_op::DeeplyNormalize;
88
use rustc_middle::bug;
99
use rustc_middle::ty::{
@@ -172,7 +172,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
172172
ty::Region::new_var(tcx, universal_regions.implicit_region_bound());
173173
// we don't actually use this for anything, but
174174
// the `TypeOutlives` code needs an origin.
175-
let origin = infer::RelateParamBound(self.span, t1, None);
175+
let origin = SubregionOrigin::RelateParamBound(self.span, t1, None);
176176
TypeOutlives::new(
177177
&mut *self,
178178
tcx,

compiler/rustc_borrowck/src/type_check/input_output.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
6666
Ty::new_tup(self.tcx(), user_provided_sig.inputs()),
6767
args.tupled_upvars_ty(),
6868
args.coroutine_captures_by_ref_ty(),
69-
self.infcx
70-
.next_region_var(RegionVariableOrigin::MiscVariable(self.body.span), || {
71-
RegionCtxt::Unknown
72-
}),
69+
self.infcx.next_region_var(RegionVariableOrigin::Misc(self.body.span), || {
70+
RegionCtxt::Unknown
71+
}),
7372
);
7473

7574
let next_ty_var = || self.infcx.next_ty_var(self.body.span);

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
1616
use rustc_infer::infer::outlives::env::RegionBoundPairs;
1717
use rustc_infer::infer::region_constraints::RegionConstraintData;
1818
use rustc_infer::infer::{
19-
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
19+
BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin,
2020
};
2121
use rustc_infer::traits::PredicateObligations;
2222
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
@@ -794,7 +794,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
794794
};
795795

796796
self.infcx.next_region_var(
797-
BoundRegion(
797+
RegionVariableOrigin::BoundRegion(
798798
term.source_info.span,
799799
br.kind,
800800
BoundRegionConversionTime::FnCall,

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ fn check_opaque_meets_bounds<'tcx>(
312312
// here rather than using ReErased.
313313
let hidden_ty = tcx.type_of(def_id.to_def_id()).instantiate(tcx, args);
314314
let hidden_ty = fold_regions(tcx, hidden_ty, |re, _dbi| match re.kind() {
315-
ty::ReErased => infcx.next_region_var(RegionVariableOrigin::MiscVariable(span)),
315+
ty::ReErased => infcx.next_region_var(RegionVariableOrigin::Misc(span)),
316316
_ => re,
317317
});
318318

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, pluralize, struct_
99
use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::intravisit::VisitorExt;
1111
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, ImplItemKind, intravisit};
12-
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
12+
use rustc_infer::infer::{self, BoundRegionConversionTime, InferCtxt, TyCtxtInferExt};
1313
use rustc_infer::traits::util;
1414
use rustc_middle::ty::error::{ExpectedFound, TypeError};
1515
use rustc_middle::ty::{
@@ -311,7 +311,7 @@ fn compare_method_predicate_entailment<'tcx>(
311311

312312
let unnormalized_impl_sig = infcx.instantiate_binder_with_fresh_vars(
313313
impl_m_span,
314-
infer::HigherRankedType,
314+
BoundRegionConversionTime::HigherRankedType,
315315
tcx.fn_sig(impl_m.def_id).instantiate_identity(),
316316
);
317317

@@ -518,7 +518,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
518518
param_env,
519519
infcx.instantiate_binder_with_fresh_vars(
520520
return_span,
521-
infer::HigherRankedType,
521+
BoundRegionConversionTime::HigherRankedType,
522522
tcx.fn_sig(impl_m.def_id).instantiate_identity(),
523523
),
524524
);

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1111
use rustc_hir::lang_items::LangItem;
1212
use rustc_hir::{AmbigArg, ItemKind};
1313
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
14-
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
14+
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin, TyCtxtInferExt};
1515
use rustc_lint_defs::builtin::SUPERTRAIT_ITEM_SHADOWING_DEFINITION;
1616
use rustc_macros::LintDiagnostic;
1717
use rustc_middle::mir::interpret::ErrorHandled;
@@ -739,7 +739,7 @@ fn ty_known_to_outlive<'tcx>(
739739
infcx.register_type_outlives_constraint_inner(infer::TypeOutlivesConstraint {
740740
sub_region: region,
741741
sup_type: ty,
742-
origin: infer::RelateParamBound(DUMMY_SP, ty, None),
742+
origin: SubregionOrigin::RelateParamBound(DUMMY_SP, ty, None),
743743
});
744744
})
745745
}
@@ -755,7 +755,11 @@ fn region_known_to_outlive<'tcx>(
755755
region_b: ty::Region<'tcx>,
756756
) -> bool {
757757
test_region_obligations(tcx, id, param_env, wf_tys, |infcx| {
758-
infcx.sub_regions(infer::RelateRegionParamBound(DUMMY_SP, None), region_b, region_a);
758+
infcx.sub_regions(
759+
SubregionOrigin::RelateRegionParamBound(DUMMY_SP, None),
760+
region_b,
761+
region_a,
762+
);
759763
})
760764
}
761765

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_hir as hir;
1010
use rustc_hir::ItemKind;
1111
use rustc_hir::def_id::{DefId, LocalDefId};
1212
use rustc_hir::lang_items::LangItem;
13-
use rustc_infer::infer::{self, RegionResolutionError, TyCtxtInferExt};
13+
use rustc_infer::infer::{self, RegionResolutionError, SubregionOrigin, TyCtxtInferExt};
1414
use rustc_infer::traits::Obligation;
1515
use rustc_middle::ty::adjustment::CoerceUnsizedInfo;
1616
use rustc_middle::ty::print::PrintTraitRefExt as _;
@@ -415,7 +415,7 @@ pub(crate) fn coerce_unsized_info<'tcx>(
415415
};
416416
let (source, target, trait_def_id, kind, field_span) = match (source.kind(), target.kind()) {
417417
(&ty::Ref(r_a, ty_a, mutbl_a), &ty::Ref(r_b, ty_b, mutbl_b)) => {
418-
infcx.sub_regions(infer::RelateObjectBound(span), r_b, r_a);
418+
infcx.sub_regions(SubregionOrigin::RelateObjectBound(span), r_b, r_a);
419419
let mt_a = ty::TypeAndMut { ty: ty_a, mutbl: mutbl_a };
420420
let mt_b = ty::TypeAndMut { ty: ty_b, mutbl: mutbl_b };
421421
check_mutbl(mt_a, mt_b, &|ty| Ty::new_imm_ref(tcx, r_b, ty))

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::def::{self, CtorKind, Namespace, Res};
77
use rustc_hir::def_id::DefId;
88
use rustc_hir::{self as hir, HirId, LangItem};
99
use rustc_hir_analysis::autoderef::Autoderef;
10-
use rustc_infer::infer;
10+
use rustc_infer::infer::BoundRegionConversionTime;
1111
use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode};
1212
use rustc_middle::ty::adjustment::{
1313
Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
@@ -219,7 +219,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
219219
let closure_sig = args.as_closure().sig();
220220
let closure_sig = self.instantiate_binder_with_fresh_vars(
221221
call_expr.span,
222-
infer::FnCall,
222+
BoundRegionConversionTime::FnCall,
223223
closure_sig,
224224
);
225225
let adjustments = self.adjust_steps(autoderef);
@@ -246,7 +246,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
246246
let closure_args = args.as_coroutine_closure();
247247
let coroutine_closure_sig = self.instantiate_binder_with_fresh_vars(
248248
call_expr.span,
249-
infer::FnCall,
249+
BoundRegionConversionTime::FnCall,
250250
closure_args.coroutine_closure_sig(),
251251
);
252252
let tupled_upvars_ty = self.next_ty_var(callee_expr.span);
@@ -545,7 +545,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
545545
// renormalize the associated types at this point, since they
546546
// previously appeared within a `Binder<>` and hence would not
547547
// have been normalized before.
548-
let fn_sig = self.instantiate_binder_with_fresh_vars(call_expr.span, infer::FnCall, fn_sig);
548+
let fn_sig = self.instantiate_binder_with_fresh_vars(
549+
call_expr.span,
550+
BoundRegionConversionTime::FnCall,
551+
fn_sig,
552+
);
549553
let fn_sig = self.normalize(call_expr.span, fn_sig);
550554

551555
self.check_argument_types(

compiler/rustc_hir_typeck/src/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn check_fn<'a, 'tcx>(
5858
let maybe_va_list = fn_sig.c_variadic.then(|| {
5959
let span = body.params.last().unwrap().span;
6060
let va_list_did = tcx.require_lang_item(LangItem::VaList, span);
61-
let region = fcx.next_region_var(RegionVariableOrigin::MiscVariable(span));
61+
let region = fcx.next_region_var(RegionVariableOrigin::Misc(span));
6262

6363
tcx.type_of(va_list_did).instantiate(tcx, &[region.into()])
6464
});

0 commit comments

Comments
 (0)