@@ -1144,15 +1144,7 @@ impl LinkCollector<'_, '_> {
1144
1144
diag. note ( & note) ;
1145
1145
suggest_disambiguator ( resolved, diag, path_str, dox, sp, & ori_link. range ) ;
1146
1146
} ;
1147
- report_diagnostic (
1148
- self . cx . tcx ,
1149
- BROKEN_INTRA_DOC_LINKS ,
1150
- & msg,
1151
- & item,
1152
- dox,
1153
- & ori_link. range ,
1154
- callback,
1155
- ) ;
1147
+ report_diagnostic ( self . cx . tcx , BROKEN_INTRA_DOC_LINKS , & msg, & diag_info, callback) ;
1156
1148
} ;
1157
1149
1158
1150
let verify = |kind : DefKind , id : DefId | {
@@ -1192,7 +1184,7 @@ impl LinkCollector<'_, '_> {
1192
1184
if self . cx . tcx . privacy_access_levels ( LOCAL_CRATE ) . is_exported ( hir_src)
1193
1185
&& !self . cx . tcx . privacy_access_levels ( LOCAL_CRATE ) . is_exported ( hir_dst)
1194
1186
{
1195
- privacy_error ( self . cx , diag_info, & path_str) ;
1187
+ privacy_error ( self . cx , & diag_info, & path_str) ;
1196
1188
}
1197
1189
}
1198
1190
@@ -1665,9 +1657,7 @@ fn report_diagnostic(
1665
1657
tcx : TyCtxt < ' _ > ,
1666
1658
lint : & ' static Lint ,
1667
1659
msg : & str ,
1668
- item : & Item ,
1669
- dox : & str ,
1670
- link_range : & Range < usize > ,
1660
+ DiagnosticInfo { item, ori_link : _, dox, link_range } : & DiagnosticInfo < ' _ > ,
1671
1661
decorate : impl FnOnce ( & mut DiagnosticBuilder < ' _ > , Option < rustc_span:: Span > ) ,
1672
1662
) {
1673
1663
let hir_id = match DocContext :: as_local_hir_id ( tcx, item. def_id ) {
@@ -1721,7 +1711,7 @@ fn report_diagnostic(
1721
1711
/// `std::io::Error::x`, this will resolve `std::io::Error`.
1722
1712
fn resolution_failure (
1723
1713
collector : & mut LinkCollector < ' _ , ' _ > ,
1724
- DiagnosticInfo { item , ori_link : _ , dox , link_range } : DiagnosticInfo < ' _ > ,
1714
+ diag_info : DiagnosticInfo < ' _ > ,
1725
1715
path_str : & str ,
1726
1716
disambiguator : Option < Disambiguator > ,
1727
1717
kinds : SmallVec < [ ResolutionFailure < ' _ > ; 3 ] > ,
@@ -1731,9 +1721,7 @@ fn resolution_failure(
1731
1721
tcx,
1732
1722
BROKEN_INTRA_DOC_LINKS ,
1733
1723
& format ! ( "unresolved link to `{}`" , path_str) ,
1734
- item,
1735
- dox,
1736
- & link_range,
1724
+ & diag_info,
1737
1725
|diag, sp| {
1738
1726
let item = |res : Res | format ! ( "the {} `{}`" , res. descr( ) , res. name( tcx) , ) ;
1739
1727
let assoc_item_not_allowed = |res : Res | {
@@ -1893,9 +1881,9 @@ fn resolution_failure(
1893
1881
disambiguator,
1894
1882
diag,
1895
1883
path_str,
1896
- dox,
1884
+ diag_info . dox ,
1897
1885
sp,
1898
- & link_range,
1886
+ & diag_info . link_range ,
1899
1887
)
1900
1888
}
1901
1889
@@ -1942,21 +1930,19 @@ fn resolution_failure(
1942
1930
}
1943
1931
1944
1932
/// Report an anchor failure.
1945
- fn anchor_failure (
1946
- cx : & DocContext < ' _ > ,
1947
- DiagnosticInfo { item, ori_link, dox, link_range } : DiagnosticInfo < ' _ > ,
1948
- failure : AnchorFailure ,
1949
- ) {
1933
+ fn anchor_failure ( cx : & DocContext < ' _ > , diag_info : DiagnosticInfo < ' _ > , failure : AnchorFailure ) {
1950
1934
let msg = match failure {
1951
- AnchorFailure :: MultipleAnchors => format ! ( "`{}` contains multiple anchors" , ori_link) ,
1935
+ AnchorFailure :: MultipleAnchors => {
1936
+ format ! ( "`{}` contains multiple anchors" , diag_info. ori_link)
1937
+ }
1952
1938
AnchorFailure :: RustdocAnchorConflict ( res) => format ! (
1953
1939
"`{}` contains an anchor, but links to {kind}s are already anchored" ,
1954
- ori_link,
1940
+ diag_info . ori_link,
1955
1941
kind = res. descr( ) ,
1956
1942
) ,
1957
1943
} ;
1958
1944
1959
- report_diagnostic ( cx. tcx , BROKEN_INTRA_DOC_LINKS , & msg, item , dox , & link_range , |diag, sp| {
1945
+ report_diagnostic ( cx. tcx , BROKEN_INTRA_DOC_LINKS , & msg, & diag_info , |diag, sp| {
1960
1946
if let Some ( sp) = sp {
1961
1947
diag. span_label ( sp, "contains invalid anchor" ) ;
1962
1948
}
@@ -1966,17 +1952,18 @@ fn anchor_failure(
1966
1952
/// Report an error in the link disambiguator.
1967
1953
fn disambiguator_error (
1968
1954
cx : & DocContext < ' _ > ,
1969
- DiagnosticInfo { item , ori_link : _ , dox , link_range : _ } : DiagnosticInfo < ' _ > ,
1955
+ mut diag_info : DiagnosticInfo < ' _ > ,
1970
1956
disambiguator_range : Range < usize > ,
1971
1957
msg : & str ,
1972
1958
) {
1973
- report_diagnostic ( cx. tcx , BROKEN_INTRA_DOC_LINKS , msg, item, dox, & disambiguator_range, |_diag, _sp| { } ) ;
1959
+ diag_info. link_range = disambiguator_range;
1960
+ report_diagnostic ( cx. tcx , BROKEN_INTRA_DOC_LINKS , msg, & diag_info, |_diag, _sp| { } ) ;
1974
1961
}
1975
1962
1976
1963
/// Report an ambiguity error, where there were multiple possible resolutions.
1977
1964
fn ambiguity_error (
1978
1965
cx : & DocContext < ' _ > ,
1979
- DiagnosticInfo { item , ori_link : _ , dox , link_range } : DiagnosticInfo < ' _ > ,
1966
+ diag_info : DiagnosticInfo < ' _ > ,
1980
1967
path_str : & str ,
1981
1968
candidates : Vec < Res > ,
1982
1969
) {
@@ -2004,7 +1991,7 @@ fn ambiguity_error(
2004
1991
}
2005
1992
}
2006
1993
2007
- report_diagnostic ( cx. tcx , BROKEN_INTRA_DOC_LINKS , & msg, item , dox , & link_range , |diag, sp| {
1994
+ report_diagnostic ( cx. tcx , BROKEN_INTRA_DOC_LINKS , & msg, & diag_info , |diag, sp| {
2008
1995
if let Some ( sp) = sp {
2009
1996
diag. span_label ( sp, "ambiguous link" ) ;
2010
1997
} else {
@@ -2013,7 +2000,14 @@ fn ambiguity_error(
2013
2000
2014
2001
for res in candidates {
2015
2002
let disambiguator = Disambiguator :: from_res ( res) ;
2016
- suggest_disambiguator ( disambiguator, diag, path_str, dox, sp, & link_range) ;
2003
+ suggest_disambiguator (
2004
+ disambiguator,
2005
+ diag,
2006
+ path_str,
2007
+ diag_info. dox ,
2008
+ sp,
2009
+ & diag_info. link_range ,
2010
+ ) ;
2017
2011
}
2018
2012
} ) ;
2019
2013
}
@@ -2045,13 +2039,9 @@ fn suggest_disambiguator(
2045
2039
}
2046
2040
2047
2041
/// Report a link from a public item to a private one.
2048
- fn privacy_error (
2049
- cx : & DocContext < ' _ > ,
2050
- DiagnosticInfo { item, ori_link : _, dox, link_range } : DiagnosticInfo < ' _ > ,
2051
- path_str : & str ,
2052
- ) {
2042
+ fn privacy_error ( cx : & DocContext < ' _ > , diag_info : & DiagnosticInfo < ' _ > , path_str : & str ) {
2053
2043
let sym;
2054
- let item_name = match item. name {
2044
+ let item_name = match diag_info . item . name {
2055
2045
Some ( name) => {
2056
2046
sym = name. as_str ( ) ;
2057
2047
& * sym
@@ -2061,7 +2051,7 @@ fn privacy_error(
2061
2051
let msg =
2062
2052
format ! ( "public documentation for `{}` links to private item `{}`" , item_name, path_str) ;
2063
2053
2064
- report_diagnostic ( cx. tcx , PRIVATE_INTRA_DOC_LINKS , & msg, item , dox , & link_range , |diag, sp| {
2054
+ report_diagnostic ( cx. tcx , PRIVATE_INTRA_DOC_LINKS , & msg, diag_info , |diag, sp| {
2065
2055
if let Some ( sp) = sp {
2066
2056
diag. span_label ( sp, "this item is private" ) ;
2067
2057
}
0 commit comments