Skip to content

Commit 20f23ab

Browse files
committed
Auto merge of rust-lang#128041 - compiler-errors:uplift-errors-into-trait-sel, r=lcnr
Uplift most type-system related error reporting from `rustc_infer` to `rustc_trait_selection` Completes the major part of rust-lang#127492. The only cleanup that's needed afterwards is to actually use normalization in favor of the callback where needed, and deleting `can_eq_shallow`. r? lcnr Sorry for the large diff! Would prefer if comments can be handled in a follow-up (unless they're absolutely dealbreakers) because it seems bitrotty to let this sit.
2 parents aee3dc4 + e9e9495 commit 20f23ab

File tree

81 files changed

+2599
-2605
lines changed

Some content is hidden

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

81 files changed

+2599
-2605
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_errors::Diag;
22
use rustc_hir::def_id::LocalDefId;
3-
use rustc_infer::error_reporting::infer::nice_region_error::NiceRegionError;
43
use rustc_infer::infer::canonical::Canonical;
54
use rustc_infer::infer::region_constraints::Constraint;
65
use rustc_infer::infer::region_constraints::RegionConstraintData;
@@ -14,6 +13,8 @@ use rustc_middle::ty::RegionVid;
1413
use rustc_middle::ty::UniverseIndex;
1514
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
1615
use rustc_span::Span;
16+
use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
17+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1718
use rustc_trait_selection::traits::query::type_op;
1819
use rustc_trait_selection::traits::ObligationCtxt;
1920
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ use rustc_span::def_id::LocalDefId;
3535
use rustc_span::hygiene::DesugaringKind;
3636
use rustc_span::symbol::{kw, sym, Ident};
3737
use rustc_span::{BytePos, Span, Symbol};
38-
use rustc_trait_selection::error_reporting::traits::suggestions::TypeErrCtxtExt;
3938
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
39+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
4040
use rustc_trait_selection::infer::InferCtxtExt;
4141
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
4242
use std::iter;

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rustc_span::def_id::LocalDefId;
2727
use rustc_span::source_map::Spanned;
2828
use rustc_span::{symbol::sym, Span, Symbol, DUMMY_SP};
2929
use rustc_target::abi::{FieldIdx, VariantIdx};
30-
use rustc_trait_selection::error_reporting::traits::suggestions::TypeErrCtxtExt as _;
30+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
3131
use rustc_trait_selection::infer::InferCtxtExt;
3232
use rustc_trait_selection::traits::{
3333
type_known_to_meet_bound_modulo_regions, FulfillmentErrorCode,

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_middle::{
1616
use rustc_span::symbol::{kw, Symbol};
1717
use rustc_span::{sym, BytePos, DesugaringKind, Span};
1818
use rustc_target::abi::FieldIdx;
19-
use rustc_trait_selection::error_reporting::traits::suggestions::TypeErrCtxtExt;
19+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
2020
use rustc_trait_selection::infer::InferCtxtExt;
2121
use rustc_trait_selection::traits;
2222

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ use rustc_hir::GenericBound::Trait;
1010
use rustc_hir::QPath::Resolved;
1111
use rustc_hir::WherePredicate::BoundPredicate;
1212
use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate};
13-
use rustc_infer::error_reporting::infer::nice_region_error::{
14-
self, find_anon_type, find_param_with_region, suggest_adding_lifetime_params,
15-
HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor,
16-
};
17-
use rustc_infer::error_reporting::infer::region::unexpected_hidden_region_diagnostic;
1813
use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound};
1914
use rustc_middle::bug;
2015
use rustc_middle::hir::place::PlaceBase;
@@ -25,6 +20,12 @@ use rustc_middle::ty::{self, RegionVid, Ty};
2520
use rustc_middle::ty::{Region, TyCtxt};
2621
use rustc_span::symbol::{kw, Ident};
2722
use rustc_span::Span;
23+
use rustc_trait_selection::error_reporting::infer::nice_region_error::{
24+
self, find_anon_type, find_param_with_region, suggest_adding_lifetime_params,
25+
HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor,
26+
};
27+
use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic;
28+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
2829
use rustc_trait_selection::infer::InferCtxtExt;
2930
use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
3031

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_middle::ty::{GenericArgKind, GenericArgsRef};
1414
use rustc_middle::{bug, span_bug};
1515
use rustc_span::symbol::{kw, sym, Symbol};
1616
use rustc_span::{Span, DUMMY_SP};
17+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1718

1819
use crate::{universal_regions::DefiningTy, MirBorrowckCtxt};
1920

@@ -457,8 +458,11 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
457458
) -> RegionNameHighlight {
458459
let mut highlight = RegionHighlightMode::default();
459460
highlight.highlighting_region_vid(self.infcx.tcx, needle_fr, counter);
460-
let type_name =
461-
self.infcx.extract_inference_diagnostics_data(ty.into(), Some(highlight)).name;
461+
let type_name = self
462+
.infcx
463+
.err_ctxt()
464+
.extract_inference_diagnostics_data(ty.into(), Some(highlight))
465+
.name;
462466

463467
debug!(
464468
"highlight_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
@@ -872,8 +876,11 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
872876

873877
let mut highlight = RegionHighlightMode::default();
874878
highlight.highlighting_region_vid(tcx, fr, *self.next_region_name.try_borrow().unwrap());
875-
let type_name =
876-
self.infcx.extract_inference_diagnostics_data(yield_ty.into(), Some(highlight)).name;
879+
let type_name = self
880+
.infcx
881+
.err_ctxt()
882+
.extract_inference_diagnostics_data(yield_ty.into(), Some(highlight))
883+
.name;
877884

878885
let yield_span = match tcx.hir_node(self.mir_hir_id()) {
879886
hir::Node::Expr(hir::Expr {

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::ty::visit::TypeVisitableExt;
1111
use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable};
1212
use rustc_middle::ty::{GenericArgKind, GenericArgs};
1313
use rustc_span::Span;
14-
use rustc_trait_selection::error_reporting::traits::TypeErrCtxtExt as _;
14+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1515
use rustc_trait_selection::traits::ObligationCtxt;
1616

1717
use crate::session_diagnostics::LifetimeMismatchOpaqueParam;

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::traits::query::OutlivesBound;
1111
use rustc_middle::traits::ObligationCause;
1212
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
1313
use rustc_span::{ErrorGuaranteed, Span};
14-
use rustc_trait_selection::error_reporting::traits::TypeErrCtxtExt;
14+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1515
use rustc_trait_selection::solve::deeply_normalize;
1616
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
1717
use std::rc::Rc;

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_middle::ty::{self, adjustment::PointerCoercion, Ty, TyCtxt};
1313
use rustc_middle::ty::{Instance, InstanceKind, TypeVisitableExt};
1414
use rustc_mir_dataflow::Analysis;
1515
use rustc_span::{sym, Span, Symbol, DUMMY_SP};
16-
use rustc_trait_selection::error_reporting::traits::TypeErrCtxtExt as _;
16+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
1717
use rustc_trait_selection::traits::{self, ObligationCauseCode, ObligationCtxt};
1818
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitor};
1919

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_middle::ty::{
2626
use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS};
2727
use rustc_target::abi::FieldIdx;
2828
use rustc_trait_selection::error_reporting::traits::on_unimplemented::OnUnimplementedDirective;
29-
use rustc_trait_selection::error_reporting::traits::TypeErrCtxtExt as _;
29+
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
3030
use rustc_trait_selection::traits;
3131
use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _;
3232
use rustc_type_ir::fold::TypeFoldable;

0 commit comments

Comments
 (0)