Skip to content

Commit ec5150c

Browse files
Rollup merge of #157803 - GuillaumeGomez:rename-err-to-diag, r=JonathanBrouwer
Rename `errors.rs` file to `diagnostics.rs` (7/N) Follow-up of #157485. r? @JonathanBrouwer
2 parents 1cac475 + d0b019e commit ec5150c

16 files changed

Lines changed: 67 additions & 63 deletions

File tree

compiler/rustc_incremental/src/assert_dep_graph.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use rustc_middle::ty::TyCtxt;
5252
use rustc_span::{Span, Symbol, sym};
5353
use tracing::debug;
5454

55-
use crate::errors;
55+
use crate::diagnostics;
5656

5757
#[allow(missing_docs)]
5858
pub(crate) fn assert_dep_graph(tcx: TyCtxt<'_>) {
@@ -128,7 +128,7 @@ impl<'tcx> IfThisChanged<'tcx> {
128128
Err(()) => self
129129
.tcx
130130
.dcx()
131-
.emit_fatal(errors::UnrecognizedDepNode { span, name: n }),
131+
.emit_fatal(diagnostics::UnrecognizedDepNode { span, name: n }),
132132
}
133133
}
134134
};
@@ -139,9 +139,10 @@ impl<'tcx> IfThisChanged<'tcx> {
139139
let Ok(dep_node) =
140140
DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash)
141141
else {
142-
self.tcx
143-
.dcx()
144-
.emit_fatal(errors::UnrecognizedDepNode { span: n.span, name: n.name });
142+
self.tcx.dcx().emit_fatal(diagnostics::UnrecognizedDepNode {
143+
span: n.span,
144+
name: n.name,
145+
});
145146
};
146147
self.then_this_would_need.push((n.span, n.name, hir_id, dep_node));
147148
}
@@ -186,7 +187,7 @@ fn check_paths<'tcx>(
186187
) {
187188
if if_this_changed.is_empty() {
188189
for &(target_span, _, _, _) in then_this_would_need {
189-
tcx.dcx().emit_err(errors::MissingIfThisChanged { span: target_span });
190+
tcx.dcx().emit_err(diagnostics::MissingIfThisChanged { span: target_span });
190191
}
191192
return;
192193
}
@@ -195,13 +196,13 @@ fn check_paths<'tcx>(
195196
let dependents = query.transitive_predecessors(source_dep_node);
196197
for &(target_span, ref target_pass, _, ref target_dep_node) in then_this_would_need {
197198
if !dependents.contains(&target_dep_node) {
198-
tcx.dcx().emit_err(errors::NoPath {
199+
tcx.dcx().emit_err(diagnostics::NoPath {
199200
span: target_span,
200201
source: tcx.def_path_str(source_def_id),
201202
target: *target_pass,
202203
});
203204
} else {
204-
tcx.dcx().emit_err(errors::Ok { span: target_span });
205+
tcx.dcx().emit_err(diagnostics::Ok { span: target_span });
205206
}
206207
}
207208
}
File renamed without changes.

compiler/rustc_incremental/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// tidy-alphabetical-end
77

88
mod assert_dep_graph;
9-
mod errors;
9+
mod diagnostics;
1010
mod persist;
1111

1212
pub use persist::{

compiler/rustc_incremental/src/persist/clean.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc_middle::ty::TyCtxt;
3333
use rustc_span::{Span, Symbol};
3434
use tracing::debug;
3535

36-
use crate::errors;
36+
use crate::diagnostics;
3737

3838
// Base and Extra labels to build up the labels
3939

@@ -193,7 +193,7 @@ impl<'tcx> CleanVisitor<'tcx> {
193193
let loaded_from_disk = self.loaded_from_disk(attr);
194194
for e in except.items().into_sorted_stable_ord() {
195195
if !auto.remove(e) {
196-
self.tcx.dcx().emit_fatal(errors::AssertionAuto { span: attr.span, name, e });
196+
self.tcx.dcx().emit_fatal(diagnostics::AssertionAuto { span: attr.span, name, e });
197197
}
198198
}
199199
Assertion { clean: auto, dirty: except, loaded_from_disk }
@@ -267,7 +267,7 @@ impl<'tcx> CleanVisitor<'tcx> {
267267
// An implementation, eg `impl<A> Trait for Foo { .. }`
268268
HirItem::Impl { .. } => ("ItemKind::Impl", LABELS_IMPL),
269269

270-
_ => self.tcx.dcx().emit_fatal(errors::UndefinedCleanDirtyItem {
270+
_ => self.tcx.dcx().emit_fatal(diagnostics::UndefinedCleanDirtyItem {
271271
span,
272272
kind: format!("{:?}", item.kind),
273273
}),
@@ -286,7 +286,7 @@ impl<'tcx> CleanVisitor<'tcx> {
286286
_ => self
287287
.tcx
288288
.dcx()
289-
.emit_fatal(errors::UndefinedCleanDirty { span, kind: format!("{node:?}") }),
289+
.emit_fatal(diagnostics::UndefinedCleanDirty { span, kind: format!("{node:?}") }),
290290
};
291291
let labels =
292292
Labels::from_iter(labels.iter().flat_map(|s| s.iter().map(|l| (*l).to_string())));
@@ -301,13 +301,13 @@ impl<'tcx> CleanVisitor<'tcx> {
301301
if out.contains(label_str) {
302302
self.tcx
303303
.dcx()
304-
.emit_fatal(errors::RepeatedDepNodeLabel { span, label: label_str });
304+
.emit_fatal(diagnostics::RepeatedDepNodeLabel { span, label: label_str });
305305
}
306306
out.insert(label_str.to_string());
307307
} else {
308308
self.tcx
309309
.dcx()
310-
.emit_fatal(errors::UnrecognizedDepNodeLabel { span, label: label_str });
310+
.emit_fatal(diagnostics::UnrecognizedDepNodeLabel { span, label: label_str });
311311
}
312312
}
313313
out
@@ -328,7 +328,7 @@ impl<'tcx> CleanVisitor<'tcx> {
328328
let dep_node_str = self.dep_node_str(&dep_node);
329329
self.tcx
330330
.dcx()
331-
.emit_err(errors::NotDirty { span: item_span, dep_node_str: &dep_node_str });
331+
.emit_err(diagnostics::NotDirty { span: item_span, dep_node_str: &dep_node_str });
332332
}
333333
}
334334

@@ -339,7 +339,7 @@ impl<'tcx> CleanVisitor<'tcx> {
339339
let dep_node_str = self.dep_node_str(&dep_node);
340340
self.tcx
341341
.dcx()
342-
.emit_err(errors::NotClean { span: item_span, dep_node_str: &dep_node_str });
342+
.emit_err(diagnostics::NotClean { span: item_span, dep_node_str: &dep_node_str });
343343
}
344344
}
345345

@@ -369,7 +369,7 @@ impl<'tcx> CleanVisitor<'tcx> {
369369
Ok(dep_node) => {
370370
if !self.tcx.dep_graph.debug_was_loaded_from_disk(dep_node) {
371371
let dep_node_str = self.dep_node_str(&dep_node);
372-
self.tcx.dcx().emit_err(errors::NotLoaded {
372+
self.tcx.dcx().emit_err(diagnostics::NotLoaded {
373373
span: item_span,
374374
dep_node_str: &dep_node_str,
375375
});
@@ -379,7 +379,7 @@ impl<'tcx> CleanVisitor<'tcx> {
379379
Err(()) => {
380380
let dep_kind = dep_kind_from_label(label);
381381
if !self.tcx.dep_graph.debug_dep_kind_was_loaded_from_disk(dep_kind) {
382-
self.tcx.dcx().emit_err(errors::NotLoaded {
382+
self.tcx.dcx().emit_err(diagnostics::NotLoaded {
383383
span: item_span,
384384
dep_node_str: &label,
385385
});
@@ -407,7 +407,7 @@ impl<'tcx> FindAllAttrs<'tcx> {
407407
fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet<Span>) {
408408
for attr in &self.found_attrs {
409409
if !checked_attrs.contains(&attr.span) {
410-
self.tcx.dcx().emit_err(errors::UncheckedClean { span: attr.span });
410+
self.tcx.dcx().emit_err(diagnostics::UncheckedClean { span: attr.span });
411411
checked_attrs.insert(attr.span);
412412
}
413413
}

compiler/rustc_incremental/src/persist/file_format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
2020
use rustc_session::Session;
2121
use tracing::debug;
2222

23-
use crate::errors;
23+
use crate::diagnostics;
2424

2525
/// The first few bytes of files generated by incremental compilation.
2626
const FILE_MAGIC: &[u8] = b"RSIC";
@@ -57,12 +57,12 @@ where
5757
debug!("save: remove old file");
5858
}
5959
Err(err) if err.kind() == io::ErrorKind::NotFound => (),
60-
Err(err) => sess.dcx().emit_fatal(errors::DeleteOld { name, path: path_buf, err }),
60+
Err(err) => sess.dcx().emit_fatal(diagnostics::DeleteOld { name, path: path_buf, err }),
6161
}
6262

6363
let mut encoder = match FileEncoder::new(&path_buf) {
6464
Ok(encoder) => encoder,
65-
Err(err) => sess.dcx().emit_fatal(errors::CreateNew { name, path: path_buf, err }),
65+
Err(err) => sess.dcx().emit_fatal(diagnostics::CreateNew { name, path: path_buf, err }),
6666
};
6767

6868
write_file_header(&mut encoder, sess);
@@ -76,7 +76,7 @@ where
7676
);
7777
debug!("save: data written to disk successfully");
7878
}
79-
Err((path, err)) => sess.dcx().emit_fatal(errors::WriteNew { name, path, err }),
79+
Err((path, err)) => sess.dcx().emit_fatal(diagnostics::WriteNew { name, path, err }),
8080
}
8181
}
8282

compiler/rustc_incremental/src/persist/fs.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ use rustc_session::{Session, StableCrateId};
120120
use rustc_span::Symbol;
121121
use tracing::debug;
122122

123-
use crate::errors;
123+
use crate::diagnostics;
124124

125125
#[cfg(test)]
126126
mod tests;
@@ -233,7 +233,7 @@ pub(crate) fn prepare_session_directory(
233233
let crate_dir = match try_canonicalize(&crate_dir) {
234234
Ok(v) => v,
235235
Err(err) => {
236-
sess.dcx().emit_fatal(errors::CanonicalizePath { path: crate_dir, err });
236+
sess.dcx().emit_fatal(diagnostics::CanonicalizePath { path: crate_dir, err });
237237
}
238238
};
239239

@@ -276,7 +276,7 @@ pub(crate) fn prepare_session_directory(
276276
debug!("successfully copied data from: {}", source_directory.display());
277277

278278
if !allows_links {
279-
sess.dcx().emit_warn(errors::HardLinkFailed { path: &session_dir });
279+
sess.dcx().emit_warn(diagnostics::HardLinkFailed { path: &session_dir });
280280
}
281281

282282
sess.init_incr_comp_session(session_dir, directory_lock);
@@ -291,7 +291,7 @@ pub(crate) fn prepare_session_directory(
291291
// Try to remove the session directory we just allocated. We don't
292292
// know if there's any garbage in it from the failed copy action.
293293
if let Err(err) = std_fs::remove_dir_all(&session_dir) {
294-
sess.dcx().emit_warn(errors::DeletePartial { path: &session_dir, err });
294+
sess.dcx().emit_warn(diagnostics::DeletePartial { path: &session_dir, err });
295295
}
296296

297297
delete_session_dir_lock_file(sess, &lock_file_path);
@@ -325,7 +325,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
325325
);
326326

327327
if let Err(err) = std_fs::remove_dir_all(&*incr_comp_session_dir) {
328-
sess.dcx().emit_warn(errors::DeleteFull { path: &incr_comp_session_dir, err });
328+
sess.dcx().emit_warn(diagnostics::DeleteFull { path: &incr_comp_session_dir, err });
329329
}
330330

331331
let lock_file_path = lock_file_path(&*incr_comp_session_dir);
@@ -364,7 +364,7 @@ pub fn finalize_session_directory(sess: &Session, svh: Option<Svh>) {
364364
}
365365
Err(e) => {
366366
// Warn about the error. However, no need to abort compilation now.
367-
sess.dcx().emit_note(errors::Finalize { path: &incr_comp_session_dir, err: e });
367+
sess.dcx().emit_note(diagnostics::Finalize { path: &incr_comp_session_dir, err: e });
368368

369369
debug!("finalize_session_directory() - error, marking as invalid");
370370
// Drop the file lock, so we can garage collect
@@ -464,7 +464,9 @@ fn create_dir(sess: &Session, path: &Path, dir_tag: &str) {
464464
Ok(()) => {
465465
debug!("{} directory created successfully", dir_tag);
466466
}
467-
Err(err) => sess.dcx().emit_fatal(errors::CreateIncrCompDir { tag: dir_tag, path, err }),
467+
Err(err) => {
468+
sess.dcx().emit_fatal(diagnostics::CreateIncrCompDir { tag: dir_tag, path, err })
469+
}
468470
}
469471
}
470472

@@ -483,7 +485,7 @@ fn lock_directory(sess: &Session, session_dir: &Path) -> (flock::Lock, PathBuf)
483485
Ok(lock) => (lock, lock_file_path),
484486
Err(lock_err) => {
485487
let is_unsupported_lock = flock::Lock::error_unsupported(&lock_err);
486-
sess.dcx().emit_fatal(errors::CreateLock {
488+
sess.dcx().emit_fatal(diagnostics::CreateLock {
487489
lock_err,
488490
session_dir,
489491
is_unsupported_lock,
@@ -495,7 +497,7 @@ fn lock_directory(sess: &Session, session_dir: &Path) -> (flock::Lock, PathBuf)
495497

496498
fn delete_session_dir_lock_file(sess: &Session, lock_file_path: &Path) {
497499
if let Err(err) = safe_remove_file(lock_file_path) {
498-
sess.dcx().emit_warn(errors::DeleteLock { path: lock_file_path, err });
500+
sess.dcx().emit_warn(diagnostics::DeleteLock { path: lock_file_path, err });
499501
}
500502
}
501503

@@ -708,7 +710,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
708710
if !lock_file_to_session_dir.items().any(|(_, dir)| *dir == directory_name) {
709711
let path = crate_directory.join(directory_name);
710712
if let Err(err) = std_fs::remove_dir_all(&path) {
711-
sess.dcx().emit_warn(errors::InvalidGcFailed { path: &path, err });
713+
sess.dcx().emit_warn(diagnostics::InvalidGcFailed { path: &path, err });
712714
}
713715
}
714716
}
@@ -840,7 +842,7 @@ pub(crate) fn garbage_collect_session_directories(sess: &Session) -> io::Result<
840842
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
841843

842844
if let Err(err) = std_fs::remove_dir_all(&path) {
843-
sess.dcx().emit_warn(errors::FinalizedGcFailed { path: &path, err });
845+
sess.dcx().emit_warn(diagnostics::FinalizedGcFailed { path: &path, err });
844846
} else {
845847
delete_session_dir_lock_file(sess, &lock_file_path(&path));
846848
}
@@ -858,7 +860,7 @@ fn delete_old(sess: &Session, path: &Path) {
858860
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
859861

860862
if let Err(err) = std_fs::remove_dir_all(path) {
861-
sess.dcx().emit_warn(errors::SessionGcFailed { path, err });
863+
sess.dcx().emit_warn(diagnostics::SessionGcFailed { path, err });
862864
} else {
863865
delete_session_dir_lock_file(sess, &lock_file_path(path));
864866
}

compiler/rustc_incremental/src/persist/load.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use tracing::{debug, warn};
1818
use super::data::*;
1919
use super::fs::*;
2020
use super::{file_format, work_product};
21-
use crate::errors;
21+
use crate::diagnostics;
2222
use crate::persist::file_format::{OpenFile, OpenFileError};
2323

2424
#[derive(Debug)]
@@ -60,7 +60,7 @@ fn load_dep_graph(sess: &Session) -> LoadResult {
6060
{
6161
// Decode the list of work_products
6262
let Ok(mut work_product_decoder) = MemDecoder::new(&mmap[..], start_pos) else {
63-
sess.dcx().emit_warn(errors::CorruptFile { path: &work_products_path });
63+
sess.dcx().emit_warn(diagnostics::CorruptFile { path: &work_products_path });
6464
return LoadResult::DataOutOfDate;
6565
};
6666
let work_products: Vec<SerializedWorkProduct> =
@@ -93,7 +93,7 @@ fn load_dep_graph(sess: &Session) -> LoadResult {
9393
Err(OpenFileError::IoError { err }) => LoadResult::IoError { path: path.to_owned(), err },
9494
Ok(OpenFile { mmap, start_pos }) => {
9595
let Ok(mut decoder) = MemDecoder::new(&mmap, start_pos) else {
96-
sess.dcx().emit_warn(errors::CorruptFile { path: &path });
96+
sess.dcx().emit_warn(diagnostics::CorruptFile { path: &path });
9797
return LoadResult::DataOutOfDate;
9898
};
9999
let prev_commandline_args_hash = Hash64::decode(&mut decoder);
@@ -135,7 +135,7 @@ pub fn load_query_result_cache(sess: &Session) -> Option<OnDiskCache> {
135135
match file_format::open_incremental_file(sess, &path) {
136136
Ok(OpenFile { mmap, start_pos }) => {
137137
let cache = OnDiskCache::new(sess, mmap, start_pos).unwrap_or_else(|()| {
138-
sess.dcx().emit_warn(errors::CorruptFile { path: &path });
138+
sess.dcx().emit_warn(diagnostics::CorruptFile { path: &path });
139139
OnDiskCache::new_empty()
140140
});
141141
Some(cache)
@@ -161,12 +161,12 @@ fn maybe_assert_incr_state(sess: &Session, load_result: &LoadResult) {
161161
match assertion {
162162
IncrementalStateAssertion::Loaded => {
163163
if !loaded {
164-
sess.dcx().emit_fatal(errors::AssertLoaded);
164+
sess.dcx().emit_fatal(diagnostics::AssertLoaded);
165165
}
166166
}
167167
IncrementalStateAssertion::NotLoaded => {
168168
if loaded {
169-
sess.dcx().emit_fatal(errors::AssertNotLoaded)
169+
sess.dcx().emit_fatal(diagnostics::AssertNotLoaded)
170170
}
171171
}
172172
}
@@ -205,12 +205,13 @@ pub fn setup_dep_graph(
205205

206206
let (prev_graph, prev_work_products) = match load_result {
207207
LoadResult::IoError { path, err } => {
208-
sess.dcx().emit_warn(errors::LoadDepGraph { path, err });
208+
sess.dcx().emit_warn(diagnostics::LoadDepGraph { path, err });
209209
Default::default()
210210
}
211211
LoadResult::DataOutOfDate => {
212212
if let Err(err) = delete_all_session_dir_contents(sess) {
213-
sess.dcx().emit_err(errors::DeleteIncompatible { path: dep_graph_path(sess), err });
213+
sess.dcx()
214+
.emit_err(diagnostics::DeleteIncompatible { path: dep_graph_path(sess), err });
214215
}
215216
Default::default()
216217
}
@@ -223,7 +224,7 @@ pub fn setup_dep_graph(
223224
let mut encoder = FileEncoder::new(&path_buf).unwrap_or_else(|err| {
224225
// We're in incremental mode but couldn't set up streaming output of the dep graph.
225226
// Exit immediately instead of continuing in an inconsistent and untested state.
226-
sess.dcx().emit_fatal(errors::CreateDepGraph { path: &path_buf, err })
227+
sess.dcx().emit_fatal(diagnostics::CreateDepGraph { path: &path_buf, err })
227228
});
228229

229230
file_format::write_file_header(&mut encoder, sess);

compiler/rustc_incremental/src/persist/save.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use super::data::*;
1313
use super::fs::*;
1414
use super::{clean, file_format, work_product};
1515
use crate::assert_dep_graph::assert_dep_graph;
16-
use crate::errors;
16+
use crate::diagnostics;
1717

1818
/// Saves and writes the [`DepGraph`] to the file system.
1919
///
@@ -45,7 +45,7 @@ pub(crate) fn save_dep_graph(tcx: TyCtxt<'_>) {
4545
move || {
4646
sess.time("incr_comp_persist_dep_graph", || {
4747
if let Err(err) = fs::rename(&staging_dep_graph_path, &dep_graph_path) {
48-
sess.dcx().emit_err(errors::MoveDepGraph {
48+
sess.dcx().emit_err(diagnostics::MoveDepGraph {
4949
from: &staging_dep_graph_path,
5050
to: &dep_graph_path,
5151
err,

0 commit comments

Comments
 (0)