Skip to content

Commit 3ed9310

Browse files
committed
port native_libs.rs to SessionDiagnostics
1 parent 54645e8 commit 3ed9310

File tree

3 files changed

+388
-128
lines changed

3 files changed

+388
-128
lines changed

compiler/rustc_error_messages/locales/en-US/metadata.ftl

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,105 @@ metadata_required_panic_strategy =
1919
2020
metadata_incompatible_panic_in_drop_strategy =
2121
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

compiler/rustc_metadata/src/errors.rs

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// use rustc_errors::ErrorGuaranteed;
22
use rustc_macros::SessionDiagnostic;
3+
use rustc_span::Span;
34

45
#[derive(SessionDiagnostic)]
56
#[diag(metadata::rlib_required)]
@@ -50,3 +51,234 @@ pub struct IncompatiblePanicInDropStrategy {
5051
pub found_strategy: String,
5152
pub desired_strategy: String,
5253
}
54+
55+
#[derive(SessionDiagnostic)]
56+
#[diag(metadata::multiple_names_in_link)]
57+
pub struct MultipleNamesInLink {
58+
#[primary_span]
59+
pub span: Span,
60+
}
61+
62+
#[derive(SessionDiagnostic)]
63+
#[diag(metadata::multiple_kinds_in_link)]
64+
pub struct MultipleKindsInLink {
65+
#[primary_span]
66+
pub span: Span,
67+
}
68+
69+
#[derive(SessionDiagnostic)]
70+
#[diag(metadata::link_name_form)]
71+
pub struct LinkNameForm {
72+
#[primary_span]
73+
pub span: Span,
74+
}
75+
76+
#[derive(SessionDiagnostic)]
77+
#[diag(metadata::link_kind_form)]
78+
pub struct LinkKindForm {
79+
#[primary_span]
80+
pub span: Span,
81+
}
82+
83+
#[derive(SessionDiagnostic)]
84+
#[diag(metadata::link_modifiers_form)]
85+
pub struct LinkModifiersForm {
86+
#[primary_span]
87+
pub span: Span,
88+
}
89+
90+
#[derive(SessionDiagnostic)]
91+
#[diag(metadata::link_cfg_form)]
92+
pub struct LinkCfgForm {
93+
#[primary_span]
94+
pub span: Span,
95+
}
96+
97+
#[derive(SessionDiagnostic)]
98+
#[diag(metadata::wasm_import_form)]
99+
pub struct WasmImportForm {
100+
#[primary_span]
101+
pub span: Span,
102+
}
103+
104+
#[derive(SessionDiagnostic)]
105+
#[diag(metadata::empty_link_name, code = "E0454")]
106+
pub struct EmptyLinkName {
107+
#[label]
108+
#[primary_span]
109+
pub span: Span,
110+
}
111+
112+
#[derive(SessionDiagnostic)]
113+
#[diag(metadata::link_framework_apple, code = "E0455")]
114+
pub struct LinkFrameworkApple {
115+
#[primary_span]
116+
pub span: Span,
117+
}
118+
119+
#[derive(SessionDiagnostic)]
120+
#[diag(metadata::framework_only_windows, code = "E0455")]
121+
pub struct FrameworkOnlyWindows {
122+
#[primary_span]
123+
pub span: Span,
124+
}
125+
126+
#[derive(SessionDiagnostic)]
127+
#[diag(metadata::unknown_link_kind, code = "E0458")]
128+
pub struct UnknownLinkKind {
129+
#[label]
130+
#[primary_span]
131+
pub span: Span,
132+
pub kind: String,
133+
}
134+
135+
#[derive(SessionDiagnostic)]
136+
#[diag(metadata::multiple_link_modifiers)]
137+
pub struct MultipleLinkModifiers {
138+
#[primary_span]
139+
pub span: Span,
140+
}
141+
142+
#[derive(SessionDiagnostic)]
143+
#[diag(metadata::multiple_cfgs)]
144+
pub struct MultipleCfgs {
145+
#[primary_span]
146+
pub span: Span,
147+
}
148+
149+
#[derive(SessionDiagnostic)]
150+
#[diag(metadata::link_cfg_single_predicate)]
151+
pub struct LinkCfgSinglePredicate {
152+
#[primary_span]
153+
pub span: Span,
154+
}
155+
156+
#[derive(SessionDiagnostic)]
157+
#[diag(metadata::multiple_wasm_import)]
158+
pub struct MultipleWasmImport {
159+
#[primary_span]
160+
pub span: Span,
161+
}
162+
163+
#[derive(SessionDiagnostic)]
164+
#[diag(metadata::unexpected_link_arg)]
165+
pub struct UnexpectedLinkArg {
166+
#[primary_span]
167+
pub span: Span,
168+
}
169+
170+
#[derive(SessionDiagnostic)]
171+
#[diag(metadata::invalid_link_modifier)]
172+
pub struct InvalidLinkModifier {
173+
#[primary_span]
174+
pub span: Span,
175+
}
176+
177+
#[derive(SessionDiagnostic)]
178+
#[diag(metadata::multiple_modifiers)]
179+
pub struct MultipleModifiers {
180+
#[primary_span]
181+
pub span: Span,
182+
pub modifier: String,
183+
}
184+
185+
#[derive(SessionDiagnostic)]
186+
#[diag(metadata::bundle_needs_static)]
187+
pub struct BundleNeedsStatic {
188+
#[primary_span]
189+
pub span: Span,
190+
}
191+
192+
#[derive(SessionDiagnostic)]
193+
#[diag(metadata::whole_archive_needs_static)]
194+
pub struct WholeArchiveNeedsStatic {
195+
#[primary_span]
196+
pub span: Span,
197+
}
198+
199+
#[derive(SessionDiagnostic)]
200+
#[diag(metadata::as_needed_compatibility)]
201+
pub struct AsNeededCompatibility {
202+
#[primary_span]
203+
pub span: Span,
204+
}
205+
206+
#[derive(SessionDiagnostic)]
207+
#[diag(metadata::unknown_link_modifier)]
208+
pub struct UnknownLinkModifier {
209+
#[primary_span]
210+
pub span: Span,
211+
pub modifier: String,
212+
}
213+
214+
#[derive(SessionDiagnostic)]
215+
#[diag(metadata::incompatible_wasm_link)]
216+
pub struct IncompatibleWasmLink {
217+
#[primary_span]
218+
pub span: Span,
219+
}
220+
221+
#[derive(SessionDiagnostic)]
222+
#[diag(metadata::link_requires_name, code = "E0459")]
223+
pub struct LinkRequiresName {
224+
#[label]
225+
#[primary_span]
226+
pub span: Span,
227+
}
228+
229+
#[derive(SessionDiagnostic)]
230+
#[diag(metadata::raw_dylib_no_nul)]
231+
pub struct RawDylibNoNul {
232+
#[primary_span]
233+
pub span: Span,
234+
}
235+
236+
#[derive(SessionDiagnostic)]
237+
#[diag(metadata::link_ordinal_raw_dylib)]
238+
pub struct LinkOrdinalRawDylib {
239+
#[primary_span]
240+
pub span: Span,
241+
}
242+
243+
#[derive(SessionDiagnostic)]
244+
#[diag(metadata::lib_framework_apple)]
245+
pub struct LibFrameworkApple;
246+
247+
#[derive(SessionDiagnostic)]
248+
#[diag(metadata::empty_renaming_target)]
249+
pub struct EmptyRenamingTarget {
250+
pub lib_name: String,
251+
}
252+
253+
#[derive(SessionDiagnostic)]
254+
#[diag(metadata::renaming_no_link)]
255+
pub struct RenamingNoLink {
256+
pub lib_name: String,
257+
}
258+
259+
#[derive(SessionDiagnostic)]
260+
#[diag(metadata::multiple_renamings)]
261+
pub struct MultipleRenamings {
262+
pub lib_name: String,
263+
}
264+
265+
#[derive(SessionDiagnostic)]
266+
#[diag(metadata::no_link_mod_override)]
267+
pub struct NoLinkModOverride {
268+
#[primary_span]
269+
pub span: Option<Span>,
270+
}
271+
272+
#[derive(SessionDiagnostic)]
273+
#[diag(metadata::unsupported_abi_i686)]
274+
pub struct UnsupportedAbiI686 {
275+
#[primary_span]
276+
pub span: Span,
277+
}
278+
279+
#[derive(SessionDiagnostic)]
280+
#[diag(metadata::unsupported_abi)]
281+
pub struct UnsupportedAbi {
282+
#[primary_span]
283+
pub span: Span,
284+
}

0 commit comments

Comments
 (0)