forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.rs
More file actions
1287 lines (1133 loc) · 43.9 KB
/
errors.rs
File metadata and controls
1287 lines (1133 loc) · 43.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//! Errors emitted by codegen_ssa
use std::borrow::Cow;
use std::ffi::OsString;
use std::io::Error;
use std::path::{Path, PathBuf};
use std::process::ExitStatus;
use rustc_errors::codes::*;
use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level, msg,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_middle::ty::layout::LayoutError;
use rustc_middle::ty::{FloatTy, Ty};
use rustc_span::{Span, Symbol};
use crate::assert_module_sources::CguReuse;
use crate::back::command::Command;
#[derive(Diagnostic)]
#[diag(
"CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be {$at_least ->
[one] {\"at least \"}
*[other] {\"\"}
}`{$expected_reuse}`"
)]
pub(crate) struct IncorrectCguReuseType<'a> {
#[primary_span]
pub span: Span,
pub cgu_user_name: &'a str,
pub actual_reuse: CguReuse,
pub expected_reuse: CguReuse,
pub at_least: u8,
}
#[derive(Diagnostic)]
#[diag("CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded")]
pub(crate) struct CguNotRecorded<'a> {
pub cgu_user_name: &'a str,
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
#[diag("found CGU-reuse attribute but `-Zquery-dep-graph` was not specified")]
pub(crate) struct MissingQueryDepGraph {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(
"found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case)"
)]
pub(crate) struct MalformedCguName<'a> {
#[primary_span]
pub span: Span,
pub user_path: &'a str,
pub crate_name: &'a str,
}
#[derive(Diagnostic)]
#[diag("no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}")]
pub(crate) struct NoModuleNamed<'a> {
#[primary_span]
pub span: Span,
pub user_path: &'a str,
pub cgu_name: Symbol,
pub cgu_names: String,
}
#[derive(Diagnostic)]
#[diag("failed to write lib.def file: {$error}")]
pub(crate) struct LibDefWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("failed to write version script: {$error}")]
pub(crate) struct VersionScriptWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("failed to write symbols file: {$error}")]
pub(crate) struct SymbolFileWriteFailure {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("`as-needed` modifier not implemented yet for ld64")]
pub(crate) struct Ld64UnimplementedModifier;
#[derive(Diagnostic)]
#[diag("`as-needed` modifier not supported for current linker")]
pub(crate) struct LinkerUnsupportedModifier;
#[derive(Diagnostic)]
#[diag("exporting symbols not implemented yet for L4Bender")]
pub(crate) struct L4BenderExportingSymbolsUnimplemented;
#[derive(Diagnostic)]
#[diag("error enumerating natvis directory: {$error}")]
pub(crate) struct NoNatvisDirectory {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("cached cgu {$cgu_name} should have an object file, but doesn't")]
pub(crate) struct NoSavedObjectFile<'a> {
pub cgu_name: &'a str,
}
#[derive(Diagnostic)]
#[diag("`#[track_caller]` requires Rust ABI", code = E0737)]
pub(crate) struct RequiresRustAbi {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("unable to copy {$source_file} to {$output_path}: {$error}")]
pub(crate) struct CopyPathBuf {
pub source_file: PathBuf,
pub output_path: PathBuf,
pub error: Error,
}
// Reports Paths using `Debug` implementation rather than Path's `Display` implementation.
#[derive(Diagnostic)]
#[diag("could not copy {$from} to {$to}: {$error}")]
pub(crate) struct CopyPath<'a> {
from: DebugArgPath<'a>,
to: DebugArgPath<'a>,
error: Error,
}
impl<'a> CopyPath<'a> {
pub(crate) fn new(from: &'a Path, to: &'a Path, error: Error) -> CopyPath<'a> {
CopyPath { from: DebugArgPath(from), to: DebugArgPath(to), error }
}
}
struct DebugArgPath<'a>(pub &'a Path);
impl IntoDiagArg for DebugArgPath<'_> {
fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> rustc_errors::DiagArgValue {
DiagArgValue::Str(Cow::Owned(format!("{:?}", self.0)))
}
}
#[derive(Diagnostic)]
#[diag(
"option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty"
)]
pub(crate) struct BinaryOutputToTty {
pub shorthand: &'static str,
}
#[derive(Diagnostic)]
#[diag("ignoring emit path because multiple .{$extension} files were produced")]
pub(crate) struct IgnoringEmitPath {
pub extension: &'static str,
}
#[derive(Diagnostic)]
#[diag("ignoring -o because multiple .{$extension} files were produced")]
pub(crate) struct IgnoringOutput {
pub extension: &'static str,
}
#[derive(Diagnostic)]
#[diag("couldn't create a temp dir: {$error}")]
pub(crate) struct CreateTempDir {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("failed to add native library {$library_path}: {$error}")]
pub(crate) struct AddNativeLibrary {
pub library_path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag(
"multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions"
)]
pub(crate) struct MultipleExternalFuncDecl<'a> {
#[primary_span]
pub span: Span,
pub function: Symbol,
pub library_name: &'a str,
}
#[derive(Diagnostic)]
pub enum LinkRlibError {
#[diag("could not find formats for rlibs")]
MissingFormat,
#[diag("could not find rlib for: `{$crate_name}`, found rmeta (metadata) file")]
OnlyRmetaFound { crate_name: Symbol },
#[diag("could not find rlib for: `{$crate_name}`")]
NotFound { crate_name: Symbol },
#[diag(
"`{$ty1}` and `{$ty2}` do not have equivalent dependency formats (`{$list1}` vs `{$list2}`)"
)]
IncompatibleDependencyFormats { ty1: String, ty2: String, list1: String, list2: String },
}
pub(crate) struct ThorinErrorWrapper(pub thorin::Error);
impl<G: EmissionGuarantee> Diagnostic<'_, G> for ThorinErrorWrapper {
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let build = |msg| Diag::new(dcx, level, msg);
match self.0 {
thorin::Error::ReadInput(_) => build(msg!("failed to read input file")),
thorin::Error::ParseFileKind(_) => {
build(msg!("failed to parse input file kind"))
}
thorin::Error::ParseObjectFile(_) => {
build(msg!("failed to parse input object file"))
}
thorin::Error::ParseArchiveFile(_) => {
build(msg!("failed to parse input archive file"))
}
thorin::Error::ParseArchiveMember(_) => {
build(msg!("failed to parse archive member"))
}
thorin::Error::InvalidInputKind => build(msg!("input is not an archive or elf object")),
thorin::Error::DecompressData(_) => build(msg!("failed to decompress compressed section")),
thorin::Error::NamelessSection(_, offset) => {
build(msg!("section without name at offset {$offset}"))
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::RelocationWithInvalidSymbol(section, offset) => {
build(msg!("relocation with invalid symbol for section `{$section}` at offset {$offset}"))
.with_arg("section", section)
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::MultipleRelocations(section, offset) => {
build(msg!("multiple relocations for section `{$section}` at offset {$offset}"))
.with_arg("section", section)
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::UnsupportedRelocation(section, offset) => {
build(msg!("unsupported relocation for section {$section} at offset {$offset}"))
.with_arg("section", section)
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::MissingDwoName(id) => build(msg!("missing path attribute to DWARF object ({$id})"))
.with_arg("id", format!("0x{id:08x}")),
thorin::Error::NoCompilationUnits => {
build(msg!("input object has no compilation units"))
}
thorin::Error::NoDie => build(msg!("no top-level debugging information entry in compilation/type unit")),
thorin::Error::TopLevelDieNotUnit => {
build(msg!("top-level debugging information entry is not a compilation/type unit"))
}
thorin::Error::MissingRequiredSection(section) => {
build(msg!("input object missing required section `{$section}`"))
.with_arg("section", section)
}
thorin::Error::ParseUnitAbbreviations(_) => {
build(msg!("failed to parse unit abbreviations"))
}
thorin::Error::ParseUnitAttribute(_) => {
build(msg!("failed to parse unit attribute"))
}
thorin::Error::ParseUnitHeader(_) => {
build(msg!("failed to parse unit header"))
}
thorin::Error::ParseUnit(_) => build(msg!("failed to parse unit")),
thorin::Error::IncompatibleIndexVersion(section, format, actual) => {
build(msg!("incompatible `{$section}` index version: found version {$actual}, expected version {$format}"))
.with_arg("section", section)
.with_arg("actual", actual)
.with_arg("format", format)
}
thorin::Error::OffsetAtIndex(_, index) => {
build(msg!("read offset at index {$index} of `.debug_str_offsets.dwo` section")).with_arg("index", index)
}
thorin::Error::StrAtOffset(_, offset) => {
build(msg!("read string at offset {$offset} of `.debug_str.dwo` section"))
.with_arg("offset", format!("0x{offset:08x}"))
}
thorin::Error::ParseIndex(_, section) => {
build(msg!("failed to parse `{$section}` index section")).with_arg("section", section)
}
thorin::Error::UnitNotInIndex(unit) => {
build(msg!("unit {$unit} from input package is not in its index"))
.with_arg("unit", format!("0x{unit:08x}"))
}
thorin::Error::RowNotInIndex(_, row) => {
build(msg!("row {$row} found in index's hash table not present in index")).with_arg("row", row)
}
thorin::Error::SectionNotInRow => build(msg!("section not found in unit's row in index")),
thorin::Error::EmptyUnit(unit) => build(msg!("unit {$unit} in input DWARF object with no data"))
.with_arg("unit", format!("0x{unit:08x}")),
thorin::Error::MultipleDebugInfoSection => {
build(msg!("multiple `.debug_info.dwo` sections"))
}
thorin::Error::MultipleDebugTypesSection => {
build(msg!("multiple `.debug_types.dwo` sections in a package"))
}
thorin::Error::NotSplitUnit => build(msg!("regular compilation unit in object (missing dwo identifier)")),
thorin::Error::DuplicateUnit(unit) => build(msg!("duplicate split compilation unit ({$unit})"))
.with_arg("unit", format!("0x{unit:08x}")),
thorin::Error::MissingReferencedUnit(unit) => {
build(msg!("unit {$unit} referenced by executable was not found"))
.with_arg("unit", format!("0x{unit:08x}"))
}
thorin::Error::NoOutputObjectCreated => {
build(msg!("no output object was created from inputs"))
}
thorin::Error::MixedInputEncodings => {
build(msg!("input objects have mixed encodings"))
}
thorin::Error::Io(e) => {
build(msg!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::ObjectRead(e) => {
build(msg!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::ObjectWrite(e) => {
build(msg!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::GimliRead(e) => {
build(msg!("{$error}")).with_arg("error", format!("{e}"))
}
thorin::Error::GimliWrite(e) => {
build(msg!("{$error}")).with_arg("error", format!("{e}"))
}
_ => unimplemented!("Untranslated thorin error"),
}
}
}
pub(crate) struct LinkingFailed<'a> {
pub linker_path: &'a Path,
pub exit_status: ExitStatus,
pub command: Command,
pub escaped_output: String,
pub verbose: bool,
pub sysroot_dir: PathBuf,
}
impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
fn into_diag(mut self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
let mut diag =
Diag::new(dcx, level, msg!("linking with `{$linker_path}` failed: {$exit_status}"));
diag.arg("linker_path", format!("{}", self.linker_path.display()));
diag.arg("exit_status", format!("{}", self.exit_status));
let contains_undefined_ref = self.escaped_output.contains("undefined reference to");
if self.verbose {
diag.note(format!("{:?}", self.command));
} else {
self.command.env_clear();
enum ArgGroup {
Regular(OsString),
Objects(usize),
Rlibs(PathBuf, Vec<OsString>),
}
// Omit rust object files and fold rlibs in the error by default to make linker errors a
// bit less verbose.
let orig_args = self.command.take_args();
let mut args: Vec<ArgGroup> = vec![];
for arg in orig_args {
if arg.as_encoded_bytes().ends_with(b".rcgu.o") {
if let Some(ArgGroup::Objects(n)) = args.last_mut() {
*n += 1;
} else {
args.push(ArgGroup::Objects(1));
}
} else if arg.as_encoded_bytes().ends_with(b".rlib") {
let rlib_path = Path::new(&arg);
let dir = rlib_path.parent().unwrap();
let filename = rlib_path.file_stem().unwrap().to_owned();
if let Some(ArgGroup::Rlibs(parent, rlibs)) = args.last_mut() {
if parent == dir {
rlibs.push(filename);
} else {
args.push(ArgGroup::Rlibs(dir.to_owned(), vec![filename]));
}
} else {
args.push(ArgGroup::Rlibs(dir.to_owned(), vec![filename]));
}
} else {
args.push(ArgGroup::Regular(arg));
}
}
let crate_hash = regex::bytes::Regex::new(r"-[0-9a-f]+").unwrap();
self.command.args(args.into_iter().map(|arg_group| {
match arg_group {
// SAFETY: we are only matching on ASCII, not any surrogate pairs, so any replacements we do will still be valid.
ArgGroup::Regular(arg) => unsafe {
use bstr::ByteSlice;
OsString::from_encoded_bytes_unchecked(
arg.as_encoded_bytes().replace(
self.sysroot_dir.as_os_str().as_encoded_bytes(),
b"<sysroot>",
),
)
},
ArgGroup::Objects(n) => OsString::from(format!("<{n} object files omitted>")),
ArgGroup::Rlibs(mut dir, rlibs) => {
let is_sysroot_dir = match dir.strip_prefix(&self.sysroot_dir) {
Ok(short) => {
dir = Path::new("<sysroot>").join(short);
true
}
Err(_) => false,
};
let mut arg = dir.into_os_string();
arg.push("/");
let needs_braces = rlibs.len() >= 2;
if needs_braces {
arg.push("{");
}
let mut first = true;
for mut rlib in rlibs {
if !first {
arg.push(",");
}
first = false;
if is_sysroot_dir {
// SAFETY: Regex works one byte at a type, and our regex will not match surrogate pairs (because it only matches ascii).
rlib = unsafe {
OsString::from_encoded_bytes_unchecked(
crate_hash
.replace(rlib.as_encoded_bytes(), b"-*")
.into_owned(),
)
};
}
arg.push(rlib);
}
if needs_braces {
arg.push("}");
}
arg.push(".rlib");
arg
}
}
}));
diag.note(format!("{:?}", self.command).trim_start_matches("env -i").to_owned());
diag.note("some arguments are omitted. use `--verbose` to show all linker arguments");
}
diag.note(self.escaped_output);
// Trying to match an error from OS linkers
// which by now we have no way to translate.
if contains_undefined_ref {
diag.note(msg!("some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified"))
.note(msg!("use the `-l` flag to specify native libraries to link"));
if rustc_session::utils::was_invoked_from_cargo() {
diag.note(msg!("use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)"));
}
}
diag
}
}
#[derive(Diagnostic)]
#[diag("`link.exe` returned an unexpected error")]
pub(crate) struct LinkExeUnexpectedError;
pub(crate) struct LinkExeStatusStackBufferOverrun;
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for LinkExeStatusStackBufferOverrun {
fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag = Diag::new(dcx, level, msg!("0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`"));
diag.note(msg!(
"this may have been caused by a program abort and not a stack buffer overrun"
));
diag.note(msg!("consider checking the Application Event Log for Windows Error Reporting events to see the fail fast error code"));
diag
}
}
#[derive(Diagnostic)]
#[diag("the Visual Studio build tools may need to be repaired using the Visual Studio installer")]
pub(crate) struct RepairVSBuildTools;
#[derive(Diagnostic)]
#[diag("or a necessary component may be missing from the \"C++ build tools\" workload")]
pub(crate) struct MissingCppBuildToolComponent;
#[derive(Diagnostic)]
#[diag("in the Visual Studio installer, ensure the \"C++ build tools\" workload is selected")]
pub(crate) struct SelectCppBuildToolWorkload;
#[derive(Diagnostic)]
#[diag("you may need to install Visual Studio build tools with the \"C++ build tools\" workload")]
pub(crate) struct VisualStudioNotInstalled;
#[derive(Diagnostic)]
#[diag("linker `{$linker_path}` not found")]
#[note("{$error}")]
pub(crate) struct LinkerNotFound {
pub linker_path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("could not exec the linker `{$linker_path}`")]
#[note("{$error}")]
#[note("{$command_formatted}")]
pub(crate) struct UnableToExeLinker {
pub linker_path: PathBuf,
pub error: Error,
pub command_formatted: String,
}
#[derive(Diagnostic)]
#[diag("the msvc targets depend on the msvc linker but `link.exe` was not found")]
pub(crate) struct MsvcMissingLinker;
#[derive(Diagnostic)]
#[diag(
"the self-contained linker was requested, but it wasn't found in the target's sysroot, or in rustc's sysroot"
)]
pub(crate) struct SelfContainedLinkerMissing;
#[derive(Diagnostic)]
#[diag(
"please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option"
)]
pub(crate) struct CheckInstalledVisualStudio;
#[derive(Diagnostic)]
#[diag("VS Code is a different product, and is not sufficient")]
pub(crate) struct InsufficientVSCodeProduct;
#[derive(Diagnostic)]
#[diag("target requires explicitly specifying a cpu with `-C target-cpu`")]
pub(crate) struct CpuRequired;
#[derive(Diagnostic)]
#[diag("processing debug info with `dsymutil` failed: {$status}")]
#[note("{$output}")]
pub(crate) struct ProcessingDymutilFailed {
pub status: ExitStatus,
pub output: String,
}
#[derive(Diagnostic)]
#[diag("unable to run `dsymutil`: {$error}")]
pub(crate) struct UnableToRunDsymutil {
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("stripping debug info with `{$util}` failed: {$status}")]
#[note("{$output}")]
pub(crate) struct StrippingDebugInfoFailed<'a> {
pub util: &'a str,
pub status: ExitStatus,
pub output: String,
}
#[derive(Diagnostic)]
#[diag("unable to run `{$util}`: {$error}")]
pub(crate) struct UnableToRun<'a> {
pub util: &'a str,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("couldn't extract file stem from specified linker")]
pub(crate) struct LinkerFileStem;
#[derive(Diagnostic)]
#[diag(
"link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms"
)]
pub(crate) struct StaticLibraryNativeArtifacts;
#[derive(Diagnostic)]
#[diag(
"native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms"
)]
pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> {
pub path: &'a Path,
}
#[derive(Diagnostic)]
#[diag("can only use link script when linking with GNU-like linker")]
pub(crate) struct LinkScriptUnavailable;
#[derive(Diagnostic)]
#[diag("failed to write link script to {$path}: {$error}")]
pub(crate) struct LinkScriptWriteFailure {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("failed to write {$path}: {$error}")]
pub(crate) struct FailedToWrite {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("unable to write debugger visualizer file `{$path}`: {$error}")]
pub(crate) struct UnableToWriteDebuggerVisualizer {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
#[diag("failed to build archive from rlib at `{$path}`: {$error}")]
pub(crate) struct RlibArchiveBuildFailure {
pub path: PathBuf,
pub error: Error,
}
#[derive(Diagnostic)]
// Public for ArchiveBuilderBuilder::extract_bundled_libs
pub enum ExtractBundledLibsError<'a> {
#[diag("failed to open file '{$rlib}': {$error}")]
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to mmap file '{$rlib}': {$error}")]
MmapFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to parse archive '{$rlib}': {$error}")]
ParseArchive { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to read entry '{$rlib}': {$error}")]
ReadEntry { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to get data from archive member '{$rlib}': {$error}")]
ArchiveMember { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to convert name '{$rlib}': {$error}")]
ConvertName { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to write file '{$rlib}': {$error}")]
WriteFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
#[diag("failed to write file '{$rlib}': {$error}")]
ExtractSection { rlib: &'a Path, error: Box<dyn std::error::Error> },
}
#[derive(Diagnostic)]
#[diag("failed to read file: {$message}")]
pub(crate) struct ReadFileError {
pub message: std::io::Error,
}
#[derive(Diagnostic)]
#[diag("option `-C link-self-contained` is not supported on this target")]
pub(crate) struct UnsupportedLinkSelfContained;
#[derive(Diagnostic)]
#[diag("failed to build archive at `{$path}`: {$error}")]
pub(crate) struct ArchiveBuildFailure {
pub path: PathBuf,
pub error: std::io::Error,
}
#[derive(Diagnostic)]
#[diag("don't know how to build archive of type: {$kind}")]
pub(crate) struct UnknownArchiveKind<'a> {
pub kind: &'a str,
}
#[derive(Diagnostic)]
#[diag("linking static libraries is not supported for BPF")]
pub(crate) struct BpfStaticlibNotSupported;
#[derive(Diagnostic)]
#[diag("entry symbol `main` declared multiple times")]
#[help(
"did you use `#[no_mangle]` on `fn main`? Use `#![no_main]` to suppress the usual Rust-generated entry point"
)]
pub(crate) struct MultipleMainFunctions {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag("could not evaluate shuffle_indices at compile time")]
pub(crate) struct ShuffleIndicesEvaluation {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
pub enum InvalidMonomorphization<'tcx> {
#[diag("invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`", code = E0511)]
BasicIntegerType {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected basic integer or pointer type, found `{$ty}`", code = E0511)]
BasicIntegerOrPtrType {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected basic float type, found `{$ty}`", code = E0511)]
BasicFloatType {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `float_to_int_unchecked` intrinsic: expected basic float type, found `{$ty}`", code = E0511)]
FloatToIntUnchecked {
#[primary_span]
span: Span,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$f_ty}` of floating-point vector `{$in_ty}`", code = E0511)]
FloatingPointVector {
#[primary_span]
span: Span,
name: Symbol,
f_ty: FloatTy,
in_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: `{$in_ty}` is not a floating-point type", code = E0511)]
FloatingPointType {
#[primary_span]
span: Span,
name: Symbol,
in_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`", code = E0511)]
UnrecognizedIntrinsic {
#[primary_span]
span: Span,
name: Symbol,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}`", code = E0511)]
SimdArgument {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}`", code = E0511)]
SimdInput {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}`", code = E0511)]
SimdFirst {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD second type, found non-SIMD `{$ty}`", code = E0511)]
SimdSecond {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD third type, found non-SIMD `{$ty}`", code = E0511)]
SimdThird {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}`", code = E0511)]
SimdReturn {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$mask_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`", code = E0511)]
InvalidBitmask {
#[primary_span]
span: Span,
name: Symbol,
mask_ty: Ty<'tcx>,
expected_int_bits: u64,
expected_bytes: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}", code = E0511)]
ReturnLengthInputType {
#[primary_span]
span: Span,
name: Symbol,
in_len: u64,
in_ty: Ty<'tcx>,
ret_ty: Ty<'tcx>,
out_len: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}", code = E0511)]
SecondArgumentLength {
#[primary_span]
span: Span,
name: Symbol,
in_len: u64,
in_ty: Ty<'tcx>,
arg_ty: Ty<'tcx>,
out_len: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected third argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}", code = E0511)]
ThirdArgumentLength {
#[primary_span]
span: Span,
name: Symbol,
in_len: u64,
in_ty: Ty<'tcx>,
arg_ty: Ty<'tcx>,
out_len: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`", code = E0511)]
ReturnIntegerType {
#[primary_span]
span: Span,
name: Symbol,
ret_ty: Ty<'tcx>,
out_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be a SIMD vector of `u32`, got `{$ty}`", code = E0511)]
SimdShuffle {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}", code = E0511)]
ReturnLength {
#[primary_span]
span: Span,
name: Symbol,
in_len: u64,
ret_ty: Ty<'tcx>,
out_len: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`", code = E0511)]
ReturnElement {
#[primary_span]
span: Span,
name: Symbol,
in_elem: Ty<'tcx>,
in_ty: Ty<'tcx>,
ret_ty: Ty<'tcx>,
out_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: SIMD index #{$arg_idx} is out of bounds (limit {$total_len})", code = E0511)]
SimdIndexOutOfBounds {
#[primary_span]
span: Span,
name: Symbol,
arg_idx: u64,
total_len: u128,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`", code = E0511)]
InsertedType {
#[primary_span]
span: Span,
name: Symbol,
in_elem: Ty<'tcx>,
in_ty: Ty<'tcx>,
out_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`", code = E0511)]
ReturnType {
#[primary_span]
span: Span,
name: Symbol,
in_elem: Ty<'tcx>,
in_ty: Ty<'tcx>,
ret_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_ty}`, found `{$ret_ty}`", code = E0511)]
ExpectedReturnType {
#[primary_span]
span: Span,
name: Symbol,
in_ty: Ty<'tcx>,
ret_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`", code = E0511)]
MismatchedLengths {
#[primary_span]
span: Span,
name: Symbol,
m_len: u64,
v_len: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected mask element type to be an integer, found `{$ty}`", code = E0511)]
MaskWrongElementType {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`", code = E0511)]
CannotReturn {
#[primary_span]
span: Span,
name: Symbol,
ret_ty: Ty<'tcx>,
expected_int_bits: u64,
expected_bytes: u64,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of second argument `{$second_arg}` to be a pointer to the element type `{$in_elem}` of the first argument `{$in_ty}`, found `{$expected_element}` != `{$mutability} {$in_elem}`", code = E0511)]
ExpectedElementType {
#[primary_span]
span: Span,
name: Symbol,
expected_element: Ty<'tcx>,
second_arg: Ty<'tcx>,
in_elem: Ty<'tcx>,
in_ty: Ty<'tcx>,
mutability: ExpectedPointerMutability,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` of size `{$size}` to `{$ret_ty}`", code = E0511)]
UnsupportedSymbolOfSize {
#[primary_span]
span: Span,
name: Symbol,
symbol: Symbol,
in_ty: Ty<'tcx>,
in_elem: Ty<'tcx>,
size: u64,
ret_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: unsupported {$symbol} from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}`", code = E0511)]
UnsupportedSymbol {
#[primary_span]
span: Span,
name: Symbol,
symbol: Symbol,
in_ty: Ty<'tcx>,
in_elem: Ty<'tcx>,
ret_ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`", code = E0511)]
CastWidePointer {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},
#[diag("invalid monomorphization of `{$name}` intrinsic: expected pointer, got `{$ty}`", code = E0511)]
ExpectedPointer {
#[primary_span]
span: Span,
name: Symbol,
ty: Ty<'tcx>,
},