use crate::ty::print::{FmtPrinter, Printer};
use crate::ty::{self, BoundRegionKind, Region, Ty, TyCtxt};
use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect};
-use rustc_errors::{pluralize, DiagnosticBuilder};
+use rustc_errors::{pluralize, Diagnostic};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_span::symbol::{sym, Symbol};
impl<'tcx> TyCtxt<'tcx> {
pub fn note_and_explain_type_err(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
err: &TypeError<'tcx>,
cause: &ObligationCause<'tcx>,
sp: Span,
fn suggest_constraint(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
msg: &str,
body_owner_def_id: DefId,
proj_ty: &ty::ProjectionTy<'tcx>,
/// fn that returns the type.
fn expected_projection(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
proj_ty: &ty::ProjectionTy<'tcx>,
values: &ExpectedFound<Ty<'tcx>>,
body_owner_def_id: DefId,
/// a return type. This can occur when dealing with `TryStream` (#71035).
fn suggest_constraining_opaque_associated_type(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
msg: &str,
proj_ty: &ty::ProjectionTy<'tcx>,
ty: Ty<'tcx>,
fn point_at_methods_that_satisfy_associated_type(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
assoc_container_id: DefId,
current_method_ident: Option<Symbol>,
proj_ty_item_def_id: DefId,
fn point_at_associated_type(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
body_owner_def_id: DefId,
found: Ty<'tcx>,
) -> bool {
- let hir_id =
- match body_owner_def_id.as_local().map(|id| self.hir().local_def_id_to_hir_id(id)) {
- Some(hir_id) => hir_id,
- None => return false,
- };
+ let Some(hir_id) = body_owner_def_id.as_local() else {
+ return false;
+ };
+ let hir_id = self.hir().local_def_id_to_hir_id(hir_id);
// When `body_owner` is an `impl` or `trait` item, look in its associated types for
// `expected` and point at it.
let parent_id = self.hir().get_parent_item(hir_id);
/// type is defined on a supertrait of the one present in the bounds.
fn constrain_generic_bound_associated_type_structured_suggestion(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
trait_ref: &ty::TraitRef<'tcx>,
bounds: hir::GenericBounds<'_>,
assoc: &ty::AssocItem,
/// associated type to a given type `ty`.
fn constrain_associated_type_structured_suggestion(
self,
- db: &mut DiagnosticBuilder<'_>,
+ // FIXME(eddyb) rename this since it's no longer a `DiagnosticBuilder`.
+ db: &mut Diagnostic,
span: Span,
assoc: &ty::AssocItem,
assoc_substs: &[ty::GenericArg<'tcx>],