@@ -5,7 +5,6 @@ use rustc_data_structures::fx::FxHashSet;
5
5
use rustc_errors:: struct_span_err;
6
6
use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
7
7
use rustc_hir as hir;
8
- use rustc_infer:: infer:: TyCtxtInferExt ;
9
8
use rustc_middle:: ty:: subst:: GenericArgKind ;
10
9
use rustc_middle:: ty:: subst:: InternalSubsts ;
11
10
use rustc_middle:: ty:: util:: IgnoreRegions ;
@@ -229,12 +228,8 @@ fn emit_orphan_check_error<'tcx>(
229
228
"only traits defined in the current crate {msg}"
230
229
) ;
231
230
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) ;
238
233
ty = match ty. kind ( ) {
239
234
// Remove the type arguments from the output, as they are not relevant.
240
235
// You can think of this as the reverse of `resolve_vars_if_possible`.
@@ -264,7 +259,7 @@ fn emit_orphan_check_error<'tcx>(
264
259
} ;
265
260
266
261
let msg = format ! ( "{} is not defined in the current crate{}" , ty, postfix) ;
267
- if * is_target_ty {
262
+ if is_target_ty {
268
263
// Point at `D<A>` in `impl<A, B> for C<B> in D<A>`
269
264
err. span_label ( self_ty_span, & msg) ;
270
265
} else {
0 commit comments