Skip to content

Commit 5ea71c1

Browse files
committed
Rename many DiagCtxt arguments.
1 parent a5c63ae commit 5ea71c1

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/back/lto.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct LtoData {
6161
tmp_path: TempDir,
6262
}
6363

64-
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt) -> Result<LtoData, FatalError> {
64+
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, dcx: &DiagCtxt) -> Result<LtoData, FatalError> {
6565
let export_threshold = match cgcx.lto {
6666
// We're just doing LTO for our one crate
6767
Lto::ThinLocal => SymbolExportLevel::Rust,
@@ -106,18 +106,18 @@ fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt
106106
// Make sure we actually can run LTO
107107
for crate_type in cgcx.crate_types.iter() {
108108
if !crate_type_allows_lto(*crate_type) {
109-
diag_handler.emit_err(LtoDisallowed);
109+
dcx.emit_err(LtoDisallowed);
110110
return Err(FatalError);
111111
} else if *crate_type == CrateType::Dylib {
112112
if !cgcx.opts.unstable_opts.dylib_lto {
113-
diag_handler.emit_err(LtoDylib);
113+
dcx.emit_err(LtoDylib);
114114
return Err(FatalError);
115115
}
116116
}
117117
}
118118

119119
if cgcx.opts.cg.prefer_dynamic && !cgcx.opts.unstable_opts.dylib_lto {
120-
diag_handler.emit_err(DynamicLinkingWithLTO);
120+
dcx.emit_err(DynamicLinkingWithLTO);
121121
return Err(FatalError);
122122
}
123123

@@ -154,7 +154,7 @@ fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt
154154
upstream_modules.push((module, CString::new(name).unwrap()));
155155
}
156156
Err(e) => {
157-
diag_handler.emit_err(e);
157+
dcx.emit_err(e);
158158
return Err(FatalError);
159159
}
160160
}
@@ -183,16 +183,16 @@ pub(crate) fn run_fat(
183183
modules: Vec<FatLtoInput<GccCodegenBackend>>,
184184
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
185185
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
186-
let diag_handler = cgcx.create_dcx();
187-
let lto_data = prepare_lto(cgcx, &diag_handler)?;
186+
let dcx = cgcx.create_dcx();
187+
let lto_data = prepare_lto(cgcx, &dcx)?;
188188
/*let symbols_below_threshold =
189189
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
190-
fat_lto(cgcx, &diag_handler, modules, cached_modules, lto_data.upstream_modules, lto_data.tmp_path,
190+
fat_lto(cgcx, &dcx, modules, cached_modules, lto_data.upstream_modules, lto_data.tmp_path,
191191
//&symbols_below_threshold,
192192
)
193193
}
194194

195-
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
195+
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _dcx: &DiagCtxt, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
196196
//symbols_below_threshold: &[*const libc::c_char],
197197
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
198198
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
@@ -257,7 +257,7 @@ fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, m
257257
let (buffer, name) = serialized_modules.remove(0);
258258
info!("no in-memory regular modules to choose from, parsing {:?}", name);
259259
ModuleCodegen {
260-
module_llvm: GccContext::parse(cgcx, &name, buffer.data(), diag_handler)?,
260+
module_llvm: GccContext::parse(cgcx, &name, buffer.data(), dcx)?,
261261
name: name.into_string().unwrap(),
262262
kind: ModuleKind::Regular,
263263
}*/

src/back/write.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_target::spec::SplitDebuginfo;
1313
use crate::{GccCodegenBackend, GccContext};
1414
use crate::errors::CopyBitcode;
1515

16-
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &DiagCtxt, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
16+
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, dcx: &DiagCtxt, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
1717
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
1818
{
1919
let context = &module.module_llvm.context;
@@ -127,12 +127,12 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
127127
EmitObj::Bitcode => {
128128
debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out);
129129
if let Err(err) = link_or_copy(&bc_out, &obj_out) {
130-
diag_handler.emit_err(CopyBitcode { err });
130+
dcx.emit_err(CopyBitcode { err });
131131
}
132132

133133
if !config.emit_bc {
134134
debug!("removing_bitcode {:?}", bc_out);
135-
ensure_removed(diag_handler, &bc_out);
135+
ensure_removed(dcx, &bc_out);
136136
}
137137
}
138138

@@ -148,7 +148,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
148148
))
149149
}
150150

151-
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &DiagCtxt, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
151+
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _dcx: &DiagCtxt, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
152152
unimplemented!();
153153
}
154154

src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
112112
pub(crate) struct MissingFeatures;
113113

114114
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> {
115-
fn into_diagnostic(self, handler: &'_ DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
116-
let mut diag = handler.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable);
115+
fn into_diagnostic(self, dcx: &'_ DiagCtxt) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
116+
let mut diag = dcx.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable);
117117
if let Some(span) = self.span {
118118
diag.set_span(span);
119119
};

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl WriteBackendMethods for GccCodegenBackend {
330330
unimplemented!()
331331
}
332332

333-
unsafe fn optimize(_cgcx: &CodegenContext<Self>, _diag_handler: &DiagCtxt, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<(), FatalError> {
333+
unsafe fn optimize(_cgcx: &CodegenContext<Self>, _dcx: &DiagCtxt, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<(), FatalError> {
334334
module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level));
335335
Ok(())
336336
}
@@ -344,8 +344,8 @@ impl WriteBackendMethods for GccCodegenBackend {
344344
unimplemented!();
345345
}
346346

347-
unsafe fn codegen(cgcx: &CodegenContext<Self>, diag_handler: &DiagCtxt, module: ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
348-
back::write::codegen(cgcx, diag_handler, module, config)
347+
unsafe fn codegen(cgcx: &CodegenContext<Self>, dcx: &DiagCtxt, module: ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
348+
back::write::codegen(cgcx, dcx, module, config)
349349
}
350350

351351
fn prepare_thin(_module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
@@ -356,8 +356,8 @@ impl WriteBackendMethods for GccCodegenBackend {
356356
unimplemented!();
357357
}
358358

359-
fn run_link(cgcx: &CodegenContext<Self>, diag_handler: &DiagCtxt, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
360-
back::write::link(cgcx, diag_handler, modules)
359+
fn run_link(cgcx: &CodegenContext<Self>, dcx: &DiagCtxt, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
360+
back::write::link(cgcx, dcx, modules)
361361
}
362362
}
363363

0 commit comments

Comments
 (0)