Skip to content

Commit bb6236c

Browse files
authored
Rollup merge of rust-lang#66754 - estebank:rustdoc-capitalization, r=Dylan-DPC
Various tweaks to diagnostic output
2 parents 0b3d4a1 + 5ea922a commit bb6236c

35 files changed

+115
-300
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
463463
&self,
464464
err: &mut DiagnosticBuilder<'_>,
465465
terr: &TypeError<'tcx>,
466-
sp: Span,
467466
) {
468467
use hir::def_id::CrateNum;
469468
use hir::map::DisambiguatedDefPathData;
@@ -577,14 +576,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
577576
};
578577
if same_path().unwrap_or(false) {
579578
let crate_name = self.tcx.crate_name(did1.krate);
580-
err.span_note(
581-
sp,
582-
&format!(
583-
"Perhaps two different versions \
584-
of crate `{}` are being used?",
585-
crate_name
586-
),
587-
);
579+
err.note(&format!(
580+
"perhaps two different versions of crate `{}` are being used?",
581+
crate_name
582+
));
588583
}
589584
}
590585
};
@@ -1434,7 +1429,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14341429
.unwrap_or_else(|| {
14351430
self.tcx.hir().body_owner_def_id(hir::BodyId { hir_id: cause.body_id })
14361431
});
1437-
self.check_and_note_conflicting_crates(diag, terr, span);
1432+
self.check_and_note_conflicting_crates(diag, terr);
14381433
self.tcx.note_and_explain_type_err(diag, terr, span, body_owner_def_id);
14391434

14401435
// It reads better to have the error origin as the final

src/librustc_metadata/creader.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,9 @@ impl<'a> CrateLoader<'a> {
698698
let has_global_allocator = match &*global_allocator_spans(krate) {
699699
[span1, span2, ..] => {
700700
self.sess.struct_span_err(*span2, "cannot define multiple global allocators")
701-
.span_note(*span1, "the previous global allocator is defined here").emit();
701+
.span_label(*span2, "cannot define a new global allocator")
702+
.span_label(*span1, "previous global allocator is defined here")
703+
.emit();
702704
true
703705
}
704706
spans => !spans.is_empty()

src/librustc_mir/borrow_check/conflict_errors.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,23 +1264,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12641264
Applicability::MachineApplicable,
12651265
);
12661266

1267-
match category {
1268-
ConstraintCategory::Return => {
1269-
err.span_note(constraint_span, "closure is returned here");
1270-
}
1271-
ConstraintCategory::OpaqueType => {
1272-
err.span_note(constraint_span, "generator is returned here");
1273-
}
1267+
let msg = match category {
1268+
ConstraintCategory::Return => "closure is returned here".to_string(),
1269+
ConstraintCategory::OpaqueType => "generator is returned here".to_string(),
12741270
ConstraintCategory::CallArgument => {
12751271
fr_name.highlight_region_name(&mut err);
1276-
err.span_note(
1277-
constraint_span,
1278-
&format!("function requires argument type to outlive `{}`", fr_name),
1279-
);
1272+
format!("function requires argument type to outlive `{}`", fr_name)
12801273
}
12811274
_ => bug!("report_escaping_closure_capture called with unexpected constraint \
12821275
category: `{:?}`", category),
1283-
}
1276+
};
1277+
err.span_note(constraint_span, &msg);
12841278
err
12851279
}
12861280

src/librustc_mir/borrow_check/move_errors.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
558558
err: &mut DiagnosticBuilder<'a>,
559559
binds_to: &[Local],
560560
) {
561-
let mut noncopy_var_spans = Vec::new();
562561
for (j, local) in binds_to.into_iter().enumerate() {
563562
let bind_to = &self.body.local_decls[*local];
564563
let binding_span = bind_to.source_info.span;
@@ -576,16 +575,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
576575
bind_to.ty,
577576
Some(binding_span)
578577
);
579-
} else {
580-
noncopy_var_spans.push(binding_span);
581578
}
582579
}
583580

584581
if binds_to.len() > 1 {
585-
err.span_note(
586-
noncopy_var_spans,
587-
"move occurs because these variables have types that \
588-
don't implement the `Copy` trait",
582+
err.note("move occurs because these variables have types that \
583+
don't implement the `Copy` trait",
589584
);
590585
}
591586
}

src/librustc_parse/parser/item.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,12 @@ impl<'a> Parser<'a> {
491491
}
492492

493493
/// Parses a macro invocation inside a `trait`, `impl` or `extern` block.
494-
fn parse_assoc_macro_invoc(&mut self, item_kind: &str, vis: Option<&Visibility>,
495-
at_end: &mut bool) -> PResult<'a, Option<Mac>>
496-
{
494+
fn parse_assoc_macro_invoc(
495+
&mut self,
496+
item_kind: &str,
497+
vis: Option<&Visibility>,
498+
at_end: &mut bool,
499+
) -> PResult<'a, Option<Mac>> {
497500
if self.token.is_path_start() &&
498501
!(self.is_async_fn() && self.token.span.rust_2015()) {
499502
let prev_span = self.prev_span;
@@ -532,9 +535,11 @@ impl<'a> Parser<'a> {
532535
}
533536
}
534537

535-
fn missing_assoc_item_kind_err(&self, item_type: &str, prev_span: Span)
536-
-> DiagnosticBuilder<'a>
537-
{
538+
fn missing_assoc_item_kind_err(
539+
&self,
540+
item_type: &str,
541+
prev_span: Span,
542+
) -> DiagnosticBuilder<'a> {
538543
let expected_kinds = if item_type == "extern" {
539544
"missing `fn`, `type`, or `static`"
540545
} else {

src/librustc_passes/loops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> {
144144
"`continue` pointing to a labeled block")
145145
.span_label(e.span,
146146
"labeled blocks cannot be `continue`'d")
147-
.span_note(block.span,
148-
"labeled block the continue points to")
147+
.span_label(block.span,
148+
"labeled block the `continue` points to")
149149
.emit();
150150
}
151151
}

src/librustc_resolve/resolve_imports.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,8 +1160,10 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
11601160
.emit();
11611161
} else {
11621162
let msg = format!("`{}` is private, and cannot be re-exported", ident);
1163-
let note_msg =
1164-
format!("consider marking `{}` as `pub` in the imported module", ident);
1163+
let note_msg = format!(
1164+
"consider marking `{}` as `pub` in the imported module",
1165+
ident,
1166+
);
11651167
struct_span_err!(self.r.session, directive.span, E0364, "{}", &msg)
11661168
.span_note(directive.span, &note_msg)
11671169
.emit();

src/librustdoc/passes/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ pub fn look_for_tests<'tcx>(
344344
lint::builtin::MISSING_DOC_CODE_EXAMPLES,
345345
hir_id,
346346
sp,
347-
"Missing code example in this documentation");
347+
"missing code example in this documentation");
348348
diag.emit();
349349
} else if check_missing_code == false &&
350350
tests.found_tests > 0 &&
@@ -353,7 +353,7 @@ pub fn look_for_tests<'tcx>(
353353
lint::builtin::PRIVATE_DOC_TESTS,
354354
hir_id,
355355
span_of_attrs(&item.attrs).unwrap_or(item.source.span()),
356-
"Documentation test in private item");
356+
"documentation test in private item");
357357
diag.emit();
358358
}
359359
}
@@ -367,7 +367,7 @@ crate fn span_of_attrs(attrs: &clean::Attributes) -> Option<Span> {
367367
if start == DUMMY_SP {
368368
return None;
369369
}
370-
let end = attrs.doc_strings.last().expect("No doc strings provided").span();
370+
let end = attrs.doc_strings.last().expect("no doc strings provided").span();
371371
Some(start.to(end))
372372
}
373373

src/libsyntax/feature_gate/check.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -688,10 +688,9 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
688688
crate_edition: Edition, allow_features: &Option<Vec<String>>) -> Features {
689689
fn feature_removed(span_handler: &Handler, span: Span, reason: Option<&str>) {
690690
let mut err = struct_span_err!(span_handler, span, E0557, "feature has been removed");
691+
err.span_label(span, "feature has been removed");
691692
if let Some(reason) = reason {
692-
err.span_note(span, reason);
693-
} else {
694-
err.span_label(span, "feature has been removed");
693+
err.note(reason);
695694
}
696695
err.emit();
697696
}

src/libsyntax_expand/mbe/macro_check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ fn check_binders(
269269
// for nested macro definitions.
270270
sess.span_diagnostic
271271
.struct_span_err(span, "duplicate matcher binding")
272-
.span_note(prev_info.span, "previous declaration was here")
272+
.span_label(span, "duplicate binding")
273+
.span_label(prev_info.span, "previous binding")
273274
.emit();
274275
*valid = false;
275276
} else {

0 commit comments

Comments
 (0)