Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7e3132a

Browse files
committed
Extract function for reporting feature gate error
1 parent a324fc1 commit 7e3132a

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,22 +1370,7 @@ impl LinkCollector<'_, '_> {
13701370
&& item.def_id.is_local()
13711371
&& !self.cx.tcx.features().intra_doc_pointers
13721372
{
1373-
let span = super::source_span_for_markdown_range(
1374-
self.cx.tcx,
1375-
dox,
1376-
&ori_link.range,
1377-
&item.attrs,
1378-
)
1379-
.unwrap_or_else(|| item.attr_span(self.cx.tcx));
1380-
1381-
rustc_session::parse::feature_err(
1382-
&self.cx.tcx.sess.parse_sess,
1383-
sym::intra_doc_pointers,
1384-
span,
1385-
"linking to associated items of raw pointers is experimental",
1386-
)
1387-
.note("rustdoc does not allow disambiguating between `*const` and `*mut`, and pointers are unstable until it does")
1388-
.emit();
1373+
self.report_rawptr_assoc_feature_gate(dox, &ori_link, item);
13891374
}
13901375
} else {
13911376
match disambiguator {
@@ -1412,6 +1397,20 @@ impl LinkCollector<'_, '_> {
14121397
}
14131398
}
14141399

1400+
fn report_rawptr_assoc_feature_gate(&self, dox: &str, ori_link: &MarkdownLink, item: &Item) {
1401+
let span =
1402+
super::source_span_for_markdown_range(self.cx.tcx, dox, &ori_link.range, &item.attrs)
1403+
.unwrap_or_else(|| item.attr_span(self.cx.tcx));
1404+
rustc_session::parse::feature_err(
1405+
&self.cx.tcx.sess.parse_sess,
1406+
sym::intra_doc_pointers,
1407+
span,
1408+
"linking to associated items of raw pointers is experimental",
1409+
)
1410+
.note("rustdoc does not allow disambiguating between `*const` and `*mut`, and pointers are unstable until it does")
1411+
.emit();
1412+
}
1413+
14151414
fn resolve_with_disambiguator_cached(
14161415
&mut self,
14171416
key: ResolutionInfo,

0 commit comments

Comments
 (0)