@@ -808,7 +808,6 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
808
808
// resolved the same as the `'_` in `&'_ Foo`.
809
809
//
810
810
// cc #48468
811
- self . resolve_elided_lifetimes ( & [ lifetime] )
812
811
}
813
812
LifetimeName :: Param ( ..) | LifetimeName :: Static => {
814
813
// If the user wrote an explicit name, use that.
@@ -1082,15 +1081,14 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
1082
1081
#[ tracing:: instrument( level = "debug" , skip( self ) ) ]
1083
1082
fn visit_lifetime ( & mut self , lifetime_ref : & ' tcx hir:: Lifetime ) {
1084
1083
match lifetime_ref. name {
1085
- hir:: LifetimeName :: ImplicitObjectLifetimeDefault | hir:: LifetimeName :: Infer => {
1086
- self . resolve_elided_lifetimes ( & [ lifetime_ref] )
1087
- }
1088
1084
hir:: LifetimeName :: Static => self . insert_lifetime ( lifetime_ref, Region :: Static ) ,
1089
1085
hir:: LifetimeName :: Param ( param_def_id, _) => {
1090
1086
self . resolve_lifetime_ref ( param_def_id, lifetime_ref)
1091
1087
}
1092
1088
// If we've already reported an error, just ignore `lifetime_ref`.
1093
1089
hir:: LifetimeName :: Error => { }
1090
+ // Those will be resolved by typechecking.
1091
+ hir:: LifetimeName :: ImplicitObjectLifetimeDefault | hir:: LifetimeName :: Infer => { }
1094
1092
}
1095
1093
}
1096
1094
@@ -1737,26 +1735,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1737
1735
return ;
1738
1736
}
1739
1737
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
+ }
1760
1742
}
1761
1743
1762
1744
// Figure out if this is a type/trait segment,
@@ -2027,35 +2009,6 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
2027
2009
}
2028
2010
}
2029
2011
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
-
2059
2012
fn resolve_object_lifetime_default ( & mut self , lifetime_ref : & ' tcx hir:: Lifetime ) {
2060
2013
debug ! ( "resolve_object_lifetime_default(lifetime_ref={:?})" , lifetime_ref) ;
2061
2014
let mut late_depth = 0 ;
0 commit comments