incremental: migrate diagnostics
Migrate the `rustc_incremental` crate's diagnostics to translatable diagnostic structs. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
2575b1abc9
commit
2ff46641a9
13 changed files with 617 additions and 253 deletions
|
@ -33,6 +33,7 @@
|
|||
//! fn baz() { foo(); }
|
||||
//! ```
|
||||
|
||||
use crate::errors;
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::graph::implementation::{Direction, NodeIndex, INCOMING, OUTGOING};
|
||||
|
@ -133,12 +134,10 @@ impl<'tcx> IfThisChanged<'tcx> {
|
|||
Some(n) => {
|
||||
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
|
||||
Ok(n) => n,
|
||||
Err(()) => {
|
||||
self.tcx.sess.span_fatal(
|
||||
attr.span,
|
||||
&format!("unrecognized DepNode variant {:?}", n),
|
||||
);
|
||||
}
|
||||
Err(()) => self.tcx.sess.emit_fatal(errors::UnrecognizedDepNode {
|
||||
span: attr.span,
|
||||
name: n,
|
||||
}),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -149,16 +148,14 @@ impl<'tcx> IfThisChanged<'tcx> {
|
|||
Some(n) => {
|
||||
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
|
||||
Ok(n) => n,
|
||||
Err(()) => {
|
||||
self.tcx.sess.span_fatal(
|
||||
attr.span,
|
||||
&format!("unrecognized DepNode variant {:?}", n),
|
||||
);
|
||||
}
|
||||
Err(()) => self.tcx.sess.emit_fatal(errors::UnrecognizedDepNode {
|
||||
span: attr.span,
|
||||
name: n,
|
||||
}),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
self.tcx.sess.span_fatal(attr.span, "missing DepNode variant");
|
||||
self.tcx.sess.emit_fatal(errors::MissingDepNode { span: attr.span });
|
||||
}
|
||||
};
|
||||
self.then_this_would_need.push((
|
||||
|
@ -204,7 +201,7 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
|
|||
// Return early here so as not to construct the query, which is not cheap.
|
||||
if if_this_changed.is_empty() {
|
||||
for &(target_span, _, _, _) in then_this_would_need {
|
||||
tcx.sess.span_err(target_span, "no `#[rustc_if_this_changed]` annotation detected");
|
||||
tcx.sess.emit_err(errors::MissingIfThisChanged { span: target_span });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -213,16 +210,13 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
|
|||
let dependents = query.transitive_predecessors(source_dep_node);
|
||||
for &(target_span, ref target_pass, _, ref target_dep_node) in then_this_would_need {
|
||||
if !dependents.contains(&target_dep_node) {
|
||||
tcx.sess.span_err(
|
||||
target_span,
|
||||
&format!(
|
||||
"no path from `{}` to `{}`",
|
||||
tcx.def_path_str(source_def_id),
|
||||
target_pass
|
||||
),
|
||||
);
|
||||
tcx.sess.emit_err(errors::NoPath {
|
||||
span: target_span,
|
||||
source: tcx.def_path_str(source_def_id),
|
||||
target: *target_pass,
|
||||
});
|
||||
} else {
|
||||
tcx.sess.span_err(target_span, "OK");
|
||||
tcx.sess.emit_err(errors::Ok { span: target_span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue