Skip to content

Commit 6c75e81

Browse files
committed
Refactor: Rename db locals to diag
#64272 replaced `DiagnosticBuilder` with `Diagnostic` in some places. This commit just renames the DB variable from `db` to `diag` where it wasn't renamed.
1 parent e369d87 commit 6c75e81

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

src/librustc_codegen_ssa/back/write.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1667,13 +1667,13 @@ impl SharedEmitter {
16671667
}
16681668

16691669
impl Emitter for SharedEmitter {
1670-
fn emit_diagnostic(&mut self, db: &rustc_errors::Diagnostic) {
1670+
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
16711671
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
1672-
msg: db.message(),
1673-
code: db.code.clone(),
1674-
lvl: db.level,
1672+
msg: diag.message(),
1673+
code: diag.code.clone(),
1674+
lvl: diag.level,
16751675
})));
1676-
for child in &db.children {
1676+
for child in &diag.children {
16771677
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
16781678
msg: child.message(),
16791679
code: None,

src/librustc_errors/annotate_snippet_emitter_writer.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ pub struct AnnotateSnippetEmitterWriter {
3131

3232
impl Emitter for AnnotateSnippetEmitterWriter {
3333
/// The entry point for the diagnostics generation
34-
fn emit_diagnostic(&mut self, db: &Diagnostic) {
35-
let mut children = db.children.clone();
36-
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
34+
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
35+
let mut children = diag.children.clone();
36+
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag);
3737

3838
self.fix_multispans_in_std_macros(&self.source_map,
3939
&mut primary_span,
4040
&mut children,
41-
&db.level,
41+
&diag.level,
4242
self.external_macro_backtrace);
4343

44-
self.emit_messages_default(&db.level,
45-
db.message(),
46-
&db.code,
44+
self.emit_messages_default(&diag.level,
45+
diag.message(),
46+
&diag.code,
4747
&primary_span,
4848
&children,
4949
&suggestions);

src/librustc_errors/emitter.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ const ANONYMIZED_LINE_NUM: &str = "LL";
180180
/// Emitter trait for emitting errors.
181181
pub trait Emitter {
182182
/// Emit a structured diagnostic.
183-
fn emit_diagnostic(&mut self, db: &Diagnostic);
183+
fn emit_diagnostic(&mut self, diag: &Diagnostic);
184184

185185
/// Emit a notification that an artifact has been output.
186186
/// This is currently only supported for the JSON format,
@@ -206,10 +206,10 @@ pub trait Emitter {
206206
/// we return the original `primary_span` and the original suggestions.
207207
fn primary_span_formatted<'a>(
208208
&mut self,
209-
db: &'a Diagnostic,
209+
diag: &'a Diagnostic,
210210
) -> (MultiSpan, &'a [CodeSuggestion]) {
211-
let mut primary_span = db.span.clone();
212-
if let Some((sugg, rest)) = db.suggestions.split_first() {
211+
let mut primary_span = diag.span.clone();
212+
if let Some((sugg, rest)) = diag.suggestions.split_first() {
213213
if rest.is_empty() &&
214214
// ^ if there is only one suggestion
215215
// don't display multi-suggestions as labels
@@ -260,10 +260,10 @@ pub trait Emitter {
260260
// to be consistent. We could try to figure out if we can
261261
// make one (or the first one) inline, but that would give
262262
// undue importance to a semi-random suggestion
263-
(primary_span, &db.suggestions)
263+
(primary_span, &diag.suggestions)
264264
}
265265
} else {
266-
(primary_span, &db.suggestions)
266+
(primary_span, &diag.suggestions)
267267
}
268268
}
269269

@@ -401,19 +401,19 @@ impl Emitter for EmitterWriter {
401401
self.sm.as_ref()
402402
}
403403

404-
fn emit_diagnostic(&mut self, db: &Diagnostic) {
405-
let mut children = db.children.clone();
406-
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
404+
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
405+
let mut children = diag.children.clone();
406+
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag);
407407

408408
self.fix_multispans_in_std_macros(&self.sm,
409409
&mut primary_span,
410410
&mut children,
411-
&db.level,
411+
&diag.level,
412412
self.external_macro_backtrace);
413413

414-
self.emit_messages_default(&db.level,
415-
&db.styled_message(),
416-
&db.code,
414+
self.emit_messages_default(&diag.level,
415+
&diag.styled_message(),
416+
&diag.code,
417417
&primary_span,
418418
&children,
419419
&suggestions);

src/libsyntax/json.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ impl JsonEmitter {
8989
}
9090

9191
impl Emitter for JsonEmitter {
92-
fn emit_diagnostic(&mut self, db: &errors::Diagnostic) {
93-
let data = Diagnostic::from_errors_diagnostic(db, self);
92+
fn emit_diagnostic(&mut self, diag: &errors::Diagnostic) {
93+
let data = Diagnostic::from_errors_diagnostic(diag, self);
9494
let result = if self.pretty {
9595
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
9696
} else {
@@ -209,10 +209,10 @@ struct ArtifactNotification<'a> {
209209
}
210210

211211
impl Diagnostic {
212-
fn from_errors_diagnostic(db: &errors::Diagnostic,
212+
fn from_errors_diagnostic(diag: &errors::Diagnostic,
213213
je: &JsonEmitter)
214214
-> Diagnostic {
215-
let sugg = db.suggestions.iter().map(|sugg| {
215+
let sugg = diag.suggestions.iter().map(|sugg| {
216216
Diagnostic {
217217
message: sugg.msg.clone(),
218218
code: None,
@@ -241,30 +241,30 @@ impl Diagnostic {
241241
let output = buf.clone();
242242
je.json_rendered.new_emitter(
243243
Box::new(buf), Some(je.sm.clone()), false, None, je.external_macro_backtrace
244-
).ui_testing(je.ui_testing).emit_diagnostic(db);
244+
).ui_testing(je.ui_testing).emit_diagnostic(diag);
245245
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
246246
let output = String::from_utf8(output).unwrap();
247247

248248
Diagnostic {
249-
message: db.message(),
250-
code: DiagnosticCode::map_opt_string(db.code.clone(), je),
251-
level: db.level.to_str(),
252-
spans: DiagnosticSpan::from_multispan(&db.span, je),
253-
children: db.children.iter().map(|c| {
249+
message: diag.message(),
250+
code: DiagnosticCode::map_opt_string(diag.code.clone(), je),
251+
level: diag.level.to_str(),
252+
spans: DiagnosticSpan::from_multispan(&diag.span, je),
253+
children: diag.children.iter().map(|c| {
254254
Diagnostic::from_sub_diagnostic(c, je)
255255
}).chain(sugg).collect(),
256256
rendered: Some(output),
257257
}
258258
}
259259

260-
fn from_sub_diagnostic(db: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic {
260+
fn from_sub_diagnostic(diag: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic {
261261
Diagnostic {
262-
message: db.message(),
262+
message: diag.message(),
263263
code: None,
264-
level: db.level.to_str(),
265-
spans: db.render_span.as_ref()
264+
level: diag.level.to_str(),
265+
spans: diag.render_span.as_ref()
266266
.map(|sp| DiagnosticSpan::from_multispan(sp, je))
267-
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&db.span, je)),
267+
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&diag.span, je)),
268268
children: vec![],
269269
rendered: None,
270270
}

0 commit comments

Comments
 (0)