Skip to content

Commit

Permalink
give a hard error temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Nov 27, 2022
1 parent 206904c commit 54a50fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/librustdoc/html/render/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::rc::Rc;
use std::sync::mpsc::{channel, Receiver};

use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::HirId;
// use rustc_hir::HirId;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
Expand Down Expand Up @@ -34,7 +34,7 @@ use crate::html::format::{join_with_double_colon, Buffer};
use crate::html::markdown::{self, plain_text_summary, ErrorCodes, IdMap};
use crate::html::url_parts_builder::UrlPartsBuilder;
use crate::html::{layout, sources, static_files};
use crate::lint::BROKEN_HTML_LINKS;
// use crate::lint::BROKEN_HTML_LINKS;
use crate::scrape_examples::AllCallLocations;
use crate::try_err;

Expand Down Expand Up @@ -176,14 +176,14 @@ impl<'tcx> Context<'tcx> {

let path = self.dst.canonicalize().unwrap();
let errors: Vec<_> = unavailable_urls(&path, &CheckContext::default()).collect();
let tcx = self.tcx();
// let tcx = self.tcx();
for err in errors {
// self.sess().struct_warn(&err.to_string().replace('\t', " ")).emit();
let msg = err.to_string().replace('\t', " ");
// TODO: map files back to items
let hir_id: HirId = todo!();
let span = tcx.def_span(tcx.hir().local_def_id(hir_id));
self.tcx().struct_span_lint_hir(BROKEN_HTML_LINKS, hir_id, span, msg, |err| err);
self.sess().struct_err(&err.to_string().replace('\t', " ")).emit();
// let msg = err.to_string().replace('\t', " ");
// // TODO: map files back to items
// let hir_id: HirId = todo!();
// let span = tcx.def_span(tcx.hir().local_def_id(hir_id));
// self.tcx().struct_span_lint_hir(BROKEN_HTML_LINKS, hir_id, span, msg, |err| err);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ fn run_renderer<'tcx, T: formats::FormatRenderer<'tcx>>(
tcx: TyCtxt<'tcx>,
) -> MainResult {
match formats::run_format::<T>(krate, renderopts, cache, tcx) {
Ok(_) => Ok(()),
Ok(_) => tcx.sess.has_errors().map_or(Ok(()), Err),
Err(e) => {
let mut msg =
tcx.sess.struct_err(&format!("couldn't generate documentation: {}", e.error));
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// error-pattern: invalid urls
//! [broken link](./not-here.html)
5 changes: 5 additions & 0 deletions src/test/rustdoc-ui/broken-link.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: Found invalid urls in $TEST_BUILD_DIR/broken-link/broken_link/index.html:
Linked file at path $TEST_BUILD_DIR/broken-link/broken_link/not-here.html does not exist!

error: aborting due to previous error

0 comments on commit 54a50fe

Please sign in to comment.