1
Fork 0

Avoid wrapping fn sig in a fn pointer when we want to just print the sig

This commit is contained in:
Oli Scherer 2024-12-16 15:38:32 +00:00
parent 1c7d54eb7b
commit 1d834c2257

View file

@ -2,18 +2,19 @@
use rustc_errors::ErrorGuaranteed; use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def::Res; use rustc_hir::def::{Namespace, Res};
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor; use rustc_hir::intravisit::Visitor;
use rustc_middle::hir::nested_filter; use rustc_middle::hir::nested_filter;
use rustc_middle::traits::ObligationCauseCode; use rustc_middle::traits::ObligationCauseCode;
use rustc_middle::ty::error::ExpectedFound; use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::print::RegionHighlightMode; use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable}; use rustc_middle::ty::{self, TyCtxt, TypeVisitable};
use rustc_span::Span; use rustc_span::Span;
use tracing::debug; use tracing::debug;
use crate::error_reporting::infer::nice_region_error::NiceRegionError; use crate::error_reporting::infer::nice_region_error::NiceRegionError;
use crate::error_reporting::infer::nice_region_error::placeholder_error::Highlighted;
use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff}; use crate::errors::{ConsiderBorrowingParamHelp, RelationshipHelp, TraitImplDiff};
use crate::infer::{RegionResolutionError, Subtype, ValuePairs}; use crate::infer::{RegionResolutionError, Subtype, ValuePairs};
@ -81,18 +82,17 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
let expected_highlight = HighlightBuilder::build(expected); let expected_highlight = HighlightBuilder::build(expected);
let tcx = self.cx.tcx; let tcx = self.cx.tcx;
let expected = self let expected = Highlighted {
.cx highlight: expected_highlight,
.extract_inference_diagnostics_data( ns: Namespace::TypeNS,
Ty::new_fn_ptr(tcx, expected).into(), tcx,
expected_highlight, value: expected,
) }
.name; .to_string();
let found_highlight = HighlightBuilder::build(found); let found_highlight = HighlightBuilder::build(found);
let found = self let found =
.cx Highlighted { highlight: found_highlight, ns: Namespace::TypeNS, tcx, value: found }
.extract_inference_diagnostics_data(Ty::new_fn_ptr(tcx, found).into(), found_highlight) .to_string();
.name;
// Get the span of all the used type parameters in the method. // Get the span of all the used type parameters in the method.
let assoc_item = self.tcx().associated_item(trait_item_def_id); let assoc_item = self.tcx().associated_item(trait_item_def_id);