@@ -1318,10 +1318,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1318
1318
// those that do.
1319
1319
self . one_bound_for_assoc_type (
1320
1320
|| traits:: supertraits ( tcx, trait_ref) ,
1321
- & trait_ref. print_only_trait_path ( ) . to_string ( ) ,
1321
+ || trait_ref. print_only_trait_path ( ) . to_string ( ) ,
1322
1322
binding. item_name ,
1323
1323
path_span,
1324
- match binding. kind {
1324
+ || match binding. kind {
1325
1325
ConvertedBindingKind :: Equality ( ty) => Some ( ty. to_string ( ) ) ,
1326
1326
_ => None ,
1327
1327
} ,
@@ -1878,10 +1878,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1878
1878
predicates. iter ( ) . filter_map ( |( p, _) | p. to_opt_poly_trait_ref ( ) ) ,
1879
1879
)
1880
1880
} ,
1881
- & param_name. as_str ( ) ,
1881
+ || param_name. to_string ( ) ,
1882
1882
assoc_name,
1883
1883
span,
1884
- None ,
1884
+ || None ,
1885
1885
)
1886
1886
}
1887
1887
@@ -1890,10 +1890,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1890
1890
fn one_bound_for_assoc_type < I > (
1891
1891
& self ,
1892
1892
all_candidates : impl Fn ( ) -> I ,
1893
- ty_param_name : & str ,
1893
+ ty_param_name : impl Fn ( ) -> String ,
1894
1894
assoc_name : ast:: Ident ,
1895
1895
span : Span ,
1896
- is_equality : Option < String > ,
1896
+ is_equality : impl Fn ( ) -> Option < String > ,
1897
1897
) -> Result < ty:: PolyTraitRef < ' tcx > , ErrorReported >
1898
1898
where
1899
1899
I : Iterator < Item = ty:: PolyTraitRef < ' tcx > > ,
@@ -1906,7 +1906,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1906
1906
None => {
1907
1907
self . complain_about_assoc_type_not_found (
1908
1908
all_candidates,
1909
- ty_param_name,
1909
+ & ty_param_name ( ) ,
1910
1910
assoc_name,
1911
1911
span,
1912
1912
) ;
@@ -1919,6 +1919,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1919
1919
if let Some ( bound2) = matching_candidates. next ( ) {
1920
1920
debug ! ( "one_bound_for_assoc_type: bound2 = {:?}" , bound2) ;
1921
1921
1922
+ let is_equality = is_equality ( ) ;
1922
1923
let bounds = iter:: once ( bound) . chain ( iter:: once ( bound2) ) . chain ( matching_candidates) ;
1923
1924
let mut err = if is_equality. is_some ( ) {
1924
1925
// More specific Error Index entry.
@@ -1928,7 +1929,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1928
1929
E0222 ,
1929
1930
"ambiguous associated type `{}` in bounds of `{}`" ,
1930
1931
assoc_name,
1931
- ty_param_name
1932
+ ty_param_name( )
1932
1933
)
1933
1934
} else {
1934
1935
struct_span_err ! (
@@ -1937,7 +1938,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1937
1938
E0221 ,
1938
1939
"ambiguous associated type `{}` in bounds of `{}`" ,
1939
1940
assoc_name,
1940
- ty_param_name
1941
+ ty_param_name( )
1941
1942
)
1942
1943
} ;
1943
1944
err. span_label ( span, format ! ( "ambiguous associated type `{}`" , assoc_name) ) ;
@@ -1975,7 +1976,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1975
1976
"use fully qualified syntax to disambiguate" ,
1976
1977
format ! (
1977
1978
"<{} as {}>::{}" ,
1978
- ty_param_name,
1979
+ ty_param_name( ) ,
1979
1980
bound. print_only_trait_path( ) ,
1980
1981
assoc_name,
1981
1982
) ,
@@ -1985,7 +1986,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1985
1986
} else {
1986
1987
err. note ( & format ! (
1987
1988
"associated type `{}` could derive from `{}`" ,
1988
- ty_param_name,
1989
+ ty_param_name( ) ,
1989
1990
bound. print_only_trait_path( ) ,
1990
1991
) ) ;
1991
1992
}
@@ -1994,7 +1995,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
1994
1995
err. help ( & format ! (
1995
1996
"consider introducing a new type parameter `T` and adding `where` constraints:\
1996
1997
\n where\n T: {},\n {}",
1997
- ty_param_name,
1998
+ ty_param_name( ) ,
1998
1999
where_bounds. join( ",\n " ) ,
1999
2000
) ) ;
2000
2001
}
@@ -2108,10 +2109,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2108
2109
2109
2110
self . one_bound_for_assoc_type (
2110
2111
|| traits:: supertraits ( tcx, ty:: Binder :: bind ( trait_ref) ) ,
2111
- "Self" ,
2112
+ || "Self" . to_string ( ) ,
2112
2113
assoc_ident,
2113
2114
span,
2114
- None ,
2115
+ || None ,
2115
2116
) ?
2116
2117
}
2117
2118
( & ty:: Param ( _) , Res :: SelfTy ( Some ( param_did) , None ) )
0 commit comments