@@ -1971,68 +1971,65 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1971
1971
// Therefore, we would compute `object_lifetime_defaults` to a
1972
1972
// vector like `['x, 'static]`. Note that the vector only
1973
1973
// includes type parameters.
1974
- let object_lifetime_defaults = type_def_id. map_or_else (
1975
- || vec ! [ ] ,
1976
- |def_id| {
1977
- let in_body = {
1978
- let mut scope = self . scope ;
1979
- loop {
1980
- match * scope {
1981
- Scope :: Root => break false ,
1982
-
1983
- Scope :: Body { .. } => break true ,
1984
-
1985
- Scope :: Binder { s, .. }
1986
- | Scope :: Elision { s, .. }
1987
- | Scope :: ObjectLifetimeDefault { s, .. } => {
1988
- scope = s;
1989
- }
1974
+ let object_lifetime_defaults = type_def_id. map_or_else ( Vec :: new, |def_id| {
1975
+ let in_body = {
1976
+ let mut scope = self . scope ;
1977
+ loop {
1978
+ match * scope {
1979
+ Scope :: Root => break false ,
1980
+
1981
+ Scope :: Body { .. } => break true ,
1982
+
1983
+ Scope :: Binder { s, .. }
1984
+ | Scope :: Elision { s, .. }
1985
+ | Scope :: ObjectLifetimeDefault { s, .. } => {
1986
+ scope = s;
1990
1987
}
1991
1988
}
1992
- } ;
1989
+ }
1990
+ } ;
1993
1991
1994
- let map = & self . map ;
1995
- let unsubst = if let Some ( def_id) = def_id. as_local ( ) {
1996
- let id = self . tcx . hir ( ) . local_def_id_to_hir_id ( def_id) ;
1997
- & map. object_lifetime_defaults [ & id]
1998
- } else {
1999
- let tcx = self . tcx ;
2000
- self . xcrate_object_lifetime_defaults . entry ( def_id) . or_insert_with ( || {
2001
- tcx. generics_of ( def_id)
2002
- . params
2003
- . iter ( )
2004
- . filter_map ( |param| match param. kind {
2005
- GenericParamDefKind :: Type { object_lifetime_default, .. } => {
2006
- Some ( object_lifetime_default)
2007
- }
2008
- GenericParamDefKind :: Lifetime | GenericParamDefKind :: Const => None ,
2009
- } )
2010
- . collect ( )
2011
- } )
2012
- } ;
2013
- debug ! ( "visit_segment_args: unsubst={:?}" , unsubst) ;
2014
- unsubst
2015
- . iter ( )
2016
- . map ( |set| match * set {
2017
- Set1 :: Empty => {
2018
- if in_body {
2019
- None
2020
- } else {
2021
- Some ( Region :: Static )
1992
+ let map = & self . map ;
1993
+ let unsubst = if let Some ( def_id) = def_id. as_local ( ) {
1994
+ let id = self . tcx . hir ( ) . local_def_id_to_hir_id ( def_id) ;
1995
+ & map. object_lifetime_defaults [ & id]
1996
+ } else {
1997
+ let tcx = self . tcx ;
1998
+ self . xcrate_object_lifetime_defaults . entry ( def_id) . or_insert_with ( || {
1999
+ tcx. generics_of ( def_id)
2000
+ . params
2001
+ . iter ( )
2002
+ . filter_map ( |param| match param. kind {
2003
+ GenericParamDefKind :: Type { object_lifetime_default, .. } => {
2004
+ Some ( object_lifetime_default)
2022
2005
}
2006
+ GenericParamDefKind :: Lifetime | GenericParamDefKind :: Const => None ,
2007
+ } )
2008
+ . collect ( )
2009
+ } )
2010
+ } ;
2011
+ debug ! ( "visit_segment_args: unsubst={:?}" , unsubst) ;
2012
+ unsubst
2013
+ . iter ( )
2014
+ . map ( |set| match * set {
2015
+ Set1 :: Empty => {
2016
+ if in_body {
2017
+ None
2018
+ } else {
2019
+ Some ( Region :: Static )
2023
2020
}
2024
- Set1 :: One ( r ) => {
2025
- let lifetimes = generic_args . args . iter ( ) . filter_map ( |arg| match arg {
2026
- GenericArg :: Lifetime ( lt ) => Some ( lt ) ,
2027
- _ => None ,
2028
- } ) ;
2029
- r . subst ( lifetimes , map )
2030
- }
2031
- Set1 :: Many => None ,
2032
- } )
2033
- . collect ( )
2034
- } ,
2035
- ) ;
2021
+ }
2022
+ Set1 :: One ( r ) => {
2023
+ let lifetimes = generic_args . args . iter ( ) . filter_map ( |arg| match arg {
2024
+ GenericArg :: Lifetime ( lt ) => Some ( lt ) ,
2025
+ _ => None ,
2026
+ } ) ;
2027
+ r . subst ( lifetimes , map )
2028
+ }
2029
+ Set1 :: Many => None ,
2030
+ } )
2031
+ . collect ( )
2032
+ } ) ;
2036
2033
2037
2034
debug ! ( "visit_segment_args: object_lifetime_defaults={:?}" , object_lifetime_defaults) ;
2038
2035
0 commit comments