Remove Session
methods that duplicate DiagCtxt
methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
This commit is contained in:
parent
d51db05d7e
commit
99472c7049
298 changed files with 1806 additions and 2064 deletions
|
@ -134,7 +134,7 @@ 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.emit_fatal(errors::UnrecognizedDepNode {
|
||||
Err(()) => self.tcx.dcx().emit_fatal(errors::UnrecognizedDepNode {
|
||||
span: attr.span,
|
||||
name: n,
|
||||
}),
|
||||
|
@ -148,14 +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.emit_fatal(errors::UnrecognizedDepNode {
|
||||
Err(()) => self.tcx.dcx().emit_fatal(errors::UnrecognizedDepNode {
|
||||
span: attr.span,
|
||||
name: n,
|
||||
}),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
self.tcx.sess.emit_fatal(errors::MissingDepNode { span: attr.span });
|
||||
self.tcx.dcx().emit_fatal(errors::MissingDepNode { span: attr.span });
|
||||
}
|
||||
};
|
||||
self.then_this_would_need.push((
|
||||
|
@ -201,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.emit_err(errors::MissingIfThisChanged { span: target_span });
|
||||
tcx.dcx().emit_err(errors::MissingIfThisChanged { span: target_span });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -210,13 +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.emit_err(errors::NoPath {
|
||||
tcx.dcx().emit_err(errors::NoPath {
|
||||
span: target_span,
|
||||
source: tcx.def_path_str(source_def_id),
|
||||
target: *target_pass,
|
||||
});
|
||||
} else {
|
||||
tcx.sess.emit_err(errors::Ok { span: target_span });
|
||||
tcx.dcx().emit_err(errors::Ok { span: target_span });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
let loaded_from_disk = self.loaded_from_disk(attr);
|
||||
for e in except.items().into_sorted_stable_ord() {
|
||||
if !auto.remove(e) {
|
||||
self.tcx.sess.emit_fatal(errors::AssertionAuto { span: attr.span, name, e });
|
||||
self.tcx.dcx().emit_fatal(errors::AssertionAuto { span: attr.span, name, e });
|
||||
}
|
||||
}
|
||||
Assertion { clean: auto, dirty: except, loaded_from_disk }
|
||||
|
@ -281,7 +281,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
// An implementation, eg `impl<A> Trait for Foo { .. }`
|
||||
HirItem::Impl { .. } => ("ItemKind::Impl", LABELS_IMPL),
|
||||
|
||||
_ => self.tcx.sess.emit_fatal(errors::UndefinedCleanDirtyItem {
|
||||
_ => self.tcx.dcx().emit_fatal(errors::UndefinedCleanDirtyItem {
|
||||
span: attr.span,
|
||||
kind: format!("{:?}", item.kind),
|
||||
}),
|
||||
|
@ -297,7 +297,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
ImplItemKind::Const(..) => ("NodeImplConst", LABELS_CONST_IN_IMPL),
|
||||
ImplItemKind::Type(..) => ("NodeImplType", LABELS_CONST_IN_IMPL),
|
||||
},
|
||||
_ => self.tcx.sess.emit_fatal(errors::UndefinedCleanDirty {
|
||||
_ => self.tcx.dcx().emit_fatal(errors::UndefinedCleanDirty {
|
||||
span: attr.span,
|
||||
kind: format!("{node:?}"),
|
||||
}),
|
||||
|
@ -314,13 +314,13 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
if DepNode::has_label_string(label) {
|
||||
if out.contains(label) {
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_fatal(errors::RepeatedDepNodeLabel { span: item.span(), label });
|
||||
}
|
||||
out.insert(label.to_string());
|
||||
} else {
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_fatal(errors::UnrecognizedDepNodeLabel { span: item.span(), label });
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
if self.tcx.dep_graph.is_green(&dep_node) {
|
||||
let dep_node_str = self.dep_node_str(&dep_node);
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_err(errors::NotDirty { span: item_span, dep_node_str: &dep_node_str });
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
if self.tcx.dep_graph.is_red(&dep_node) {
|
||||
let dep_node_str = self.dep_node_str(&dep_node);
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_err(errors::NotClean { span: item_span, dep_node_str: &dep_node_str });
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ impl<'tcx> DirtyCleanVisitor<'tcx> {
|
|||
if !self.tcx.dep_graph.debug_was_loaded_from_disk(dep_node) {
|
||||
let dep_node_str = self.dep_node_str(&dep_node);
|
||||
self.tcx
|
||||
.sess
|
||||
.dcx()
|
||||
.emit_err(errors::NotLoaded { span: item_span, dep_node_str: &dep_node_str });
|
||||
}
|
||||
}
|
||||
|
@ -405,12 +405,12 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
|
|||
debug!("check_config: searching for cfg {:?}", value);
|
||||
cfg = Some(config.contains(&(value, None)));
|
||||
} else if !(item.has_name(EXCEPT) || item.has_name(LOADED_FROM_DISK)) {
|
||||
tcx.sess.emit_err(errors::UnknownItem { span: attr.span, name: item.name_or_empty() });
|
||||
tcx.dcx().emit_err(errors::UnknownItem { span: attr.span, name: item.name_or_empty() });
|
||||
}
|
||||
}
|
||||
|
||||
match cfg {
|
||||
None => tcx.sess.emit_fatal(errors::NoCfg { span: attr.span }),
|
||||
None => tcx.dcx().emit_fatal(errors::NoCfg { span: attr.span }),
|
||||
Some(c) => c,
|
||||
}
|
||||
}
|
||||
|
@ -420,9 +420,9 @@ fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
|
|||
value
|
||||
} else {
|
||||
if let Some(ident) = item.ident() {
|
||||
tcx.sess.emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
|
||||
} else {
|
||||
tcx.sess.emit_fatal(errors::AssociatedValueExpected { span: item.span() });
|
||||
tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ impl<'tcx> FindAllAttrs<'tcx> {
|
|||
fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet<ast::AttrId>) {
|
||||
for attr in &self.found_attrs {
|
||||
if !checked_attrs.contains(&attr.id) {
|
||||
self.tcx.sess.emit_err(errors::UncheckedClean { span: attr.span });
|
||||
self.tcx.dcx().emit_err(errors::UncheckedClean { span: attr.span });
|
||||
checked_attrs.insert(attr.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ where
|
|||
}
|
||||
Err(err) if err.kind() == io::ErrorKind::NotFound => (),
|
||||
Err(err) => {
|
||||
sess.emit_err(errors::DeleteOld { name, path: path_buf, err });
|
||||
sess.dcx().emit_err(errors::DeleteOld { name, path: path_buf, err });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ where
|
|||
let mut encoder = match FileEncoder::new(&path_buf) {
|
||||
Ok(encoder) => encoder,
|
||||
Err(err) => {
|
||||
sess.emit_err(errors::CreateNew { name, path: path_buf, err });
|
||||
sess.dcx().emit_err(errors::CreateNew { name, path: path_buf, err });
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -81,7 +81,7 @@ where
|
|||
debug!("save: data written to disk successfully");
|
||||
}
|
||||
Err((path, err)) => {
|
||||
sess.emit_err(errors::WriteNew { name, path, err });
|
||||
sess.dcx().emit_err(errors::WriteNew { name, path, err });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ pub(crate) fn prepare_session_directory(
|
|||
let crate_dir = match try_canonicalize(&crate_dir) {
|
||||
Ok(v) => v,
|
||||
Err(err) => {
|
||||
return Err(sess.emit_err(errors::CanonicalizePath { path: crate_dir, err }));
|
||||
return Err(sess.dcx().emit_err(errors::CanonicalizePath { path: crate_dir, err }));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -273,7 +273,7 @@ pub(crate) fn prepare_session_directory(
|
|||
debug!("successfully copied data from: {}", source_directory.display());
|
||||
|
||||
if !allows_links {
|
||||
sess.emit_warning(errors::HardLinkFailed { path: &session_dir });
|
||||
sess.dcx().emit_warning(errors::HardLinkFailed { path: &session_dir });
|
||||
}
|
||||
|
||||
sess.init_incr_comp_session(session_dir, directory_lock);
|
||||
|
@ -288,7 +288,7 @@ pub(crate) fn prepare_session_directory(
|
|||
// Try to remove the session directory we just allocated. We don't
|
||||
// know if there's any garbage in it from the failed copy action.
|
||||
if let Err(err) = safe_remove_dir_all(&session_dir) {
|
||||
sess.emit_warning(errors::DeletePartial { path: &session_dir, err });
|
||||
sess.dcx().emit_warning(errors::DeletePartial { path: &session_dir, err });
|
||||
}
|
||||
|
||||
delete_session_dir_lock_file(sess, &lock_file_path);
|
||||
|
@ -322,7 +322,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
|
|||
);
|
||||
|
||||
if let Err(err) = safe_remove_dir_all(&*incr_comp_session_dir) {
|
||||
sess.emit_warning(errors::DeleteFull { path: &incr_comp_session_dir, err });
|
||||
sess.dcx().emit_warning(errors::DeleteFull { path: &incr_comp_session_dir, err });
|
||||
}
|
||||
|
||||
let lock_file_path = lock_file_path(&*incr_comp_session_dir);
|
||||
|
@ -365,7 +365,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
|
|||
}
|
||||
Err(e) => {
|
||||
// Warn about the error. However, no need to abort compilation now.
|
||||
sess.emit_warning(errors::Finalize { path: &incr_comp_session_dir, err: e });
|
||||
sess.dcx().emit_warning(errors::Finalize { path: &incr_comp_session_dir, err: e });
|
||||
|
||||
debug!("finalize_session_directory() - error, marking as invalid");
|
||||
// Drop the file lock, so we can garage collect
|
||||
|
@ -466,7 +466,7 @@ fn create_dir(sess: &Session, path: &Path, dir_tag: &str) -> Result<(), ErrorGua
|
|||
debug!("{} directory created successfully", dir_tag);
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => Err(sess.emit_err(errors::CreateIncrCompDir { tag: dir_tag, path, err })),
|
||||
Err(err) => Err(sess.dcx().emit_err(errors::CreateIncrCompDir { tag: dir_tag, path, err })),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,7 +488,7 @@ fn lock_directory(
|
|||
Ok(lock) => Ok((lock, lock_file_path)),
|
||||
Err(lock_err) => {
|
||||
let is_unsupported_lock = flock::Lock::error_unsupported(&lock_err).then_some(());
|
||||
Err(sess.emit_err(errors::CreateLock {
|
||||
Err(sess.dcx().emit_err(errors::CreateLock {
|
||||
lock_err,
|
||||
session_dir,
|
||||
is_unsupported_lock,
|
||||
|
@ -500,7 +500,7 @@ fn lock_directory(
|
|||
|
||||
fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) {
|
||||
if let Err(err) = safe_remove_file(lock_file_path) {
|
||||
sess.emit_warning(errors::DeleteLock { path: lock_file_path, err });
|
||||
sess.dcx().emit_warning(errors::DeleteLock { path: lock_file_path, err });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -724,7 +724,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
|
|||
if !lock_file_to_session_dir.items().any(|(_, dir)| *dir == directory_name) {
|
||||
let path = crate_directory.join(directory_name);
|
||||
if let Err(err) = safe_remove_dir_all(&path) {
|
||||
sess.emit_warning(errors::InvalidGcFailed { path: &path, err });
|
||||
sess.dcx().emit_warning(errors::InvalidGcFailed { path: &path, err });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -830,7 +830,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
|
|||
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
|
||||
|
||||
if let Err(err) = safe_remove_dir_all(&path) {
|
||||
sess.emit_warning(errors::FinalizedGcFailed { path: &path, err });
|
||||
sess.dcx().emit_warning(errors::FinalizedGcFailed { path: &path, err });
|
||||
} else {
|
||||
delete_session_dir_lock_file(sess, &lock_file_path(&path));
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ fn delete_old(sess: &Session, path: &Path) {
|
|||
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
|
||||
|
||||
if let Err(err) = safe_remove_dir_all(path) {
|
||||
sess.emit_warning(errors::SessionGcFailed { path: path, err });
|
||||
sess.dcx().emit_warning(errors::SessionGcFailed { path: path, err });
|
||||
} else {
|
||||
delete_session_dir_lock_file(sess, &lock_file_path(path));
|
||||
}
|
||||
|
|
|
@ -38,25 +38,26 @@ impl<T: Default> LoadResult<T> {
|
|||
// Check for errors when using `-Zassert-incremental-state`
|
||||
match (sess.opts.assert_incr_state, &self) {
|
||||
(Some(IncrementalStateAssertion::NotLoaded), LoadResult::Ok { .. }) => {
|
||||
sess.emit_fatal(errors::AssertNotLoaded);
|
||||
sess.dcx().emit_fatal(errors::AssertNotLoaded);
|
||||
}
|
||||
(
|
||||
Some(IncrementalStateAssertion::Loaded),
|
||||
LoadResult::LoadDepGraph(..) | LoadResult::DataOutOfDate,
|
||||
) => {
|
||||
sess.emit_fatal(errors::AssertLoaded);
|
||||
sess.dcx().emit_fatal(errors::AssertLoaded);
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match self {
|
||||
LoadResult::LoadDepGraph(path, err) => {
|
||||
sess.emit_warning(errors::LoadDepGraph { path, err });
|
||||
sess.dcx().emit_warning(errors::LoadDepGraph { path, err });
|
||||
Default::default()
|
||||
}
|
||||
LoadResult::DataOutOfDate => {
|
||||
if let Err(err) = delete_all_session_dir_contents(sess) {
|
||||
sess.emit_err(errors::DeleteIncompatible { path: dep_graph_path(sess), err });
|
||||
sess.dcx()
|
||||
.emit_err(errors::DeleteIncompatible { path: dep_graph_path(sess), err });
|
||||
}
|
||||
Default::default()
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ pub fn save_dep_graph(tcx: TyCtxt<'_>) {
|
|||
move || {
|
||||
sess.time("incr_comp_persist_dep_graph", || {
|
||||
if let Err(err) = fs::rename(&staging_dep_graph_path, &dep_graph_path) {
|
||||
sess.emit_err(errors::MoveDepGraph {
|
||||
sess.dcx().emit_err(errors::MoveDepGraph {
|
||||
from: &staging_dep_graph_path,
|
||||
to: &dep_graph_path,
|
||||
err,
|
||||
|
@ -161,7 +161,7 @@ pub(crate) fn build_dep_graph(
|
|||
let mut encoder = match FileEncoder::new(&path_buf) {
|
||||
Ok(encoder) => encoder,
|
||||
Err(err) => {
|
||||
sess.emit_err(errors::CreateDepGraph { path: &path_buf, err });
|
||||
sess.dcx().emit_err(errors::CreateDepGraph { path: &path_buf, err });
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn copy_cgu_workproduct_to_incr_comp_cache_dir(
|
|||
let _ = saved_files.insert(ext.to_string(), file_name);
|
||||
}
|
||||
Err(err) => {
|
||||
sess.emit_warning(errors::CopyWorkProductToCache {
|
||||
sess.dcx().emit_warning(errors::CopyWorkProductToCache {
|
||||
from: path,
|
||||
to: &path_in_incr_dir,
|
||||
err,
|
||||
|
@ -50,7 +50,7 @@ pub(crate) fn delete_workproduct_files(sess: &Session, work_product: &WorkProduc
|
|||
for (_, path) in work_product.saved_files.items().into_sorted_stable_ord() {
|
||||
let path = in_incr_comp_dir_sess(sess, path);
|
||||
if let Err(err) = std_fs::remove_file(&path) {
|
||||
sess.emit_warning(errors::DeleteWorkProduct { path: &path, err });
|
||||
sess.dcx().emit_warning(errors::DeleteWorkProduct { path: &path, err });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue