Skip to content

Commit

Permalink
Rollup merge of rust-lang#65428 - phansch:rename_db_var, r=Centril
Browse files Browse the repository at this point in the history
Refactor: Rename `db` locals to `diag`

rust-lang#64272 replaced `DiagnosticBuilder` with `Diagnostic` in some places. This PR just renames the db variable from `db` to `diag` where it wasn't renamed.

r? @Mark-Simulacrum
  • Loading branch information
Centril authored Oct 15, 2019
2 parents ebead31 + 6c75e81 commit 9fa8f02
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
10 changes: 5 additions & 5 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1667,13 +1667,13 @@ impl SharedEmitter {
}

impl Emitter for SharedEmitter {
fn emit_diagnostic(&mut self, db: &rustc_errors::Diagnostic) {
fn emit_diagnostic(&mut self, diag: &rustc_errors::Diagnostic) {
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
msg: db.message(),
code: db.code.clone(),
lvl: db.level,
msg: diag.message(),
code: diag.code.clone(),
lvl: diag.level,
})));
for child in &db.children {
for child in &diag.children {
drop(self.sender.send(SharedEmitterMessage::Diagnostic(Diagnostic {
msg: child.message(),
code: None,
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_errors/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ pub struct AnnotateSnippetEmitterWriter {

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

self.fix_multispans_in_std_macros(&self.source_map,
&mut primary_span,
&mut children,
&db.level,
&diag.level,
self.external_macro_backtrace);

self.emit_messages_default(&db.level,
db.message(),
&db.code,
self.emit_messages_default(&diag.level,
diag.message(),
&diag.code,
&primary_span,
&children,
&suggestions);
Expand Down
26 changes: 13 additions & 13 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const ANONYMIZED_LINE_NUM: &str = "LL";
/// Emitter trait for emitting errors.
pub trait Emitter {
/// Emit a structured diagnostic.
fn emit_diagnostic(&mut self, db: &Diagnostic);
fn emit_diagnostic(&mut self, diag: &Diagnostic);

/// Emit a notification that an artifact has been output.
/// This is currently only supported for the JSON format,
Expand All @@ -206,10 +206,10 @@ pub trait Emitter {
/// we return the original `primary_span` and the original suggestions.
fn primary_span_formatted<'a>(
&mut self,
db: &'a Diagnostic,
diag: &'a Diagnostic,
) -> (MultiSpan, &'a [CodeSuggestion]) {
let mut primary_span = db.span.clone();
if let Some((sugg, rest)) = db.suggestions.split_first() {
let mut primary_span = diag.span.clone();
if let Some((sugg, rest)) = diag.suggestions.split_first() {
if rest.is_empty() &&
// ^ if there is only one suggestion
// don't display multi-suggestions as labels
Expand Down Expand Up @@ -260,10 +260,10 @@ pub trait Emitter {
// to be consistent. We could try to figure out if we can
// make one (or the first one) inline, but that would give
// undue importance to a semi-random suggestion
(primary_span, &db.suggestions)
(primary_span, &diag.suggestions)
}
} else {
(primary_span, &db.suggestions)
(primary_span, &diag.suggestions)
}
}

Expand Down Expand Up @@ -401,19 +401,19 @@ impl Emitter for EmitterWriter {
self.sm.as_ref()
}

fn emit_diagnostic(&mut self, db: &Diagnostic) {
let mut children = db.children.clone();
let (mut primary_span, suggestions) = self.primary_span_formatted(&db);
fn emit_diagnostic(&mut self, diag: &Diagnostic) {
let mut children = diag.children.clone();
let (mut primary_span, suggestions) = self.primary_span_formatted(&diag);

self.fix_multispans_in_std_macros(&self.sm,
&mut primary_span,
&mut children,
&db.level,
&diag.level,
self.external_macro_backtrace);

self.emit_messages_default(&db.level,
&db.styled_message(),
&db.code,
self.emit_messages_default(&diag.level,
&diag.styled_message(),
&diag.code,
&primary_span,
&children,
&suggestions);
Expand Down
30 changes: 15 additions & 15 deletions src/libsyntax/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ impl JsonEmitter {
}

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

impl Diagnostic {
fn from_errors_diagnostic(db: &errors::Diagnostic,
fn from_errors_diagnostic(diag: &errors::Diagnostic,
je: &JsonEmitter)
-> Diagnostic {
let sugg = db.suggestions.iter().map(|sugg| {
let sugg = diag.suggestions.iter().map(|sugg| {
Diagnostic {
message: sugg.msg.clone(),
code: None,
Expand Down Expand Up @@ -241,30 +241,30 @@ impl Diagnostic {
let output = buf.clone();
je.json_rendered.new_emitter(
Box::new(buf), Some(je.sm.clone()), false, None, je.external_macro_backtrace
).ui_testing(je.ui_testing).emit_diagnostic(db);
).ui_testing(je.ui_testing).emit_diagnostic(diag);
let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap();
let output = String::from_utf8(output).unwrap();

Diagnostic {
message: db.message(),
code: DiagnosticCode::map_opt_string(db.code.clone(), je),
level: db.level.to_str(),
spans: DiagnosticSpan::from_multispan(&db.span, je),
children: db.children.iter().map(|c| {
message: diag.message(),
code: DiagnosticCode::map_opt_string(diag.code.clone(), je),
level: diag.level.to_str(),
spans: DiagnosticSpan::from_multispan(&diag.span, je),
children: diag.children.iter().map(|c| {
Diagnostic::from_sub_diagnostic(c, je)
}).chain(sugg).collect(),
rendered: Some(output),
}
}

fn from_sub_diagnostic(db: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic {
fn from_sub_diagnostic(diag: &SubDiagnostic, je: &JsonEmitter) -> Diagnostic {
Diagnostic {
message: db.message(),
message: diag.message(),
code: None,
level: db.level.to_str(),
spans: db.render_span.as_ref()
level: diag.level.to_str(),
spans: diag.render_span.as_ref()
.map(|sp| DiagnosticSpan::from_multispan(sp, je))
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&db.span, je)),
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&diag.span, je)),
children: vec![],
rendered: None,
}
Expand Down

0 comments on commit 9fa8f02

Please sign in to comment.