Skip to content

Commit bbed968

Browse files
Rollup merge of rust-lang#100754 - davidtwco:translation-incremental, r=compiler-errors
incremental: migrate diagnostics - Apply the diagnostic migration lints to more functions on `Session`, namely: `span_warn`, `span_warn_with_code`, `warn` `note_without_error`, `span_note_without_error`, `struct_note_without_error`. - Add impls of `IntoDiagnosticArg` for `std::io::Error`, `std::path::Path` and `std::path::PathBuf`. - Migrate the `rustc_incremental` crate's diagnostics to translatable diagnostic structs. r? ```@compiler-errors``` cc rust-lang#100717
2 parents 2910abe + 3becaaf commit bbed968

File tree

14 files changed

+611
-253
lines changed

14 files changed

+611
-253
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
incremental_unrecognized_depnode = unrecognized `DepNode` variant: {$name}
2+
3+
incremental_missing_depnode = missing `DepNode` variant
4+
5+
incremental_missing_if_this_changed = no `#[rustc_if_this_changed]` annotation detected
6+
7+
incremental_no_path = no path from `{$source}` to `{$target}`
8+
9+
incremental_ok = OK
10+
11+
incremental_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
12+
13+
incremental_missing_query_depgraph = found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
14+
15+
incremental_malformed_cgu_name =
16+
found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case).
17+
18+
incremental_no_module_named = no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
19+
20+
incremental_field_associated_value_expected = associated value expected for `{$name}`
21+
22+
incremental_no_field = no field `{$name}`
23+
24+
incremental_assertion_auto = `except` specified DepNodes that can not be affected for \"{$name}\": \"{$e}\"
25+
26+
incremental_undefined_clean_dirty_assertions_item = clean/dirty auto-assertions not yet defined for Node::Item.node={$kind}
27+
28+
incremental_undefined_clean_dirty_assertions = clean/dirty auto-assertions not yet defined for {$kind}
29+
30+
incremental_repeated_depnode_label = dep-node label `{$label}` is repeated
31+
32+
incremental_unrecognized_depnode_label = dep-node label `{$label}` not recognized
33+
34+
incremental_not_dirty = `{$dep_node_str}` should be dirty but is not
35+
36+
incremental_not_clean = `{$dep_node_str}` should be clean but is not
37+
38+
incremental_not_loaded = `{$dep_node_str}` should have been loaded from disk but it was not
39+
40+
incremental_unknown_item = unknown item `{$name}`
41+
42+
incremental_no_cfg = no cfg attribute
43+
44+
incremental_associated_value_expected_for = associated value expected for `{$ident}`
45+
46+
incremental_associated_value_expected = expected an associated value
47+
48+
incremental_unchecked_clean = found unchecked `#[rustc_clean]` attribute
49+
50+
incremental_delete_old = unable to delete old {$name} at `{$path}`: {$err}
51+
52+
incremental_create_new = failed to create {$name} at `{$path}`: {$err}
53+
54+
incremental_write_new = failed to write {$name} to `{$path}`: {$err}
55+
56+
incremental_canonicalize_path = incremental compilation: error canonicalizing path `{$path}`: {$err}
57+
58+
incremental_create_incr_comp_dir = could not create incremental compilation {$tag} directory `{$path}`: {$err}
59+
60+
incremental_create_lock = incremental compilation: could not create session directory lock file: {$lock_err}
61+
.lock_unsupported = the filesystem for the incremental path at {$session_dir} does not appear to support locking, consider changing the incremental path to a filesystem that supports locking or disable incremental compilation
62+
.cargo_help_1 = incremental compilation can be disabled by setting the environment variable CARGO_INCREMENTAL=0 (see https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
63+
.cargo_help_2 = the entire build directory can be changed to a different filesystem by setting the environment variable CARGO_TARGET_DIR to a different path (see https://doc.rust-lang.org/cargo/reference/config.html#buildtarget-dir)
64+
65+
incremental_delete_lock = error deleting lock file for incremental compilation session directory `{$path}`: {$err}
66+
67+
incremental_hard_link_failed =
68+
hard linking files in the incremental compilation cache failed. copying files instead. consider moving the cache directory to a file system which supports hard linking in session dir `{$path}`
69+
70+
incremental_delete_partial = failed to delete partly initialized session dir `{$path}`: {$err}
71+
72+
incremental_delete_full = error deleting incremental compilation session directory `{$path}`: {$err}
73+
74+
incremental_finalize = error finalizing incremental compilation session directory `{$path}`: {$err}
75+
76+
incremental_invalid_gc_failed =
77+
failed to garbage collect invalid incremental compilation session directory `{$path}`: {$err}
78+
79+
incremental_finalized_gc_failed =
80+
failed to garbage collect finalized incremental compilation session directory `{$path}`: {$err}
81+
82+
incremental_session_gc_failed =
83+
failed to garbage collect incremental compilation session directory `{$path}`: {$err}
84+
85+
incremental_assert_not_loaded =
86+
we asserted that the incremental cache should not be loaded, but it was loaded
87+
88+
incremental_assert_loaded =
89+
we asserted that an existing incremental cache directory should be successfully loaded, but it was not
90+
91+
incremental_delete_incompatible =
92+
failed to delete invalidated or incompatible incremental compilation session directory contents `{$path}`: {$err}
93+
94+
incremental_load_dep_graph = could not load dep-graph from `{$path}`: {$err}
95+
96+
incremental_decode_incr_cache = could not decode incremental cache: {$err}
97+
98+
incremental_write_dep_graph = failed to write dependency graph to `{$path}`: {$err}
99+
100+
incremental_move_dep_graph = failed to move dependency graph from `{$from}` to `{$to}`: {$err}
101+
102+
incremental_create_dep_graph = failed to create dependency graph at `{$path}`: {$err}
103+
104+
incremental_copy_workproduct_to_cache = error copying object file `{$from}` to incremental directory as `{$to}`: {$err}
105+
106+
incremental_delete_workproduct = file-system error deleting outdated file `{$path}`: {$err}

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fluent_messages! {
4040
const_eval => "../locales/en-US/const_eval.ftl",
4141
driver => "../locales/en-US/driver.ftl",
4242
expand => "../locales/en-US/expand.ftl",
43+
incremental => "../locales/en-US/incremental.ftl",
4344
interface => "../locales/en-US/interface.ftl",
4445
lint => "../locales/en-US/lint.ftl",
4546
parser => "../locales/en-US/parser.ftl",

compiler/rustc_incremental/src/assert_dep_graph.rs

+17-23
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
//! fn baz() { foo(); }
3434
//! ```
3535
36+
use crate::errors;
3637
use rustc_ast as ast;
3738
use rustc_data_structures::fx::FxHashSet;
3839
use rustc_data_structures::graph::implementation::{Direction, NodeIndex, INCOMING, OUTGOING};
@@ -133,12 +134,10 @@ impl<'tcx> IfThisChanged<'tcx> {
133134
Some(n) => {
134135
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
135136
Ok(n) => n,
136-
Err(()) => {
137-
self.tcx.sess.span_fatal(
138-
attr.span,
139-
&format!("unrecognized DepNode variant {:?}", n),
140-
);
141-
}
137+
Err(()) => self.tcx.sess.emit_fatal(errors::UnrecognizedDepNode {
138+
span: attr.span,
139+
name: n,
140+
}),
142141
}
143142
}
144143
};
@@ -149,16 +148,14 @@ impl<'tcx> IfThisChanged<'tcx> {
149148
Some(n) => {
150149
match DepNode::from_label_string(self.tcx, n.as_str(), def_path_hash) {
151150
Ok(n) => n,
152-
Err(()) => {
153-
self.tcx.sess.span_fatal(
154-
attr.span,
155-
&format!("unrecognized DepNode variant {:?}", n),
156-
);
157-
}
151+
Err(()) => self.tcx.sess.emit_fatal(errors::UnrecognizedDepNode {
152+
span: attr.span,
153+
name: n,
154+
}),
158155
}
159156
}
160157
None => {
161-
self.tcx.sess.span_fatal(attr.span, "missing DepNode variant");
158+
self.tcx.sess.emit_fatal(errors::MissingDepNode { span: attr.span });
162159
}
163160
};
164161
self.then_this_would_need.push((
@@ -204,7 +201,7 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
204201
// Return early here so as not to construct the query, which is not cheap.
205202
if if_this_changed.is_empty() {
206203
for &(target_span, _, _, _) in then_this_would_need {
207-
tcx.sess.span_err(target_span, "no `#[rustc_if_this_changed]` annotation detected");
204+
tcx.sess.emit_err(errors::MissingIfThisChanged { span: target_span });
208205
}
209206
return;
210207
}
@@ -213,16 +210,13 @@ fn check_paths<'tcx>(tcx: TyCtxt<'tcx>, if_this_changed: &Sources, then_this_wou
213210
let dependents = query.transitive_predecessors(source_dep_node);
214211
for &(target_span, ref target_pass, _, ref target_dep_node) in then_this_would_need {
215212
if !dependents.contains(&target_dep_node) {
216-
tcx.sess.span_err(
217-
target_span,
218-
&format!(
219-
"no path from `{}` to `{}`",
220-
tcx.def_path_str(source_def_id),
221-
target_pass
222-
),
223-
);
213+
tcx.sess.emit_err(errors::NoPath {
214+
span: target_span,
215+
source: tcx.def_path_str(source_def_id),
216+
target: *target_pass,
217+
});
224218
} else {
225-
tcx.sess.span_err(target_span, "OK");
219+
tcx.sess.emit_err(errors::Ok { span: target_span });
226220
}
227221
}
228222
}

compiler/rustc_incremental/src/assert_module_sources.rs

+21-29
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
//! allows for doing a more fine-grained check to see if pre- or post-lto data
2323
//! was re-used.
2424
25+
use crate::errors;
2526
use rustc_ast as ast;
2627
use rustc_data_structures::fx::FxHashSet;
2728
use rustc_hir::def_id::LOCAL_CRATE;
@@ -66,21 +67,17 @@ impl<'tcx> AssertModuleSource<'tcx> {
6667
sym::post_dash_lto => (CguReuse::PostLto, ComparisonKind::Exact),
6768
sym::any => (CguReuse::PreLto, ComparisonKind::AtLeast),
6869
other => {
69-
self.tcx.sess.span_fatal(
70-
attr.span,
71-
&format!("unknown cgu-reuse-kind `{}` specified", other),
72-
);
70+
self.tcx
71+
.sess
72+
.emit_fatal(errors::UnknownReuseKind { span: attr.span, kind: other });
7373
}
7474
}
7575
} else {
7676
return;
7777
};
7878

7979
if !self.tcx.sess.opts.unstable_opts.query_dep_graph {
80-
self.tcx.sess.span_fatal(
81-
attr.span,
82-
"found CGU-reuse attribute but `-Zquery-dep-graph` was not specified",
83-
);
80+
self.tcx.sess.emit_fatal(errors::MissingQueryDepGraph { span: attr.span });
8481
}
8582

8683
if !self.check_config(attr) {
@@ -92,13 +89,11 @@ impl<'tcx> AssertModuleSource<'tcx> {
9289
let crate_name = self.tcx.crate_name(LOCAL_CRATE).to_string();
9390

9491
if !user_path.starts_with(&crate_name) {
95-
let msg = format!(
96-
"Found malformed codegen unit name `{}`. \
97-
Codegen units names must always start with the name of the \
98-
crate (`{}` in this case).",
99-
user_path, crate_name
100-
);
101-
self.tcx.sess.span_fatal(attr.span, &msg);
92+
self.tcx.sess.emit_fatal(errors::MalformedCguName {
93+
span: attr.span,
94+
user_path,
95+
crate_name,
96+
});
10297
}
10398

10499
// Split of the "special suffix" if there is one.
@@ -125,15 +120,12 @@ impl<'tcx> AssertModuleSource<'tcx> {
125120
let mut cgu_names: Vec<&str> =
126121
self.available_cgus.iter().map(|cgu| cgu.as_str()).collect();
127122
cgu_names.sort();
128-
self.tcx.sess.span_err(
129-
attr.span,
130-
&format!(
131-
"no module named `{}` (mangled: {}). Available modules: {}",
132-
user_path,
133-
cgu_name,
134-
cgu_names.join(", ")
135-
),
136-
);
123+
self.tcx.sess.emit_err(errors::NoModuleNamed {
124+
span: attr.span,
125+
user_path,
126+
cgu_name,
127+
cgu_names: cgu_names.join(", "),
128+
});
137129
}
138130

139131
self.tcx.sess.cgu_reuse_tracker.set_expectation(
@@ -151,15 +143,15 @@ impl<'tcx> AssertModuleSource<'tcx> {
151143
if let Some(value) = item.value_str() {
152144
return value;
153145
} else {
154-
self.tcx.sess.span_fatal(
155-
item.span(),
156-
&format!("associated value expected for `{}`", name),
157-
);
146+
self.tcx.sess.emit_fatal(errors::FieldAssociatedValueExpected {
147+
span: item.span(),
148+
name,
149+
});
158150
}
159151
}
160152
}
161153

162-
self.tcx.sess.span_fatal(attr.span, &format!("no field `{}`", name));
154+
self.tcx.sess.emit_fatal(errors::NoField { span: attr.span, name });
163155
}
164156

165157
/// Scan for a `cfg="foo"` attribute and check whether we have a

0 commit comments

Comments
 (0)