Skip to content

Commit 4c05e77

Browse files
authored
Rollup merge of rust-lang#100928 - CleanCut:rustc_metadata_diagnostics, r=davidtwco
Migrate rustc_metadata to SessionDiagnostics Migrate rustc_metadata to SessionDiagnostics. Part of rust-lang#100717
2 parents 85d68d6 + 30adfd6 commit 4c05e77

File tree

13 files changed

+1195
-453
lines changed

13 files changed

+1195
-453
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,7 @@ dependencies = [
34893489
"rustc_macros",
34903490
"rustc_serialize",
34913491
"rustc_span",
3492+
"rustc_target",
34923493
"serde",
34933494
"serde_json",
34943495
"termcolor",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
metadata_rlib_required =
2+
crate `{$crate_name}` required to be available in rlib format, but was not found in this form
3+
4+
metadata_lib_required =
5+
crate `{$crate_name}` required to be available in {$kind} format, but was not found in this form
6+
7+
metadata_crate_dep_multiple =
8+
cannot satisfy dependencies so `{$crate_name}` only shows up once
9+
.help = having upstream crates all available in one format will likely make this go away
10+
11+
metadata_two_panic_runtimes =
12+
cannot link together two panic runtimes: {$prev_name} and {$cur_name}
13+
14+
metadata_bad_panic_strategy =
15+
the linked panic runtime `{$runtime}` is not compiled with this crate's panic strategy `{$strategy}`
16+
17+
metadata_required_panic_strategy =
18+
the crate `{$crate_name}` requires panic strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`
19+
20+
metadata_incompatible_panic_in_drop_strategy =
21+
the crate `{$crate_name}` is compiled with the panic-in-drop strategy `{$found_strategy}` which is incompatible with this crate's strategy of `{$desired_strategy}`
22+
23+
metadata_multiple_names_in_link =
24+
multiple `name` arguments in a single `#[link]` attribute
25+
26+
metadata_multiple_kinds_in_link =
27+
multiple `kind` arguments in a single `#[link]` attribute
28+
29+
metadata_link_name_form =
30+
link name must be of the form `name = "string"`
31+
32+
metadata_link_kind_form =
33+
link kind must be of the form `kind = "string"`
34+
35+
metadata_link_modifiers_form =
36+
link modifiers must be of the form `modifiers = "string"`
37+
38+
metadata_link_cfg_form =
39+
link cfg must be of the form `cfg(/* predicate */)`
40+
41+
metadata_wasm_import_form =
42+
wasm import module must be of the form `wasm_import_module = "string"`
43+
44+
metadata_empty_link_name =
45+
link name must not be empty
46+
.label = empty link name
47+
48+
metadata_link_framework_apple =
49+
link kind `framework` is only supported on Apple targets
50+
51+
metadata_framework_only_windows =
52+
link kind `raw-dylib` is only supported on Windows targets
53+
54+
metadata_unknown_link_kind =
55+
unknown link kind `{$kind}`, expected one of: static, dylib, framework, raw-dylib
56+
.label = unknown link kind
57+
58+
metadata_multiple_link_modifiers =
59+
multiple `modifiers` arguments in a single `#[link]` attribute
60+
61+
metadata_multiple_cfgs =
62+
multiple `cfg` arguments in a single `#[link]` attribute
63+
64+
metadata_link_cfg_single_predicate =
65+
link cfg must have a single predicate argument
66+
67+
metadata_multiple_wasm_import =
68+
multiple `wasm_import_module` arguments in a single `#[link]` attribute
69+
70+
metadata_unexpected_link_arg =
71+
unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type
72+
73+
metadata_invalid_link_modifier =
74+
invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed
75+
76+
metadata_multiple_modifiers =
77+
multiple `{$modifier}` modifiers in a single `modifiers` argument
78+
79+
metadata_bundle_needs_static =
80+
linking modifier `bundle` is only compatible with `static` linking kind
81+
82+
metadata_whole_archive_needs_static =
83+
linking modifier `whole-archive` is only compatible with `static` linking kind
84+
85+
metadata_as_needed_compatibility =
86+
linking modifier `as-needed` is only compatible with `dylib` and `framework` linking kinds
87+
88+
metadata_unknown_link_modifier =
89+
unknown linking modifier `{$modifier}`, expected one of: bundle, verbatim, whole-archive, as-needed
90+
91+
metadata_incompatible_wasm_link =
92+
`wasm_import_module` is incompatible with other arguments in `#[link]` attributes
93+
94+
metadata_link_requires_name =
95+
`#[link]` attribute requires a `name = "string"` argument
96+
.label = missing `name` argument
97+
98+
metadata_raw_dylib_no_nul =
99+
link name must not contain NUL characters if link kind is `raw-dylib`
100+
101+
metadata_link_ordinal_raw_dylib =
102+
`#[link_ordinal]` is only supported if link kind is `raw-dylib`
103+
104+
metadata_lib_framework_apple =
105+
library kind `framework` is only supported on Apple targets
106+
107+
metadata_empty_renaming_target =
108+
an empty renaming target was specified for library `{$lib_name}`
109+
110+
metadata_renaming_no_link =
111+
renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library
112+
113+
metadata_multiple_renamings =
114+
multiple renamings were specified for library `{$lib_name}`
115+
116+
metadata_no_link_mod_override =
117+
overriding linking modifiers from command line is not supported
118+
119+
metadata_unsupported_abi_i686 =
120+
ABI not supported by `#[link(kind = "raw-dylib")]` on i686
121+
122+
metadata_unsupported_abi =
123+
ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
124+
125+
metadata_fail_create_file_encoder =
126+
failed to create file encoder: {$err}
127+
128+
metadata_fail_seek_file =
129+
failed to seek the file: {$err}
130+
131+
metadata_fail_write_file =
132+
failed to write to the file: {$err}
133+
134+
metadata_crate_not_panic_runtime =
135+
the crate `{$crate_name}` is not a panic runtime
136+
137+
metadata_no_panic_strategy =
138+
the crate `{$crate_name}` does not have the panic strategy `{$strategy}`
139+
140+
metadata_profiler_builtins_needs_core =
141+
`profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]`
142+
143+
metadata_not_profiler_runtime =
144+
the crate `{$crate_name}` is not a profiler runtime
145+
146+
metadata_no_multiple_global_alloc =
147+
cannot define multiple global allocators
148+
.label = cannot define a new global allocator
149+
150+
metadata_prev_global_alloc =
151+
previous global allocator defined here
152+
153+
metadata_conflicting_global_alloc =
154+
the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name}
155+
156+
metadata_global_alloc_required =
157+
no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait
158+
159+
metadata_no_transitive_needs_dep =
160+
the crate `{$crate_name}` cannot depend on a crate that needs {$needs_crate_name}, but it depends on `{$deps_crate_name}`
161+
162+
metadata_failed_write_error =
163+
failed to write {$filename}: {$err}
164+
165+
metadata_failed_create_tempdir =
166+
couldn't create a temp dir: {$err}
167+
168+
metadata_failed_create_file =
169+
failed to create the file {$filename}: {$err}
170+
171+
metadata_failed_create_encoded_metadata =
172+
failed to create encoded metadata from file: {$err}
173+
174+
metadata_non_ascii_name =
175+
cannot load a crate with a non-ascii name `{$crate_name}`
176+
177+
metadata_extern_location_not_exist =
178+
extern location for {$crate_name} does not exist: {$location}
179+
180+
metadata_extern_location_not_file =
181+
extern location for {$crate_name} is not a file: {$location}
182+
183+
metadata_multiple_candidates =
184+
multiple {$flavor} candidates for `{$crate_name}` found
185+
186+
metadata_multiple_matching_crates =
187+
multiple matching crates for `{$crate_name}`
188+
.note = candidates:{$candidates}
189+
190+
metadata_symbol_conflicts_current =
191+
the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments. This will result in symbol conflicts between the two.
192+
193+
metadata_symbol_conflicts_others =
194+
found two different crates with name `{$crate_name}` that are not distinguished by differing `-C metadata`. This will result in symbol conflicts between the two.
195+
196+
metadata_stable_crate_id_collision =
197+
found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values.
198+
199+
metadata_dl_error =
200+
{$err}
201+
202+
metadata_newer_crate_version =
203+
found possibly newer version of crate `{$crate_name}`{$add_info}
204+
.note = perhaps that crate needs to be recompiled?
205+
206+
metadata_found_crate_versions =
207+
the following crate versions were found:{$found_crates}
208+
209+
metadata_no_crate_with_triple =
210+
couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info}
211+
212+
metadata_found_staticlib =
213+
found staticlib `{$crate_name}` instead of rlib or dylib{$add_info}
214+
.help = please recompile that crate using --crate-type lib
215+
216+
metadata_incompatible_rustc =
217+
found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info}
218+
.help = please recompile that crate using this compiler ({$rustc_version}) (consider running `cargo clean` first)
219+
220+
metadata_invalid_meta_files =
221+
found invalid metadata files for crate `{$crate_name}`{$add_info}
222+
223+
metadata_cannot_find_crate =
224+
can't find crate for `{$crate_name}`{$add_info}
225+
226+
metadata_no_dylib_plugin =
227+
plugin `{$crate_name}` only found in rlib format, but must be available in dylib format
228+
229+
metadata_target_not_installed =
230+
the `{$locator_triple}` target may not be installed
231+
232+
metadata_target_no_std_support =
233+
the `{$locator_triple}` target may not support the standard library
234+
235+
metadata_consider_downloading_target =
236+
consider downloading the target with `rustup target add {$locator_triple}`
237+
238+
metadata_std_required =
239+
`std` is required by `{$current_crate}` because it does not declare `#![no_std]`
240+
241+
metadata_consider_building_std =
242+
consider building the standard library from source with `cargo build -Zbuild-std`
243+
244+
metadata_compiler_missing_profiler =
245+
the compiler may have been built without the profiler runtime
246+
247+
metadata_install_missing_components =
248+
maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`
249+
250+
metadata_cant_find_crate =
251+
can't find crate
252+
253+
metadata_crate_location_unknown_type =
254+
extern location for {$crate_name} is of an unknown type: {$path}
255+
256+
metadata_lib_filename_form =
257+
file name should be lib*.rlib or {dll_prefix}*.{dll_suffix}
258+
259+
metadata_multiple_import_name_type =
260+
multiple `import_name_type` arguments in a single `#[link]` attribute
261+
262+
metadata_import_name_type_form =
263+
import name type must be of the form `import_name_type = "string"`
264+
265+
metadata_import_name_type_x86 =
266+
import name type is only supported on x86
267+
268+
metadata_unknown_import_name_type =
269+
unknown import name type `{$import_name_type}`, expected one of: decorated, noprefix, undecorated
270+
271+
metadata_import_name_type_raw =
272+
import name type can only be used with link kind `raw-dylib`

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ fluent_messages! {
4848
infer => "../locales/en-US/infer.ftl",
4949
lint => "../locales/en-US/lint.ftl",
5050
monomorphize => "../locales/en-US/monomorphize.ftl",
51+
metadata => "../locales/en-US/metadata.ftl",
5152
parser => "../locales/en-US/parser.ftl",
5253
passes => "../locales/en-US/passes.ftl",
5354
plugin_impl => "../locales/en-US/plugin_impl.ftl",

compiler/rustc_errors/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ rustc_macros = { path = "../rustc_macros" }
1515
rustc_data_structures = { path = "../rustc_data_structures" }
1616
rustc_hir = { path = "../rustc_hir" }
1717
rustc_lint_defs = { path = "../rustc_lint_defs" }
18+
rustc_target = { path = "../rustc_target" }
1819
unicode-width = "0.1.4"
1920
atty = "0.2"
2021
termcolor = "1.0"
2122
annotate-snippets = "0.9"
2223
termize = "0.1.1"
23-
serde = { version = "1.0.125", features = ["derive"] }
24+
serde = { version = "1.0.125", features = [ "derive" ] }
2425
serde_json = "1.0.59"
2526

2627
[target.'cfg(windows)'.dependencies]
27-
winapi = { version = "0.3", features = ["handleapi", "synchapi", "winbase"] }
28+
winapi = { version = "0.3", features = [ "handleapi", "synchapi", "winbase" ] }

compiler/rustc_errors/src/diagnostic.rs

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_lint_defs::{Applicability, LintExpectationId};
1010
use rustc_span::edition::LATEST_STABLE_EDITION;
1111
use rustc_span::symbol::{Ident, MacroRulesNormalizedIdent, Symbol};
1212
use rustc_span::{edition::Edition, Span, DUMMY_SP};
13+
use rustc_target::spec::PanicStrategy;
1314
use std::borrow::Cow;
1415
use std::fmt;
1516
use std::hash::{Hash, Hasher};
@@ -144,6 +145,12 @@ impl IntoDiagnosticArg for usize {
144145
}
145146
}
146147

148+
impl IntoDiagnosticArg for PanicStrategy {
149+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
150+
DiagnosticArgValue::Str(Cow::Owned(self.desc().to_string()))
151+
}
152+
}
153+
147154
impl<'source> Into<FluentValue<'source>> for DiagnosticArgValue<'source> {
148155
fn into(self) -> FluentValue<'source> {
149156
match self {

0 commit comments

Comments
 (0)