Skip to content

Commit 0b95ee0

Browse files
committed
Auto merge of rust-lang#122502 - compiler-errors:crater-rollup, r=<try>
Crater rollup This is a crater rollup of: - [ ] rust-lang#122317 - [ ] rust-lang#122501 - [ ] rust-lang#122077 What does that mean? Well, I'm gonna run crater with p=3 on this PR, and then re-run *just* the list of failed crates on each PR. That should deduplicate the bulk of crates which we expect are unaffected by these PRs. Don't touch this PR please. r? `@ghost`
2 parents fe61575 + fea073f commit 0b95ee0

File tree

79 files changed

+655
-919
lines changed

Some content is hidden

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

79 files changed

+655
-919
lines changed

compiler/rustc_borrowck/src/consumers.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_hir::def_id::LocalDefId;
44
use rustc_index::{IndexSlice, IndexVec};
55
use rustc_infer::infer::TyCtxtInferExt;
66
use rustc_middle::mir::{Body, Promoted};
7-
use rustc_middle::traits::DefiningAnchor;
87
use rustc_middle::ty::TyCtxt;
98
use std::rc::Rc;
109

@@ -106,7 +105,7 @@ pub fn get_body_with_borrowck_facts(
106105
options: ConsumerOptions,
107106
) -> BodyWithBorrowckFacts<'_> {
108107
let (input_body, promoted) = tcx.mir_promoted(def);
109-
let infcx = tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::bind(tcx, def)).build();
108+
let infcx = tcx.infer_ctxt().with_opaque_type_inference(def).build();
110109
let input_body: &Body<'_> = &input_body.borrow();
111110
let promoted: &IndexSlice<_, _> = &promoted.borrow();
112111
*super::do_mir_borrowck(&infcx, input_body, promoted, Some(options)).1.unwrap()

compiler/rustc_borrowck/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use rustc_infer::infer::{
3232
use rustc_middle::mir::tcx::PlaceTy;
3333
use rustc_middle::mir::*;
3434
use rustc_middle::query::Providers;
35-
use rustc_middle::traits::DefiningAnchor;
3635
use rustc_middle::ty::{self, ParamEnv, RegionVid, TyCtxt};
3736
use rustc_session::lint::builtin::UNUSED_MUT;
3837
use rustc_span::{Span, Symbol};
@@ -126,7 +125,7 @@ fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
126125
return tcx.arena.alloc(result);
127126
}
128127

129-
let infcx = tcx.infer_ctxt().with_opaque_type_inference(DefiningAnchor::bind(tcx, def)).build();
128+
let infcx = tcx.infer_ctxt().with_opaque_type_inference(def).build();
130129
let promoted: &IndexSlice<_, _> = &promoted.borrow();
131130
let opt_closure_req = do_mir_borrowck(&infcx, input_body, promoted, None).0;
132131
debug!("mir_borrowck done");

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_infer::infer::InferCtxt;
77
use rustc_infer::infer::TyCtxtInferExt as _;
88
use rustc_infer::traits::{Obligation, ObligationCause};
99
use rustc_macros::extension;
10-
use rustc_middle::traits::DefiningAnchor;
1110
use rustc_middle::ty::visit::TypeVisitableExt;
1211
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable};
1312
use rustc_middle::ty::{GenericArgKind, GenericArgs};
@@ -146,6 +145,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
146145
opaque_type_key,
147146
universal_concrete_type,
148147
);
148+
149+
// Sometimes, when the hidden type is an inference variable, it can happen that
150+
// the hidden type becomes the opaque type itself. In this case, this was an opaque
151+
// usage of the opaque type and we can ignore it. This check is mirrored in typeck's
152+
// writeback.
153+
if let ty::Alias(ty::Opaque, alias_ty) = universal_concrete_type.ty.kind()
154+
&& alias_ty.def_id == opaque_type_key.def_id.to_def_id()
155+
&& alias_ty.args == opaque_type_key.args
156+
{
157+
continue;
158+
}
149159
// Sometimes two opaque types are the same only after we remap the generic parameters
150160
// back to the opaque type definition. E.g. we may have `OpaqueType<X, Y>` mapped to `(X, Y)`
151161
// and `OpaqueType<Y, X>` mapped to `(Y, X)`, and those are the same, but we only know that
@@ -311,13 +321,13 @@ fn check_opaque_type_well_formed<'tcx>(
311321
parent_def_id = tcx.local_parent(parent_def_id);
312322
}
313323

314-
// FIXME(-Znext-solver): We probably should use `DefiningAnchor::Bind(&[])`
324+
// FIXME(-Znext-solver): We probably should use `&[]` instead of
315325
// and prepopulate this `InferCtxt` with known opaque values, rather than
316-
// using the `Bind` anchor here. For now it's fine.
326+
// allowing opaque types to be defined and checking them after the fact.
317327
let infcx = tcx
318328
.infer_ctxt()
319329
.with_next_trait_solver(next_trait_solver)
320-
.with_opaque_type_inference(DefiningAnchor::bind(tcx, parent_def_id))
330+
.with_opaque_type_inference(parent_def_id)
321331
.build();
322332
let ocx = ObligationCtxt::new(&infcx);
323333
let identity_args = GenericArgs::identity_for_item(tcx, def_id);

compiler/rustc_hir_analysis/src/check/check.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
1313
use rustc_infer::traits::{Obligation, TraitEngineExt as _};
1414
use rustc_lint_defs::builtin::REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS;
1515
use rustc_middle::middle::stability::EvalResult;
16-
use rustc_middle::traits::{DefiningAnchor, ObligationCauseCode};
16+
use rustc_middle::traits::ObligationCauseCode;
1717
use rustc_middle::ty::fold::BottomUpFolder;
1818
use rustc_middle::ty::layout::{LayoutError, MAX_SIMD_LANES};
1919
use rustc_middle::ty::util::{Discr, InspectCoroutineFields, IntTypeExt};
@@ -345,10 +345,7 @@ fn check_opaque_meets_bounds<'tcx>(
345345
};
346346
let param_env = tcx.param_env(defining_use_anchor);
347347

348-
let infcx = tcx
349-
.infer_ctxt()
350-
.with_opaque_type_inference(DefiningAnchor::bind(tcx, defining_use_anchor))
351-
.build();
348+
let infcx = tcx.infer_ctxt().with_opaque_type_inference(defining_use_anchor).build();
352349
let ocx = ObligationCtxt::new(&infcx);
353350

354351
let args = match *origin {
@@ -1564,7 +1561,7 @@ pub(super) fn check_coroutine_obligations(
15641561
.ignoring_regions()
15651562
// Bind opaque types to type checking root, as they should have been checked by borrowck,
15661563
// but may show up in some cases, like when (root) obligations are stalled in the new solver.
1567-
.with_opaque_type_inference(DefiningAnchor::bind(tcx, typeck.hir_owner.def_id))
1564+
.with_opaque_type_inference(typeck.hir_owner.def_id)
15681565
.build();
15691566

15701567
let mut fulfillment_cx = <dyn TraitEngine<'_>>::new(&infcx);

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
894894
[candidate] => format!(
895895
"the method of the same name on {} `{}`",
896896
match candidate.kind {
897-
probe::CandidateKind::InherentImplCandidate(..) => "the inherent impl for",
897+
probe::CandidateKind::InherentImplCandidate(_) => "the inherent impl for",
898898
_ => "trait",
899899
},
900900
self.tcx.def_path_str(candidate.item.container_id(self.tcx))

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
719719
for ty in ret_ty.walk() {
720720
if let ty::GenericArgKind::Type(ty) = ty.unpack()
721721
&& let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *ty.kind()
722-
&& let Some(def_id) = def_id.as_local()
723-
&& self.opaque_type_origin(def_id).is_some()
722+
&& self.can_define_opaque_ty(def_id)
724723
{
725724
return None;
726725
}

compiler/rustc_hir_typeck/src/inherited.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_hir as hir;
55
use rustc_hir::def_id::LocalDefId;
66
use rustc_hir::HirIdMap;
77
use rustc_infer::infer::{InferCtxt, InferOk, TyCtxtInferExt};
8-
use rustc_middle::traits::DefiningAnchor;
98
use rustc_middle::ty::visit::TypeVisitableExt;
109
use rustc_middle::ty::{self, Ty, TyCtxt};
1110
use rustc_span::def_id::LocalDefIdMap;
@@ -76,11 +75,7 @@ impl<'tcx> Inherited<'tcx> {
7675
pub fn new(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Self {
7776
let hir_owner = tcx.local_def_id_to_hir_id(def_id).owner;
7877

79-
let infcx = tcx
80-
.infer_ctxt()
81-
.ignoring_regions()
82-
.with_opaque_type_inference(DefiningAnchor::bind(tcx, def_id))
83-
.build();
78+
let infcx = tcx.infer_ctxt().ignoring_regions().with_opaque_type_inference(def_id).build();
8479
let typeck_results = RefCell::new(ty::TypeckResults::new(hir_owner));
8580

8681
Inherited {

0 commit comments

Comments
 (0)