@@ -916,7 +916,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
916
916
917
917
ty:: Predicate :: ObjectSafe ( trait_def_id) => {
918
918
let violations = self . tcx . object_safety_violations ( trait_def_id) ;
919
- self . tcx . report_object_safety_error ( span, trait_def_id, violations)
919
+ report_object_safety_error ( self . tcx , span, trait_def_id, violations)
920
920
}
921
921
922
922
ty:: Predicate :: ClosureKind ( closure_def_id, closure_substs, kind) => {
@@ -1080,7 +1080,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1080
1080
1081
1081
TraitNotObjectSafe ( did) => {
1082
1082
let violations = self . tcx . object_safety_violations ( did) ;
1083
- self . tcx . report_object_safety_error ( span, did, violations)
1083
+ report_object_safety_error ( self . tcx , span, did, violations)
1084
1084
}
1085
1085
1086
1086
// already reported in the query
@@ -1945,64 +1945,62 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
1945
1945
}
1946
1946
}
1947
1947
1948
- impl < ' tcx > TyCtxt < ' tcx > {
1949
- pub fn recursive_type_with_infinite_size_error (
1950
- self ,
1951
- type_def_id : DefId ,
1952
- ) -> DiagnosticBuilder < ' tcx > {
1953
- assert ! ( type_def_id. is_local( ) ) ;
1954
- let span = self . hir ( ) . span_if_local ( type_def_id) . unwrap ( ) ;
1955
- let span = self . sess . source_map ( ) . def_span ( span) ;
1956
- let mut err = struct_span_err ! (
1957
- self . sess,
1958
- span,
1959
- E0072 ,
1960
- "recursive type `{}` has infinite size" ,
1961
- self . def_path_str( type_def_id)
1962
- ) ;
1963
- err. span_label ( span, "recursive type has infinite size" ) ;
1964
- err. help ( & format ! (
1965
- "insert indirection (e.g., a `Box`, `Rc`, or `&`) \
1948
+ pub fn recursive_type_with_infinite_size_error (
1949
+ tcx : TyCtxt < ' tcx > ,
1950
+ type_def_id : DefId ,
1951
+ ) -> DiagnosticBuilder < ' tcx > {
1952
+ assert ! ( type_def_id. is_local( ) ) ;
1953
+ let span = tcx. hir ( ) . span_if_local ( type_def_id) . unwrap ( ) ;
1954
+ let span = tcx. sess . source_map ( ) . def_span ( span) ;
1955
+ let mut err = struct_span_err ! (
1956
+ tcx. sess,
1957
+ span,
1958
+ E0072 ,
1959
+ "recursive type `{}` has infinite size" ,
1960
+ tcx. def_path_str( type_def_id)
1961
+ ) ;
1962
+ err. span_label ( span, "recursive type has infinite size" ) ;
1963
+ err. help ( & format ! (
1964
+ "insert indirection (e.g., a `Box`, `Rc`, or `&`) \
1966
1965
at some point to make `{}` representable",
1967
- self . def_path_str( type_def_id)
1968
- ) ) ;
1969
- err
1970
- }
1971
-
1972
- pub fn report_object_safety_error (
1973
- self ,
1974
- span : Span ,
1975
- trait_def_id : DefId ,
1976
- violations : Vec < ObjectSafetyViolation > ,
1977
- ) -> DiagnosticBuilder < ' tcx > {
1978
- let trait_str = self . def_path_str ( trait_def_id) ;
1979
- let span = self . sess . source_map ( ) . def_span ( span) ;
1980
- let mut err = struct_span_err ! (
1981
- self . sess,
1982
- span,
1983
- E0038 ,
1984
- "the trait `{}` cannot be made into an object" ,
1985
- trait_str
1986
- ) ;
1987
- err. span_label ( span, format ! ( "the trait `{}` cannot be made into an object" , trait_str) ) ;
1988
-
1989
- let mut reported_violations = FxHashSet :: default ( ) ;
1990
- for violation in violations {
1991
- if reported_violations. insert ( violation. clone ( ) ) {
1992
- match violation. span ( ) {
1993
- Some ( span) => err. span_label ( span, violation. error_msg ( ) ) ,
1994
- None => err. note ( & violation. error_msg ( ) ) ,
1995
- } ;
1996
- }
1997
- }
1966
+ tcx. def_path_str( type_def_id)
1967
+ ) ) ;
1968
+ err
1969
+ }
1998
1970
1999
- if self . sess . trait_methods_not_found . borrow ( ) . contains ( & span) {
2000
- // Avoid emitting error caused by non-existing method (#58734)
2001
- err. cancel ( ) ;
1971
+ pub fn report_object_safety_error (
1972
+ tcx : TyCtxt < ' tcx > ,
1973
+ span : Span ,
1974
+ trait_def_id : DefId ,
1975
+ violations : Vec < ObjectSafetyViolation > ,
1976
+ ) -> DiagnosticBuilder < ' tcx > {
1977
+ let trait_str = tcx. def_path_str ( trait_def_id) ;
1978
+ let span = tcx. sess . source_map ( ) . def_span ( span) ;
1979
+ let mut err = struct_span_err ! (
1980
+ tcx. sess,
1981
+ span,
1982
+ E0038 ,
1983
+ "the trait `{}` cannot be made into an object" ,
1984
+ trait_str
1985
+ ) ;
1986
+ err. span_label ( span, format ! ( "the trait `{}` cannot be made into an object" , trait_str) ) ;
1987
+
1988
+ let mut reported_violations = FxHashSet :: default ( ) ;
1989
+ for violation in violations {
1990
+ if reported_violations. insert ( violation. clone ( ) ) {
1991
+ match violation. span ( ) {
1992
+ Some ( span) => err. span_label ( span, violation. error_msg ( ) ) ,
1993
+ None => err. note ( & violation. error_msg ( ) ) ,
1994
+ } ;
2002
1995
}
1996
+ }
2003
1997
2004
- err
1998
+ if tcx. sess . trait_methods_not_found . borrow ( ) . contains ( & span) {
1999
+ // Avoid emitting error caused by non-existing method (#58734)
2000
+ err. cancel ( ) ;
2005
2001
}
2002
+
2003
+ err
2006
2004
}
2007
2005
2008
2006
impl < ' a , ' tcx > InferCtxt < ' a , ' tcx > {
0 commit comments