@@ -21,7 +21,7 @@ use rustc_middle::query::Providers;
2121use rustc_middle:: ty:: { self , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
2222use rustc_session:: lint;
2323use rustc_span:: def_id:: DefId ;
24- use rustc_span:: symbol:: { sym , Ident } ;
24+ use rustc_span:: symbol:: Ident ;
2525use rustc_span:: { Span , DUMMY_SP } ;
2626use std:: fmt;
2727
@@ -1197,68 +1197,14 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
11971197 break None ;
11981198 }
11991199
1200- Scope :: Binder { ref bound_vars, scope_type, s, where_bound_origin , .. } => {
1200+ Scope :: Binder { ref bound_vars, scope_type, s, .. } => {
12011201 if let Some ( & def) = bound_vars. get ( & region_def_id) {
12021202 break Some ( def. shifted ( late_depth) ) ;
12031203 }
12041204 match scope_type {
12051205 BinderScopeType :: Normal => late_depth += 1 ,
12061206 BinderScopeType :: Concatenating => { }
12071207 }
1208- // Fresh lifetimes in APIT used to be allowed in async fns and forbidden in
1209- // regular fns.
1210- if let Some ( hir:: PredicateOrigin :: ImplTrait ) = where_bound_origin
1211- && let hir:: LifetimeName :: Param ( param_id) = lifetime_ref. res
1212- && let Some ( generics) = self . tcx . hir ( ) . get_generics ( self . tcx . local_parent ( param_id) )
1213- && let Some ( param) = generics. params . iter ( ) . find ( |p| p. def_id == param_id)
1214- && param. is_elided_lifetime ( )
1215- && !self . tcx . asyncness ( lifetime_ref. hir_id . owner . def_id ) . is_async ( )
1216- && !self . tcx . features ( ) . anonymous_lifetime_in_impl_trait
1217- {
1218- let mut diag = rustc_session:: parse:: feature_err (
1219- & self . tcx . sess . parse_sess ,
1220- sym:: anonymous_lifetime_in_impl_trait,
1221- lifetime_ref. ident . span ,
1222- "anonymous lifetimes in `impl Trait` are unstable" ,
1223- ) ;
1224-
1225- if let Some ( generics) =
1226- self . tcx . hir ( ) . get_generics ( lifetime_ref. hir_id . owner . def_id )
1227- {
1228- let new_param_sugg = if let Some ( span) =
1229- generics. span_for_lifetime_suggestion ( )
1230- {
1231- ( span, "'a, " . to_owned ( ) )
1232- } else {
1233- ( generics. span , "<'a>" . to_owned ( ) )
1234- } ;
1235-
1236- let lifetime_sugg = match lifetime_ref. suggestion_position ( ) {
1237- ( hir:: LifetimeSuggestionPosition :: Normal , span) => ( span, "'a" . to_owned ( ) ) ,
1238- ( hir:: LifetimeSuggestionPosition :: Ampersand , span) => ( span, "'a " . to_owned ( ) ) ,
1239- ( hir:: LifetimeSuggestionPosition :: ElidedPath , span) => ( span, "<'a>" . to_owned ( ) ) ,
1240- ( hir:: LifetimeSuggestionPosition :: ElidedPathArgument , span) => ( span, "'a, " . to_owned ( ) ) ,
1241- ( hir:: LifetimeSuggestionPosition :: ObjectDefault , span) => ( span, "+ 'a" . to_owned ( ) ) ,
1242- } ;
1243- let suggestions = vec ! [
1244- lifetime_sugg,
1245- new_param_sugg,
1246- ] ;
1247-
1248- diag. span_label (
1249- lifetime_ref. ident . span ,
1250- "expected named lifetime parameter" ,
1251- ) ;
1252- diag. multipart_suggestion (
1253- "consider introducing a named lifetime parameter" ,
1254- suggestions,
1255- rustc_errors:: Applicability :: MaybeIncorrect ,
1256- ) ;
1257- }
1258-
1259- diag. emit ( ) ;
1260- return ;
1261- }
12621208 scope = s;
12631209 }
12641210
0 commit comments