Skip to content

Commit 35a0961

Browse files
committed
Auto merge of rust-lang#108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#108879 (Unconstrained terms should account for infer vars being equated) - rust-lang#108936 (Rustdoc: don't hide anonymous reexport) - rust-lang#108940 (Add myself to compiler reviewers list) - rust-lang#108945 (Make some report and emit errors take DefIds instead of BodyIds) - rust-lang#108946 (Document the resulting values produced when using `From<bool>` on floats) - rust-lang#108956 (Make ptr::from_ref and ptr::from_mut in rust-lang#106116 const.) - rust-lang#108960 (Remove `body_def_id` from `Inherited`) - rust-lang#108963 (only call git on git checkouts during bootstrap) - rust-lang#108964 (Fix the docs for pointer method with_metadata_of) Failed merges: - rust-lang#108950 (Directly construct Inherited in typeck.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d583342 + df74b70 commit 35a0961

File tree

24 files changed

+157
-121
lines changed

24 files changed

+157
-121
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
325325
if errors.is_empty() {
326326
definition_ty
327327
} else {
328-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
328+
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
329329
self.tcx.ty_error(reported)
330330
}
331331
}

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
770770

771771
let errors = ocx.select_all_or_error();
772772
if !errors.is_empty() {
773-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
773+
infcx.err_ctxt().report_fulfillment_errors(&errors);
774774
}
775775
}
776776

compiler/rustc_hir_analysis/src/check/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ fn check_opaque_meets_bounds<'tcx>(
444444
// version.
445445
let errors = ocx.select_all_or_error();
446446
if !errors.is_empty() {
447-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
447+
infcx.err_ctxt().report_fulfillment_errors(&errors);
448448
}
449449
match origin {
450450
// Checked when type checking the function containing them.
@@ -1545,6 +1545,6 @@ pub(super) fn check_generator_obligations(tcx: TyCtxt<'_>, def_id: LocalDefId) {
15451545
let errors = fulfillment_cx.select_all_or_error(&infcx);
15461546
debug!(?errors);
15471547
if !errors.is_empty() {
1548-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
1548+
infcx.err_ctxt().report_fulfillment_errors(&errors);
15491549
}
15501550
}

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ fn compare_method_predicate_entailment<'tcx>(
320320
});
321321
}
322322
CheckImpliedWfMode::Skip => {
323-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
323+
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
324324
return Err(reported);
325325
}
326326
}
@@ -720,7 +720,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
720720
// RPITs.
721721
let errors = ocx.select_all_or_error();
722722
if !errors.is_empty() {
723-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
723+
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
724724
return Err(reported);
725725
}
726726

@@ -1731,7 +1731,7 @@ pub(super) fn compare_impl_const_raw(
17311731
// version.
17321732
let errors = ocx.select_all_or_error();
17331733
if !errors.is_empty() {
1734-
return Err(infcx.err_ctxt().report_fulfillment_errors(&errors, None));
1734+
return Err(infcx.err_ctxt().report_fulfillment_errors(&errors));
17351735
}
17361736

17371737
let outlives_environment = OutlivesEnvironment::new(param_env);
@@ -1831,7 +1831,7 @@ fn compare_type_predicate_entailment<'tcx>(
18311831
// version.
18321832
let errors = ocx.select_all_or_error();
18331833
if !errors.is_empty() {
1834-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
1834+
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
18351835
return Err(reported);
18361836
}
18371837

@@ -2044,7 +2044,7 @@ pub(super) fn check_type_bounds<'tcx>(
20442044
// version.
20452045
let errors = ocx.select_all_or_error();
20462046
if !errors.is_empty() {
2047-
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors, None);
2047+
let reported = infcx.err_ctxt().report_fulfillment_errors(&errors);
20482048
return Err(reported);
20492049
}
20502050

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
111111

112112
let errors = wfcx.select_all_or_error();
113113
if !errors.is_empty() {
114-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
114+
infcx.err_ctxt().report_fulfillment_errors(&errors);
115115
return;
116116
}
117117

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
345345
}),
346346
);
347347
if !errors.is_empty() {
348-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
348+
infcx.err_ctxt().report_fulfillment_errors(&errors);
349349
}
350350

351351
// Finally, resolve all regions.
@@ -585,7 +585,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
585585
predicate_for_trait_def(tcx, param_env, cause, trait_def_id, 0, [source, target]);
586586
let errors = traits::fully_solve_obligation(&infcx, predicate);
587587
if !errors.is_empty() {
588-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
588+
infcx.err_ctxt().report_fulfillment_errors(&errors);
589589
}
590590

591591
// Finally, resolve all regions.

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn get_impl_substs(
174174

175175
let errors = ocx.select_all_or_error();
176176
if !errors.is_empty() {
177-
ocx.infcx.err_ctxt().report_fulfillment_errors(&errors, None);
177+
ocx.infcx.err_ctxt().report_fulfillment_errors(&errors);
178178
return None;
179179
}
180180

compiler/rustc_hir_analysis/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn require_same_types<'tcx>(
176176
match &errors[..] {
177177
[] => true,
178178
errors => {
179-
infcx.err_ctxt().report_fulfillment_errors(errors, None);
179+
infcx.err_ctxt().report_fulfillment_errors(errors);
180180
false
181181
}
182182
}
@@ -309,7 +309,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
309309
ocx.register_bound(cause, param_env, norm_return_ty, term_did);
310310
let errors = ocx.select_all_or_error();
311311
if !errors.is_empty() {
312-
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
312+
infcx.err_ctxt().report_fulfillment_errors(&errors);
313313
error = true;
314314
}
315315
// now we can take the return type of the given main function

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
581581

582582
if !errors.is_empty() {
583583
self.adjust_fulfillment_errors_for_expr_obligation(&mut errors);
584-
self.err_ctxt().report_fulfillment_errors(&errors, self.inh.body_id);
584+
self.err_ctxt().report_fulfillment_errors(&errors);
585585
}
586586
}
587587

@@ -594,7 +594,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
594594
if !result.is_empty() {
595595
mutate_fulfillment_errors(&mut result);
596596
self.adjust_fulfillment_errors_for_expr_obligation(&mut result);
597-
self.err_ctxt().report_fulfillment_errors(&result, self.inh.body_id);
597+
self.err_ctxt().report_fulfillment_errors(&result);
598598
}
599599
}
600600

@@ -1411,7 +1411,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14111411
} else {
14121412
let e = self.tainted_by_errors().unwrap_or_else(|| {
14131413
self.err_ctxt()
1414-
.emit_inference_failure_err((**self).body_id, sp, ty.into(), E0282, true)
1414+
.emit_inference_failure_err(self.body_id, sp, ty.into(), E0282, true)
14151415
.emit()
14161416
});
14171417
let err = self.tcx.ty_error(e);

compiler/rustc_hir_typeck/src/inherited.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ pub struct Inherited<'tcx> {
5858
pub(super) deferred_generator_interiors:
5959
RefCell<Vec<(LocalDefId, hir::BodyId, Ty<'tcx>, hir::GeneratorKind)>>,
6060

61-
pub(super) body_id: Option<hir::BodyId>,
62-
6361
/// Whenever we introduce an adjustment from `!` into a type variable,
6462
/// we record that type variable here. This is later used to inform
6563
/// fallback. See the `fallback` module for details.
@@ -80,7 +78,6 @@ impl<'tcx> Deref for Inherited<'tcx> {
8078
/// without using `Rc` or something similar.
8179
pub struct InheritedBuilder<'tcx> {
8280
infcx: infer::InferCtxtBuilder<'tcx>,
83-
def_id: LocalDefId,
8481
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
8582
}
8683

@@ -93,7 +90,6 @@ impl<'tcx> Inherited<'tcx> {
9390
.infer_ctxt()
9491
.ignoring_regions()
9592
.with_opaque_type_inference(DefiningAnchor::Bind(hir_owner.def_id)),
96-
def_id,
9793
typeck_results: RefCell::new(ty::TypeckResults::new(hir_owner)),
9894
}
9995
}
@@ -104,19 +100,13 @@ impl<'tcx> InheritedBuilder<'tcx> {
104100
where
105101
F: FnOnce(&Inherited<'tcx>) -> R,
106102
{
107-
let def_id = self.def_id;
108-
f(&Inherited::new(self.infcx.build(), def_id, self.typeck_results))
103+
f(&Inherited::new(self.infcx.build(), self.typeck_results))
109104
}
110105
}
111106

112107
impl<'tcx> Inherited<'tcx> {
113-
fn new(
114-
infcx: InferCtxt<'tcx>,
115-
def_id: LocalDefId,
116-
typeck_results: RefCell<ty::TypeckResults<'tcx>>,
117-
) -> Self {
108+
fn new(infcx: InferCtxt<'tcx>, typeck_results: RefCell<ty::TypeckResults<'tcx>>) -> Self {
118109
let tcx = infcx.tcx;
119-
let body_id = tcx.hir().maybe_body_owned_by(def_id);
120110

121111
Inherited {
122112
typeck_results,
@@ -130,7 +120,6 @@ impl<'tcx> Inherited<'tcx> {
130120
deferred_asm_checks: RefCell::new(Vec::new()),
131121
deferred_generator_interiors: RefCell::new(Vec::new()),
132122
diverging_type_vars: RefCell::new(Default::default()),
133-
body_id,
134123
infer_var_info: RefCell::new(Default::default()),
135124
}
136125
}

compiler/rustc_hir_typeck/src/writeback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
748748
.infcx
749749
.err_ctxt()
750750
.emit_inference_failure_err(
751-
Some(self.body.id()),
751+
self.tcx.hir().body_owner_def_id(self.body.id()),
752752
self.span.to_span(self.tcx),
753753
p.into(),
754754
E0282,

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed, IntoDiagnosticArg};
1010
use rustc_hir as hir;
1111
use rustc_hir::def::Res;
1212
use rustc_hir::def::{CtorOf, DefKind, Namespace};
13-
use rustc_hir::def_id::DefId;
13+
use rustc_hir::def_id::{DefId, LocalDefId};
1414
use rustc_hir::intravisit::{self, Visitor};
1515
use rustc_hir::{Body, Closure, Expr, ExprKind, FnRetTy, HirId, Local, LocalSource};
1616
use rustc_middle::hir::nested_filter;
@@ -386,7 +386,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
386386
#[instrument(level = "debug", skip(self, error_code))]
387387
pub fn emit_inference_failure_err(
388388
&self,
389-
body_id: Option<hir::BodyId>,
389+
body_def_id: LocalDefId,
390390
failure_span: Span,
391391
arg: GenericArg<'tcx>,
392392
error_code: TypeAnnotationNeeded,
@@ -403,8 +403,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
403403
};
404404

405405
let mut local_visitor = FindInferSourceVisitor::new(&self, typeck_results, arg);
406-
if let Some(body_id) = body_id {
407-
let expr = self.tcx.hir().expect_expr(body_id.hir_id);
406+
if let Some(body_id) = self.tcx.hir().maybe_body_owned_by(
407+
self.tcx.typeck_root_def_id(body_def_id.to_def_id()).expect_local(),
408+
) {
409+
let expr = self.tcx.hir().body(body_id).value;
408410
local_visitor.visit_expr(expr);
409411
}
410412

compiler/rustc_trait_selection/src/solve/eval_ctxt.rs

+20-15
Original file line numberDiff line numberDiff line change
@@ -93,37 +93,42 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
9393
};
9494

9595
// Guard against `<T as Trait<?0>>::Assoc = ?0>`.
96-
struct ContainsTerm<'tcx> {
96+
struct ContainsTerm<'a, 'tcx> {
9797
term: ty::Term<'tcx>,
98+
infcx: &'a InferCtxt<'tcx>,
9899
}
99-
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTerm<'tcx> {
100+
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTerm<'_, 'tcx> {
100101
type BreakTy = ();
101102
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
102-
if t.needs_infer() {
103-
if ty::Term::from(t) == self.term {
104-
ControlFlow::Break(())
105-
} else {
106-
t.super_visit_with(self)
107-
}
103+
if let Some(vid) = t.ty_vid()
104+
&& let ty::TermKind::Ty(term) = self.term.unpack()
105+
&& let Some(term_vid) = term.ty_vid()
106+
&& self.infcx.root_var(vid) == self.infcx.root_var(term_vid)
107+
{
108+
ControlFlow::Break(())
109+
} else if t.has_non_region_infer() {
110+
t.super_visit_with(self)
108111
} else {
109112
ControlFlow::Continue(())
110113
}
111114
}
112115

113116
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
114-
if c.needs_infer() {
115-
if ty::Term::from(c) == self.term {
116-
ControlFlow::Break(())
117-
} else {
118-
c.super_visit_with(self)
119-
}
117+
if let ty::ConstKind::Infer(ty::InferConst::Var(vid)) = c.kind()
118+
&& let ty::TermKind::Const(term) = self.term.unpack()
119+
&& let ty::ConstKind::Infer(ty::InferConst::Var(term_vid)) = term.kind()
120+
&& self.infcx.root_const_var(vid) == self.infcx.root_const_var(term_vid)
121+
{
122+
ControlFlow::Break(())
123+
} else if c.has_non_region_infer() {
124+
c.super_visit_with(self)
120125
} else {
121126
ControlFlow::Continue(())
122127
}
123128
}
124129
}
125130

126-
let mut visitor = ContainsTerm { term: goal.predicate.term };
131+
let mut visitor = ContainsTerm { infcx: self.infcx, term: goal.predicate.term };
127132

128133
term_is_infer
129134
&& goal.predicate.projection_ty.visit_with(&mut visitor).is_continue()

0 commit comments

Comments
 (0)