Skip to content

Commit a25f939

Browse files
committed
Address PR comments
- UPDATE - revert migration of logs - UPDATE - use derive on LinkRlibError enum - [Gardening] UPDATE - alphabetically sort fluent_messages - UPDATE - use PathBuf and unify both AddNativeLibrary to use Display (which is what PathBuf uses when conforming to IntoDiagnosticArg) - UPDATE - fluent messages sort after rebase
1 parent 12aa84b commit a25f939

File tree

5 files changed

+15
-53
lines changed

5 files changed

+15
-53
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,7 @@ fn link_rlib<'a>(
362362
continue;
363363
}
364364
ab.add_archive(&location, Box::new(|_| false)).unwrap_or_else(|error| {
365-
sess.emit_fatal(errors::AddNativeLibrary {
366-
library_path: &location.to_string_lossy(),
367-
error,
368-
});
365+
sess.emit_fatal(errors::AddNativeLibrary { library_path: location, error });
369366
});
370367
}
371368
}
@@ -381,10 +378,7 @@ fn link_rlib<'a>(
381378
);
382379

383380
ab.add_archive(&output_path, Box::new(|_| false)).unwrap_or_else(|error| {
384-
sess.emit_fatal(errors::AddNativeLibrary {
385-
library_path: &output_path.display().to_string(),
386-
error,
387-
});
381+
sess.emit_fatal(errors::AddNativeLibrary { library_path: output_path, error });
388382
});
389383
}
390384

compiler/rustc_codegen_ssa/src/back/linker.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ pub fn get_linker<'a>(
9191
arg.push(format!("{}\\lib\\{}\\store", root_lib_path.display(), a));
9292
cmd.arg(&arg);
9393
} else {
94-
sess.emit_warning(errors::UnsupportedArch);
94+
warn!("arch is not supported");
9595
}
9696
} else {
97-
sess.emit_warning(errors::MsvcPathNotFound);
97+
warn!("MSVC root path lib location not found");
9898
}
9999
} else {
100-
sess.emit_warning(errors::LinkExeNotFound);
100+
warn!("link.exe not found");
101101
}
102102
}
103103

compiler/rustc_codegen_ssa/src/errors.rs

+8-34
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ pub struct SymbolFileWriteFailure {
3030
pub error: Error,
3131
}
3232

33-
#[derive(Diagnostic)]
34-
#[diag(codegen_ssa::unsupported_arch)]
35-
pub struct UnsupportedArch;
36-
37-
#[derive(Diagnostic)]
38-
#[diag(codegen_ssa::msvc_path_not_found)]
39-
pub struct MsvcPathNotFound;
40-
41-
#[derive(Diagnostic)]
42-
#[diag(codegen_ssa::link_exe_not_found)]
43-
pub struct LinkExeNotFound;
44-
4533
#[derive(Diagnostic)]
4634
#[diag(codegen_ssa::ld64_unimplemented_modifier)]
4735
pub struct Ld64UnimplementedModifier;
@@ -115,8 +103,8 @@ pub struct IncompatibleLinkingModifiers;
115103

116104
#[derive(Diagnostic)]
117105
#[diag(codegen_ssa::add_native_library)]
118-
pub struct AddNativeLibrary<'a> {
119-
pub library_path: &'a str,
106+
pub struct AddNativeLibrary {
107+
pub library_path: PathBuf,
120108
pub error: Error,
121109
}
122110

@@ -129,30 +117,16 @@ pub struct MultipleExternalFuncDecl<'a> {
129117
pub library_name: &'a str,
130118
}
131119

120+
#[derive(Diagnostic)]
132121
pub enum LinkRlibError {
122+
#[diag(codegen_ssa::rlib_missing_format)]
133123
MissingFormat,
124+
125+
#[diag(codegen_ssa::rlib_only_rmeta_found)]
134126
OnlyRmetaFound { crate_name: Symbol },
135-
NotFound { crate_name: Symbol },
136-
}
137127

138-
impl IntoDiagnostic<'_, !> for LinkRlibError {
139-
fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder<'_, !> {
140-
match self {
141-
LinkRlibError::MissingFormat => {
142-
handler.struct_fatal(fluent::codegen_ssa::rlib_missing_format)
143-
}
144-
LinkRlibError::OnlyRmetaFound { crate_name } => {
145-
let mut diag = handler.struct_fatal(fluent::codegen_ssa::rlib_only_rmeta_found);
146-
diag.set_arg("crate_name", crate_name);
147-
diag
148-
}
149-
LinkRlibError::NotFound { crate_name } => {
150-
let mut diag = handler.struct_fatal(fluent::codegen_ssa::rlib_not_found);
151-
diag.set_arg("crate_name", crate_name);
152-
diag
153-
}
154-
}
155-
}
128+
#[diag(codegen_ssa::rlib_not_found)]
129+
NotFound { crate_name: Symbol },
156130
}
157131

158132
#[derive(Diagnostic)]

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

-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ codegen_ssa_version_script_write_failure = failed to write version script: {$err
44
55
codegen_ssa_symbol_file_write_failure = failed to write symbols file: {$error}
66
7-
codegen_ssa_unsupported_arch = arch is not supported
8-
9-
codegen_ssa_msvc_path_not_found = MSVC root path lib location not found
10-
11-
codegen_ssa_link_exe_not_found = link.exe not found
12-
137
codegen_ssa_ld64_unimplemented_modifier = `as-needed` modifier not implemented yet for ld64
148
159
codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for current linker

compiler/rustc_error_messages/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ fluent_messages! {
4040
attr => "../locales/en-US/attr.ftl",
4141
borrowck => "../locales/en-US/borrowck.ftl",
4242
builtin_macros => "../locales/en-US/builtin_macros.ftl",
43+
codegen_gcc => "../locales/en-US/codegen_gcc.ftl",
44+
codegen_ssa => "../locales/en-US/codegen_ssa.ftl",
4345
compiletest => "../locales/en-US/compiletest.ftl",
4446
const_eval => "../locales/en-US/const_eval.ftl",
45-
codegen_gcc => "../locales/en-US/codegen_gcc.ftl",
4647
driver => "../locales/en-US/driver.ftl",
4748
expand => "../locales/en-US/expand.ftl",
4849
hir_analysis => "../locales/en-US/hir_analysis.ftl",
@@ -63,7 +64,6 @@ fluent_messages! {
6364
symbol_mangling => "../locales/en-US/symbol_mangling.ftl",
6465
trait_selection => "../locales/en-US/trait_selection.ftl",
6566
ty_utils => "../locales/en-US/ty_utils.ftl",
66-
codegen_ssa => "../locales/en-US/codegen_ssa.ftl",
6767
}
6868

6969
pub use fluent_generated::{self as fluent, DEFAULT_LOCALE_RESOURCES};

0 commit comments

Comments
 (0)