@@ -5,7 +5,6 @@ use rustc_data_structures::fx::FxHashSet;
55use rustc_errors:: struct_span_err;
66use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
77use rustc_hir as hir;
8- use rustc_infer:: infer:: TyCtxtInferExt ;
98use rustc_middle:: ty:: subst:: GenericArgKind ;
109use rustc_middle:: ty:: subst:: InternalSubsts ;
1110use rustc_middle:: ty:: util:: IgnoreRegions ;
@@ -229,12 +228,8 @@ fn emit_orphan_check_error<'tcx>(
229228 "only traits defined in the current crate {msg}"
230229 ) ;
231230 err. span_label ( sp, "impl doesn't use only types from inside the current crate" ) ;
232- for ( ty, is_target_ty) in & tys {
233- let mut ty = * ty;
234- tcx. infer_ctxt ( ) . enter ( |infcx| {
235- // Remove the lifetimes unnecessary for this error.
236- ty = infcx. freshen ( ty) ;
237- } ) ;
231+ for & ( mut ty, is_target_ty) in & tys {
232+ ty = tcx. erase_regions ( ty) ;
238233 ty = match ty. kind ( ) {
239234 // Remove the type arguments from the output, as they are not relevant.
240235 // You can think of this as the reverse of `resolve_vars_if_possible`.
@@ -264,7 +259,7 @@ fn emit_orphan_check_error<'tcx>(
264259 } ;
265260
266261 let msg = format ! ( "{} is not defined in the current crate{}" , ty, postfix) ;
267- if * is_target_ty {
262+ if is_target_ty {
268263 // Point at `D<A>` in `impl<A, B> for C<B> in D<A>`
269264 err. span_label ( self_ty_span, & msg) ;
270265 } else {
0 commit comments