@@ -808,7 +808,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
808808 // resolved the same as the `'_` in `&'_ Foo`.
809809 //
810810 // cc #48468
811- self . resolve_elided_lifetimes ( & [ lifetime] )
812811 }
813812 LifetimeName :: Param ( ..) | LifetimeName :: Static => {
814813 // If the user wrote an explicit name, use that.
@@ -1082,15 +1081,14 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
10821081 #[ tracing:: instrument( level = "debug" , skip( self ) ) ]
10831082 fn visit_lifetime ( & mut self , lifetime_ref : & ' tcx hir:: Lifetime ) {
10841083 match lifetime_ref. name {
1085- hir:: LifetimeName :: ImplicitObjectLifetimeDefault | hir:: LifetimeName :: Infer => {
1086- self . resolve_elided_lifetimes ( & [ lifetime_ref] )
1087- }
10881084 hir:: LifetimeName :: Static => self . insert_lifetime ( lifetime_ref, Region :: Static ) ,
10891085 hir:: LifetimeName :: Param ( param_def_id, _) => {
10901086 self . resolve_lifetime_ref ( param_def_id, lifetime_ref)
10911087 }
10921088 // If we've already reported an error, just ignore `lifetime_ref`.
10931089 hir:: LifetimeName :: Error => { }
1090+ // Those will be resolved by typechecking.
1091+ hir:: LifetimeName :: ImplicitObjectLifetimeDefault | hir:: LifetimeName :: Infer => { }
10941092 }
10951093 }
10961094
@@ -1737,26 +1735,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
17371735 return ;
17381736 }
17391737
1740- let mut elide_lifetimes = true ;
1741- let lifetimes: Vec < _ > = generic_args
1742- . args
1743- . iter ( )
1744- . filter_map ( |arg| match arg {
1745- hir:: GenericArg :: Lifetime ( lt) => {
1746- if !lt. is_elided ( ) {
1747- elide_lifetimes = false ;
1748- }
1749- Some ( lt)
1750- }
1751- _ => None ,
1752- } )
1753- . collect ( ) ;
1754- // We short-circuit here if all are elided in order to pluralize
1755- // possible errors
1756- if elide_lifetimes {
1757- self . resolve_elided_lifetimes ( & lifetimes) ;
1758- } else {
1759- lifetimes. iter ( ) . for_each ( |lt| self . visit_lifetime ( lt) ) ;
1738+ for arg in generic_args. args {
1739+ if let hir:: GenericArg :: Lifetime ( lt) = arg {
1740+ self . visit_lifetime ( lt) ;
1741+ }
17601742 }
17611743
17621744 // Figure out if this is a type/trait segment,
@@ -2027,35 +2009,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
20272009 }
20282010 }
20292011
2030- fn resolve_elided_lifetimes ( & mut self , lifetime_refs : & [ & ' tcx hir:: Lifetime ] ) {
2031- debug ! ( "resolve_elided_lifetimes(lifetime_refs={:?})" , lifetime_refs) ;
2032-
2033- if lifetime_refs. is_empty ( ) {
2034- return ;
2035- }
2036-
2037- let mut scope = self . scope ;
2038- loop {
2039- match * scope {
2040- // Do not assign any resolution, it will be inferred.
2041- Scope :: Body { .. } => return ,
2042-
2043- Scope :: Root | Scope :: Elision { .. } => break ,
2044-
2045- Scope :: Binder { s, .. }
2046- | Scope :: ObjectLifetimeDefault { s, .. }
2047- | Scope :: Supertrait { s, .. }
2048- | Scope :: TraitRefBoundary { s, .. } => {
2049- scope = s;
2050- }
2051- }
2052- }
2053-
2054- for lt in lifetime_refs {
2055- self . tcx . sess . delay_span_bug ( lt. span , "Missing lifetime specifier" ) ;
2056- }
2057- }
2058-
20592012 fn resolve_object_lifetime_default ( & mut self , lifetime_ref : & ' tcx hir:: Lifetime ) {
20602013 debug ! ( "resolve_object_lifetime_default(lifetime_ref={:?})" , lifetime_ref) ;
20612014 let mut late_depth = 0 ;
0 commit comments